Skip to content

Commit

Permalink
m.proj: replace checks in code by parser rules (#106)
Browse files Browse the repository at this point in the history
This simplifies the code and translations and standardizes the messages,
but it also allows m.proj in command line to start GUI as all the other
modules do without an explicit --ui.

All checks are replaced by rules except the overwrite check which is checked by the parser itself.
  • Loading branch information
wenzeslaus committed Aug 27, 2019
1 parent b5e6311 commit 5b38358
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions scripts/m.proj/m.proj.py
Expand Up @@ -10,7 +10,7 @@
PURPOSE: cs2cs reprojection frontend for a list of coordinates.
Replacement for m.proj2 from GRASS 5
COPYRIGHT: (c) 2006-2014 Hamish Bowman, and the GRASS Development Team
COPYRIGHT: (c) 2006-2019 Hamish Bowman, and the GRASS Development Team
This program is free software under the GNU General Public
License (>=v2). Read the file COPYING that comes with GRASS
for details.
Expand Down Expand Up @@ -90,7 +90,13 @@
#% description: Include column names in output file
#% guisection: Output
#%end

#%rules
#% required: coordinates, input
#% exclusive: coordinates, input
#% exclusive: proj_in, -i
#% exclusive: proj_out, -o
#% exclusive: -i, -o
#%end

import sys
import os
Expand Down Expand Up @@ -139,25 +145,6 @@ def main():
"cs2cs program not found, install PROJ.4 first: \
http://proj.maptools.org"))

# check for overenthusiasm
if proj_in and ll_in:
gcore.fatal(_("Choose only one input parameter method"))

if proj_out and ll_out:
gcore.fatal(_("Choose only one output parameter method"))

if ll_in and ll_out:
gcore.fatal(_("Choose only one auto-projection parameter method"))

if output and not gcore.overwrite() and os.path.exists(output):
gcore.fatal(_("Output file already exists"))

if not coords and not input:
gcore.fatal(_("One of <coordinates> and <input> must be given"))
if coords and input:
gcore.fatal(_(
"Options <coordinates> and <input> are mutually exclusive"))

# parse field separator
# FIXME: input_x,y needs to split on multiple whitespace between them
if fs == ',':
Expand Down

0 comments on commit 5b38358

Please sign in to comment.