changeset 1494:ae76ea63ee12

csv_to_fd: improve comments and usage
author Luke Mewburn <luke@mewburn.net>
date Mon, 30 Mar 2020 16:46:31 +1100
parents a89913941dcf
children acbfec3df281
files contrib/tools/csv_to_fd
diffstat 1 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/tools/csv_to_fd	Mon Mar 30 15:31:48 2020 +1100
+++ b/contrib/tools/csv_to_fd	Mon Mar 30 16:46:31 2020 +1100
@@ -10,6 +10,7 @@
     - Name:
         AVP Name. String, validated as ALPHA *(ALPHA / DIGIT / "-")
         per RFC 6733 section 3.2.
+        May start with a DIGIT (e.g., "3GPP-IMSI").
     - Code:
         AVP Code. Integer, 0..4294967295.
     - Section:
@@ -20,7 +21,7 @@
             - RFC 6733 section 4.3
             - RFC 7155 section 4.1
     - Must, May, ShouldNot, MustNot:
-        Flags, possibly comma or space separated: M, V
+        Flags, possibly comma or space separated: M, P, V
 
 - Comment row. First cell:
     # Comment text      'Comment text'
@@ -182,7 +183,7 @@
 
 
 class Processor(object):
-    """Interface for processor of Avp"""
+    """Interface for processor of Avp."""
 
     __metaclass__ = abc.ABCMeta
 
@@ -226,7 +227,7 @@
 
 
 class DebugProcessor(Processor):
-    """Display the CSV parsing"""
+    """Display the CSV parsing."""
 
     def next_file(self, filename):
         print('File: {}'.format(filename))
@@ -243,7 +244,7 @@
 
 
 class NoopProcessor(Processor):
-    """Validate the CSV; no other output"""
+    """Validate the CSV; no other output."""
 
     def next_file(self, filename):
         pass
@@ -259,7 +260,7 @@
 
 
 class FdcProcessor(Processor):
-    """Generate freeDiameter C code
+    """Generate freeDiameter C code.
 
     Comment cells are parsed as:
         # text comment  /* text comment */
@@ -374,7 +375,7 @@
 
 
 class JsonProcessor(Processor):
-    """Generate freeDiameter JSON object
+    """Generate freeDiameter JSON object.
     """
 
     def __init__(self):
@@ -460,8 +461,9 @@
 
     # Parse options
     parser = MyParser(
+        usage='%prog [-h] [-p PROCESSOR] FILE ...',
         description="""\
-Convert CSV files containing RADIUS or Diameter AVP tables
+Convert CSV files FILE ... containing RADIUS or Diameter AVP tables
 into various formats using the specified processor PROCESSOR.
 """)
 
@@ -472,13 +474,13 @@
              ', '.join(processors.keys())))
     (opts, args) = parser.parse_args()
     if len(args) < 1:
-        parser.error('Incorrect number of arguments')
+        parser.error('Incorrect number of arguments. Use -h for help.')
 
     # Find processor
     try:
         avpproc = processors[opts.processor]()
     except KeyError as e:
-        parser.error('Unknown processor "{}"'.format(opts.processor))
+        parser.error('Unknown processor "{}".'.format(opts.processor))
 
     # dict of [vendor][code] : Avp
     avp_codes = collections.defaultdict(dict)
"Welcome to our mercurial repository"