19 #include "parser_local_proto.h"
29 fprintf(fp,
"#!/usr/bin/env python3\n");
30 fprintf(fp,
"##############################################################"
34 fprintf(fp,
"# AUTHOR(S): %s\n",
G_whoami());
37 "# COPYRIGHT: (C) %s by %s, and the GRASS Development Team\n",
40 fprintf(fp,
"# This program is free software; you can redistribute it "
42 fprintf(fp,
"# it under the terms of the GNU General Public License as "
44 fprintf(fp,
"# the Free Software Foundation; either version 2 of the "
46 fprintf(fp,
"# (at your option) any later version.\n");
50 "# This program is distributed in the hope that it will be useful,\n");
53 "# but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
56 "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
57 fprintf(fp,
"# GNU General Public License for more details.\n");
59 fprintf(fp,
"##############################################################"
60 "##############\n\n");
62 fprintf(fp,
"\"\"\"Wraps %s to make it even better\"\"\"\n\n",
65 fprintf(fp,
"# %%module\n");
66 if (
st->module_info.label)
67 fprintf(fp,
"# %% label: %s\n",
st->module_info.label);
68 if (
st->module_info.description)
69 fprintf(fp,
"# %% description: %s\n",
st->module_info.description);
70 if (
st->module_info.keywords) {
73 for (i = 0; i <
st->n_keys; i++) {
74 fprintf(fp,
"# %% keyword: %s\n",
st->module_info.keywords[i]);
77 fprintf(fp,
"# %%end\n");
82 for (flag = &
st->first_flag; flag; flag = flag->
next_flag) {
83 fprintf(fp,
"# %%flag\n");
84 fprintf(fp,
"# %% key: %c\n", flag->
key);
86 fprintf(fp,
"# %% suppress_required: yes\n");
88 fprintf(fp,
"# %% label: %s\n", flag->
label);
90 fprintf(fp,
"# %% description: %s\n", flag->
description);
92 fprintf(fp,
"# %% guisection: %s\n", flag->
guisection);
93 fprintf(fp,
"# %%end\n");
100 for (opt = &
st->first_option; opt; opt = opt->
next_opt) {
116 fprintf(fp,
"# %%option\n");
117 fprintf(fp,
"# %% key: %s\n", opt->
key);
118 fprintf(fp,
"# %% type: %s\n",
type);
119 fprintf(fp,
"# %% required: %s\n", opt->
required ?
"yes" :
"no");
120 fprintf(fp,
"# %% multiple: %s\n", opt->
multiple ?
"yes" :
"no");
122 fprintf(fp,
"# %% options: %s\n", opt->
options);
124 fprintf(fp,
"# %% key_desc: %s\n", opt->
key_desc);
126 fprintf(fp,
"# %% label: %s\n", opt->
label);
128 fprintf(fp,
"# %% description: %s\n", opt->
description);
130 fprintf(fp,
"# %% descriptions: %s\n", opt->
descriptions);
132 fprintf(fp,
"# %% answer: %s\n", opt->
answer);
134 fprintf(fp,
"# %% gisprompt: %s\n", opt->
gisprompt);
136 fprintf(fp,
"# %% guisection: %s\n", opt->
guisection);
139 fprintf(fp,
"# %%end\n");
143 fprintf(fp,
"\nimport grass.script as gs\n\n");
144 fprintf(fp,
"\ndef main():");
147 "\n \"\"\"Process command line parameters and run analysis\"\"\"");
148 fprintf(fp,
"\n options, flags = gs.parser()");
149 fprintf(fp,
"\n # Put your code here.");
151 fprintf(fp,
"\nif __name__ == \"__main__\":");
152 fprintf(fp,
"\n main()\n");
const char * G_whoami(void)
Gets user's name.
const char * G_program_name(void)
Return module name.
void G__script(void)
Generate Python script-like output.
Structure that stores flag info.
Structure that stores option information.
const char * descriptions
const char * guidependency