diff --git a/CHANGES.txt b/CHANGES.txt index 01762c3..0be839b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,5 +3,8 @@ June 21, 2017 -- ssteinerX WORK IN PROGRESS... * Add CHANGES.txt (this file) +* Add TODO.txt * Remove Python 3.1, 3.2, and 3.3 from tests. Versions are obsolete and are no longer supported. -* Add travis.yml +* Add Travis support & badge in README.rst +* Update GitHub page & maintainer info +* diff --git a/README.rst b/README.rst index fee265c..6f0132c 100755 --- a/README.rst +++ b/README.rst @@ -7,7 +7,6 @@ Yay, Travis status: .. image:: https://travis-ci.org/ssteinerx/pingparser.svg?branch=master :target: https://travis-ci.org/ssteinerx/pingparser - Usage ~~~~~ You can pipe ping command output into pingparser.py on the command line, which diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 0000000..59e691f --- /dev/null +++ b/TODO.txt @@ -0,0 +1,19 @@ +ToDo: June 22, 2017 +------------------- +pingparser.py: + + > Consolidate `format_replacements`, currently a list of tuples, then + duplicated in return statement of parse() function. + + Make it an ordered dict and use it to build `default_format` and + JSON return value. + + `default_format` should only be built JIT since it's not used when: + * pingparser is used as a library (i.e. when just calling parse() on results). + * when different formatting is given on the command line + + > NOTE: pulled from my (ssteinerX) inline comments. Not sure exactly what I meant...it's not specific enough, but says: + "Make `minmax_matcher` more specific i.e. match a bit before the '=' sign" + + > Completely remove "+" parameter formatting. + See related NOTE:s in pingparser.py near text: "+...format string" diff --git a/pingparser.py b/pingparser.py index 8973575..1ab9941 100755 --- a/pingparser.py +++ b/pingparser.py @@ -3,7 +3,7 @@ """ Parses the output of the system ping command. """ -__version__ = '0.4' +__version__ = '0.5' from optparse import OptionGroup, OptionParser @@ -12,7 +12,6 @@ __all__ = ["parse", "format_ping_result", - "main", ] # Pull regex compilation out of parser() so it only gets done once @@ -31,7 +30,6 @@ rslt_matcher = re.compile(r'(\d+) packets transmitted, (\d+) (?:packets )?received, (\d+\.?\d*)% packet loss') # Pull out round-trip min/avg/max/stddev = 49.042/49.042/49.042/0.000 ms -# TODO: make this more specific i.e. match a bit before the '=' sign minmax_matcher = re.compile(r'(\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+)') # Available replacements @@ -123,18 +121,22 @@ def main(argv=sys.argv): # parser.add_option("+", dest="format", # help="optional format string") - format_group = OptionGroup(parser, - """FORMAT controls the output. Interpreted sequences are: - \t%h host name or IP address - \t%s packets sent - \t%r packets received - \t%p packet_loss - \t%m minimum ping in milliseconds - \t%a average ping in milliseconds - \t%M maximum ping in milliseconds - \t%j jitter in milliseconds + format_group = OptionGroup( + parser, + """ + FORMAT controls the output. Interpreted sequences are: - Default FORMAT is: """ + default_format) + \t%h host name or IP address + \t%s packets sent + \t%r packets received + \t%p packet_loss + \t%m minimum ping in milliseconds + \t%a average ping in milliseconds + \t%M maximum ping in milliseconds + \t%j jitter in milliseconds + + Default FORMAT is: """ + default_format + ) parser.add_option_group(format_group) (options, args) = parser.parse_args() @@ -176,6 +178,7 @@ def main(argv=sys.argv): sys.exit(0) + if __name__ == "__main__": try: main(sys.argv) diff --git a/setup.cfg b/setup.cfg index 600213c..ff3f7cf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,9 +5,9 @@ author = Gregg Gajic author_email = gregg.gajic@gmail.com summary = Parses the output of the system ping command. description-file = README.rst -home_page = https://github.com/gg/pingparser +home_page = https://github.com/ssteinerx/pingparser project_url = - Source repository,https://github.com/gg/pingparser + Source repository,https://github.com/ssteinerx/pingparser license = UNLICENSE maintainer = Steve Steiner maintainer-email = ssteinerX@gmail.com