17 #include <grass/gis.h> 19 #include "parser_local_proto.h" 30 "#!/usr/bin/env python\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) {
65 fprintf(fp,
"#%% keyword: ");
69 fprintf(fp,
"#%%end\n");
74 for (flag = &
st->first_flag; flag; flag = flag->next_flag) {
75 fprintf(fp,
"#%%flag\n");
76 fprintf(fp,
"#%% key: %c\n", flag->key);
77 if (flag->suppress_required)
78 fprintf(fp,
"#%% suppress_required: yes\n");
80 fprintf(fp,
"#%% label: %s\n", flag->label);
81 if (flag->description)
82 fprintf(fp,
"#%% description: %s\n", flag->description);
84 fprintf(fp,
"#%% guisection: %s\n", flag->guisection);
85 fprintf(fp,
"#%%end\n");
92 for (opt = &
st->first_option; opt; opt = opt->next_opt) {
108 fprintf(fp,
"#%%option\n");
109 fprintf(fp,
"#%% key: %s\n", opt->key);
110 fprintf(fp,
"#%% type: %s\n", type);
111 fprintf(fp,
"#%% required: %s\n", opt->required ?
"yes" :
"no");
112 fprintf(fp,
"#%% multiple: %s\n", opt->multiple ?
"yes" :
"no");
114 fprintf(fp,
"#%% options: %s\n", opt->options);
116 fprintf(fp,
"#%% key_desc: %s\n", opt->key_desc);
118 fprintf(fp,
"#%% label: %s\n", opt->label);
119 if (opt->description)
120 fprintf(fp,
"#%% description: %s\n", opt->description);
121 if (opt->descriptions)
122 fprintf(fp,
"#%% descriptions: %s\n", opt->descriptions);
124 fprintf(fp,
"#%% answer: %s\n", opt->answer);
126 fprintf(fp,
"#%% gisprompt: %s\n", opt->gisprompt);
128 fprintf(fp,
"#%% guisection: %s\n", opt->guisection);
129 if (opt->guidependency)
130 fprintf(fp,
"#%% guidependency: %s\n", opt->guidependency);
131 fprintf(fp,
"#%%end\n");
135 fprintf(fp,
"\nimport sys\n");
136 fprintf(fp,
"\nimport grass.script as grass\n");
137 fprintf(fp,
"\ndef main():");
138 fprintf(fp,
"\n # put code here\n");
139 fprintf(fp,
"\n return 0\n");
140 fprintf(fp,
"\nif __name__ == \"__main__\":");
141 fprintf(fp,
"\n options, flags = grass.parser()");
142 fprintf(fp,
"\n sys.exit(main())\n");
void G__script(void)
Generate Python script-like output.
const char * G_program_name(void)
Return module name.
const char * G_whoami(void)
Gets user's name.
void G__print_keywords(FILE *fd, void(*format)(FILE *, const char *))
Print list of keywords (internal use only)