From c3655b1338fc61a1215d266c86f6dd1eeea92247 Mon Sep 17 00:00:00 2001
From: Hal Simpson <hasimpson@usgs.gov>
Date: Wed, 1 Apr 2015 12:48:58 -0600
Subject: [PATCH] moved parsers back into geomag.py

---
 bin/geomag.py                        | 47 +++++++++++++++++++++++-----
 geomagio/XYZAlgorithm.py             | 13 --------
 geomagio/iaga2002/IAGA2002Factory.py | 36 ---------------------
 3 files changed, 40 insertions(+), 56 deletions(-)

diff --git a/bin/geomag.py b/bin/geomag.py
index 2c327e49f..b47039a57 100755
--- a/bin/geomag.py
+++ b/bin/geomag.py
@@ -17,9 +17,6 @@ from geomagio.Algorithm import Algorithm
 from geomagio.XYZAlgorithm import XYZAlgorithm
 from geomagio.Controller import Controller
 from geomagio.iaga2002.IAGA2002Factory import IAGA_FILE_PATTERN
-from geomagio.iaga2002.IAGA2002Factory import iaga_add_parse_arguments
-from geomagio.XYZAlgorithm import XYZAlgorithm_add_parse_arguments
-from geomagio.edge.EdgeFactory import edge_add_parse_arguments
 from obspy.core.utcdatetime import UTCDateTime
 
 
@@ -145,10 +142,46 @@ def parse_args():
 
     parser.add_argument('--algorithm', choices=['xyz', ])
 
-    # Add I/O and Algorithm specific arguments
-    iaga_add_parse_arguments(parser)
-    edge_add_parse_arguments(parser)
-    XYZAlgorithm_add_parse_arguments(parser)
+    # iaga specific args.
+    parser.add_argument('--input-iaga-file',
+            help='Iaga2002 filename')
+    parser.add_argument('--input-iaga-magweb',
+            action="store_true", default=False,
+            help='Indicates iaga2002 files will be read from \
+            http://magweb.cr.usgs.gov/data/magnetometer/')
+    parser.add_argument('--input-iaga-stdin',
+            action="store_true", default=False,
+            help='Indicates file will be redirected from stdin')
+    parser.add_argument('--input-iaga-url',
+            help='Url or Directory where Iaga2002 files can be read from')
+    parser.add_argument('--input-iaga-urltemplate',
+            help='Template for directory matching')
+    parser.add_argument('--input-iaga-filetemplate',
+            help='Template for iaga filenames')
+
+    parser.add_argument('--output-iaga-url',
+            help='Url or Directory where IAGA2002 files should be written to')
+    parser.add_argument('--output-iaga-stdout',
+            action="store_true", default=False,
+            help='Indicates file will be directed to stdout')
+    parser.add_argument('--output-iaga-urltemplate',
+            help='Template for subdirectories')
+    parser.add_argument('--output-iaga-filetemplate',
+            help='Template for iaga filenames')
+    parser.add_argument('--output-iaga-file',
+            help='Output file name for single iaga file.')
+
+    # edge specific args
+    parser.add_argument('--input-edge-host',
+            help='ip address of the edge input server')
+    parser.add_argument('--input-edge-port', type=int,
+            help='port number of the edge input server')
+
+    # XYZ Algorithm specific args
+    parser.add_argument('--xyz-informat',
+            choices=['geo', 'mag', 'obs', 'obsd'])
+    parser.add_argument('--xyz-outformat',
+            choices=['geo', 'mag', 'obs', 'obsd'])
 
     return parser.parse_args()
 
diff --git a/geomagio/XYZAlgorithm.py b/geomagio/XYZAlgorithm.py
index bf06b300d..60e175a70 100644
--- a/geomagio/XYZAlgorithm.py
+++ b/geomagio/XYZAlgorithm.py
@@ -19,19 +19,6 @@ CHANNELS = {
 }
 
 
-def XYZAlgorithm_add_parse_arguments(parser):
-    """add XYZ specific arguments to parser
-
-    Parameters
-    ----------
-    parser: argparse.ArgumentParser
-    """
-    parser.add_argument('--xyz-informat',
-            choices=['geo', 'mag', 'obs', 'obsd'])
-    parser.add_argument('--xyz-outformat',
-            choices=['geo', 'mag', 'obs', 'obsd'])
-
-
 class XYZAlgorithm(Algorithm):
     """Algorithm for converting data,  probably inapproprately named XYZ.
 
diff --git a/geomagio/iaga2002/IAGA2002Factory.py b/geomagio/iaga2002/IAGA2002Factory.py
index 493bdd08a..c5be4f1bd 100644
--- a/geomagio/iaga2002/IAGA2002Factory.py
+++ b/geomagio/iaga2002/IAGA2002Factory.py
@@ -43,42 +43,6 @@ def read_url(url):
     return content
 
 
-def iaga_add_parse_arguments(parser):
-    """add iaga2002 specific arguments to parser
-
-    Parameters
-    ----------
-    parser: argparse.ArgumentParser
-    """
-    parser.add_argument('--input-iaga-file',
-            help='Iaga2002 filename')
-    parser.add_argument('--input-iaga-magweb',
-            action="store_true", default=False,
-            help='Indicates iaga2002 files will be read from \
-            http://magweb.cr.usgs.gov/data/magnetometer/')
-    parser.add_argument('--input-iaga-stdin',
-            action="store_true", default=False,
-            help='Indicates file will be redirected from stdin')
-    parser.add_argument('--input-iaga-url',
-            help='Url or Directory where Iaga2002 files can be read from')
-    parser.add_argument('--input-iaga-urltemplate',
-            help='Template for directory matching')
-    parser.add_argument('--input-iaga-filetemplate',
-            help='Template for iaga filenames')
-
-    parser.add_argument('--output-iaga-url',
-            help='Url or Directory where IAGA2002 files should be written to')
-    parser.add_argument('--output-iaga-stdout',
-            action="store_true", default=False,
-            help='Indicates file will be directed to stdout')
-    parser.add_argument('--output-iaga-urltemplate',
-            help='Template for subdirectories')
-    parser.add_argument('--output-iaga-filetemplate',
-            help='Template for iaga filenames')
-    parser.add_argument('--output-iaga-file',
-            help='Output file name for single iaga file.')
-
-
 class IAGA2002Factory(TimeseriesFactory):
     """TimeseriesFactory for IAGA 2002 formatted files.
 
-- 
GitLab