19 #include "parser_local_proto.h" 30 "#!/usr/bin/env python3\n");
32 "############################################################################\n");
35 fprintf(fp,
"# AUTHOR(S): %s\n",
G_whoami());
37 fprintf(fp,
"# COPYRIGHT: (C) %s by %s, and the GRASS Development Team\n",
41 "# This program is free software; you can redistribute it and/or modify\n");
43 "# it under the terms of the GNU General Public License as published by\n");
45 "# the Free Software Foundation; either version 2 of the License, or\n");
46 fprintf(fp,
"# (at your option) any later version.\n");
49 "# This program is distributed in the hope that it will be useful,\n");
51 "# but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
53 "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
54 fprintf(fp,
"# GNU General Public License for more details.\n");
57 "############################################################################\n\n");
59 fprintf(fp,
"# %%module\n");
60 if (
st->module_info.label)
61 fprintf(fp,
"# %% label: %s\n",
st->module_info.label);
62 if (
st->module_info.description)
63 fprintf(fp,
"# %% description: %s\n",
st->module_info.description);
64 if (
st->module_info.keywords) {
67 for(i = 0; i <
st->n_keys; i++) {
68 fprintf(fp,
"# %% keyword: %s\n",
st->module_info.keywords[i]);
71 fprintf(fp,
"# %%end\n");
76 for (flag = &
st->first_flag; flag; flag = flag->
next_flag) {
77 fprintf(fp,
"# %%flag\n");
78 fprintf(fp,
"# %% key: %c\n", flag->
key);
80 fprintf(fp,
"# %% suppress_required: yes\n");
82 fprintf(fp,
"# %% label: %s\n", flag->
label);
84 fprintf(fp,
"# %% description: %s\n", flag->
description);
86 fprintf(fp,
"# %% guisection: %s\n", flag->
guisection);
87 fprintf(fp,
"# %%end\n");
94 for (opt = &
st->first_option; opt; opt = opt->
next_opt) {
110 fprintf(fp,
"# %%option\n");
111 fprintf(fp,
"# %% key: %s\n", opt->
key);
112 fprintf(fp,
"# %% type: %s\n", type);
113 fprintf(fp,
"# %% required: %s\n", opt->
required ?
"yes" :
"no");
114 fprintf(fp,
"# %% multiple: %s\n", opt->
multiple ?
"yes" :
"no");
116 fprintf(fp,
"# %% options: %s\n", opt->
options);
118 fprintf(fp,
"# %% key_desc: %s\n", opt->
key_desc);
120 fprintf(fp,
"# %% label: %s\n", opt->
label);
122 fprintf(fp,
"# %% description: %s\n", opt->
description);
124 fprintf(fp,
"# %% descriptions: %s\n", opt->
descriptions);
126 fprintf(fp,
"# %% answer: %s\n", opt->
answer);
128 fprintf(fp,
"# %% gisprompt: %s\n", opt->
gisprompt);
130 fprintf(fp,
"# %% guisection: %s\n", opt->
guisection);
133 fprintf(fp,
"# %%end\n");
137 fprintf(fp,
"\nimport sys\n");
138 fprintf(fp,
"\nimport grass.script as gs\n");
139 fprintf(fp,
"\ndef main():");
140 fprintf(fp,
"\n # put code here\n");
141 fprintf(fp,
"\n return 0\n");
142 fprintf(fp,
"\nif __name__ == \"__main__\":");
143 fprintf(fp,
"\n options, flags = gs.parser()");
144 fprintf(fp,
"\n sys.exit(main())\n");
const char * guidependency
const char * G_program_name(void)
Return module name.
const char * G_whoami(void)
Gets user's name.
const char * descriptions
Structure that stores flag info.
void G__script(void)
Generate Python script-like output.
Structure that stores option information.