diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | Makefile.nmake | 4 | ||||
-rw-r--r-- | tools/Makefile.am | 2 | ||||
-rwxr-xr-x | tools/make-services.py | 30 |
4 files changed, 19 insertions, 19 deletions
diff --git a/Makefile.am b/Makefile.am index 586c2b17f1..1fd3011826 100644 --- a/Makefile.am +++ b/Makefile.am @@ -605,7 +605,7 @@ SUFFIXES = .sh $(editsh) $< > $@.tmp && chmod +x $@.tmp && mv $@.tmp $@ services: - $(PERL) $(srcdir)/tools/make-services.pl + $(PYTHON) $(srcdir)/tools/make-services.py CLEANFILES = \ *~ \ diff --git a/Makefile.nmake b/Makefile.nmake index f6dab8a470..42fa30a7f4 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -802,8 +802,8 @@ doxygen-run: doxygen: doxygen.cfg doxygen-run -services: tools\make-services.pl - $(PERL) tools/make-services.pl +services: tools\make-services.py + $(PYTHON) tools/make-services.py ################################################################################ # Prepare build environment by downloading and installing required libraries diff --git a/tools/Makefile.am b/tools/Makefile.am index fb26089b9f..d85d5c140c 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -114,7 +114,7 @@ EXTRA_DIST = \ make-dissector-reg.py \ make-manuf \ make-sminmpec.pl \ - make-services.pl \ + make-services.py \ make-tapreg-dotc \ make-tap-reg.py \ msnchat \ diff --git a/tools/make-services.py b/tools/make-services.py index 42047b8f59..4753e727ef 100755 --- a/tools/make-services.py +++ b/tools/make-services.py @@ -21,22 +21,22 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -iana_ns = 'http://www.iana.org/assignments' -iana_port_url = iana_ns + '/service-names-port-numbers/service-names-port-numbers.csv' +iana_svc_url = 'http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.csv' __doc__ = '''\ Usage: make-services.py [url] url defaults to %s -''' % (iana_port_url) +''' % (iana_svc_url) import sys import getopt import csv import re -if sys.version_info[0] < 3: +python_version = sys.hexversion >> 16 +if python_version < 0x300: import urllib else: import urllib.request, urllib.error, urllib.parse @@ -57,12 +57,12 @@ exclude_comments = [ min_body_size = 900000 # Size was ~ 922000 on 2013-08-06 -def parse_rows(port_fd): +def parse_rows(svc_fd): lines = [] - port_reader = csv.reader(port_fd) + port_reader = csv.reader(svc_fd) # Header positions as of 2013-08-06 - if sys.version_info[0] < 3: + if python_version < 0x206: headers = port_reader.next() else: headers = next(port_reader) @@ -128,20 +128,20 @@ def main(argv): exit_msg(None, 0) if (len(argv) > 0): - port_url = argv[0] + svc_url = argv[0] else: - port_url = iana_port_url + svc_url = iana_svc_url try: - if sys.version_info[0] < 3: - port_fd = urllib.urlopen(port_url) + if python_version < 0x300: + svc_fd = urllib.urlopen(svc_url) else: - req = urllib.request.urlopen(port_url) - port_fd = codecs.getreader('utf8')(req) + req = urllib.request.urlopen(svc_url) + svc_fd = codecs.getreader('utf8')(req) except URLError: exit_err(URLError) - body = parse_rows(port_fd) + body = parse_rows(svc_fd) if len(body) < min_body_size: exit_err('Not enough parsed data') @@ -162,7 +162,7 @@ def main(argv): # %s -''' % (iana_port_url, body)) +''' % (iana_svc_url, body)) if __name__ == "__main__": sys.exit(main(sys.argv[1:])) |