diff options
author | Fred Wright <fw@fwright.net> | 2016-04-09 19:57:16 -0700 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2016-04-10 04:59:07 -0400 |
commit | 4ce87b1b589e6241553d20c72716954cdb415210 (patch) | |
tree | b006eae040b42bb9c8dd228668ac322ee984aa25 | |
parent | f089f6d2dda9fa95bdf9b0e1e8ede9fa61ce087c (diff) | |
download | gpsd-4ce87b1b589e6241553d20c72716954cdb415210.tar.gz |
Makes "future imports" and Python version comments consistent.
This makes the "future import" statements consistently specify
absolute_import, print_function, and division, for maximum consistency
between Python 2 and Python 3. Although absolute_import is probably a
don't care for top-level programs, if unit tests were ever implemented
for the programs they would be imported as modules, making the module
import behavior relevant.
Note that previous Python 3 fixes are a prerequisite for this change.
Also makes the "polyglot comment" consistent across sources.
TESTED:
Using a version of SConstruct patched to use the target Python for
build helpers, ran "scons build-all check valgrind-audit
www/hardware.html" with all six supported Python versions. Also ran
gegps, gpscat, gpsprof, xgps, and xgpsspeed with both Python 2 and
Python 3.
-rwxr-xr-x | gegps | 5 | ||||
-rw-r--r-- | gps/__init__.py | 4 | ||||
-rw-r--r-- | gps/client.py | 2 | ||||
-rwxr-xr-x | gps/gps.py | 2 | ||||
-rw-r--r-- | gpscap.py | 5 | ||||
-rwxr-xr-x | gpscat | 2 | ||||
-rwxr-xr-x | gpsfake | 2 | ||||
-rwxr-xr-x | gpsprof | 5 | ||||
-rwxr-xr-x | jsongen.py | 5 | ||||
-rwxr-xr-x | leapsecond.py | 5 | ||||
-rwxr-xr-x | maskaudit.py | 5 | ||||
-rwxr-xr-x | test_maidenhead.py | 2 | ||||
-rwxr-xr-x | valgrind-audit.py | 4 | ||||
-rwxr-xr-x | xgps | 5 | ||||
-rwxr-xr-x | xgpsspeed | 5 |
15 files changed, 35 insertions, 23 deletions
@@ -20,8 +20,9 @@ # Modified by Chen Wei <weichen302@aol.com> for use with gpsd # Cleaned up and adapted for the GPSD project by Eric S. Raymond. -# This code runs under both Python 2 and Python 3. Preserve this property! -from __future__ import print_function, division +# This code runs compatibly under Python 2 and 3.x for x >= 2. +# Preserve this property! +from __future__ import absolute_import, print_function, division import sys, os, getopt import gps diff --git a/gps/__init__.py b/gps/__init__.py index 4292098e..553d30ea 100644 --- a/gps/__init__.py +++ b/gps/__init__.py @@ -2,7 +2,9 @@ # # This file is Copyright (c) 2010 by the GPSD project # BSD terms apply: see the file COPYING in the distribution root for details. - +# +# This code runs compatibly under Python 2 and 3.x for x >= 2. +# Preserve this property! from __future__ import absolute_import # Ensure Python2 behaves like Python 3 api_major_version = 5 # bumped on incompatible changes diff --git a/gps/client.py b/gps/client.py index 70f0b347..88d8054f 100644 --- a/gps/client.py +++ b/gps/client.py @@ -1,7 +1,7 @@ # This file is Copyright (c) 2010 by the GPSD project # BSD terms apply: see the file COPYING in the distribution root for details. # -# This code run compatibly under Python 2 and 3.x for x >= 3. +# This code run compatibly under Python 2 and 3.x for x >= 2. # Preserve this property! from __future__ import absolute_import, print_function, division @@ -15,7 +15,7 @@ # now live in a different module. # -# This code run compatibly under Python 2 and 3.x for x >= 3. +# This code runs compatibly under Python 2 and 3.x for x >= 2. # Preserve this property! from __future__ import absolute_import, print_function, division @@ -4,8 +4,9 @@ gpscap - GPS/AIS capability dictionary class. This file is Copyright (c) 2010 by the GPSD project BSD terms apply: see the file COPYING in the distribution root for details. """ -# This code runs under both Python 2 and Python 3. Preserve this property! -from __future__ import print_function +# This code runs compatibly under Python 2 and 3.x for x >= 2. +# Preserve this property! +from __future__ import absolute_import, print_function, division try: import configparser @@ -8,7 +8,7 @@ # This code runs compatibly under Python 2 and 3.x for x >= 2. # Preserve this property! -from __future__ import print_function, division +from __future__ import absolute_import, print_function, division import os, sys, termios, socket, select, getopt, curses.ascii import gps.packet as sniffer @@ -11,7 +11,7 @@ # This code runs compatibly under Python 2 and 3.x for x >= 2. # Preserve this property! -from __future__ import print_function, division +from __future__ import absolute_import, print_function, division import getopt import gps @@ -6,8 +6,9 @@ # Collect and plot latency-profiling data from a running gpsd. # Requires gnuplot. # -# This code runs under both Python 2 and Python 3. Preserve this property! -from __future__ import print_function, division +# This code runs compatibly under Python 2 and 3.x for x >= 2. +# Preserve this property! +from __future__ import absolute_import, print_function, division import copy import getopt @@ -8,8 +8,9 @@ # This code generates template declarations for AIS-JSON parsing from a # declarative specification of a JSON structure. # -# This code runs under both Python 2 and Python 3. Preserve this property! -from __future__ import print_function +# This code runs compatibly under Python 2 and 3.x for x >= 2. +# Preserve this property! +from __future__ import absolute_import, print_function, division import sys, getopt diff --git a/leapsecond.py b/leapsecond.py index e43f353d..2f0ce8fb 100755 --- a/leapsecond.py +++ b/leapsecond.py @@ -43,8 +43,9 @@ This file is Copyright (c) 2013 by the GPSD project BSD terms apply: see the file COPYING in the distribution root for details. """ -# This code runs under both Python 2 and Python 3. Preserve this property! -from __future__ import print_function, division +# This code runs compatibly under Python 2 and 3.x for x >= 2. +# Preserve this property! +from __future__ import absolute_import, print_function, division import os, re, random, time, calendar, math, sys, signal diff --git a/maskaudit.py b/maskaudit.py index cfa07785..20bc5d0a 100755 --- a/maskaudit.py +++ b/maskaudit.py @@ -9,8 +9,9 @@ # # With -t, tabulate usage of defines to find unused ones. Requires -c or -d. -# This code runs under both Python 2 and Python 3. Preserve this property! -from __future__ import print_function +# This code runs compatibly under Python 2 and 3.x for x >= 2. +# Preserve this property! +from __future__ import absolute_import, print_function, division import getopt import glob diff --git a/test_maidenhead.py b/test_maidenhead.py index 13b64475..707a05fb 100755 --- a/test_maidenhead.py +++ b/test_maidenhead.py @@ -9,7 +9,7 @@ # This code runs compatibly under Python 2 and 3.x for x >= 2. # Preserve this property! -from __future__ import print_function +from __future__ import absolute_import, print_function, division import sys, gps.clienthelpers diff --git a/valgrind-audit.py b/valgrind-audit.py index caa56c0a..c674ef7f 100755 --- a/valgrind-audit.py +++ b/valgrind-audit.py @@ -7,7 +7,9 @@ # This file is Copyright (c) 2010 by the GPSD project # BSD terms apply: see the file COPYING in the distribution root for details. # -from __future__ import print_function +# This code runs compatibly under Python 2 and 3.x for x >= 2. +# Preserve this property! +from __future__ import absolute_import, print_function, division import sys, gps.fake @@ -6,8 +6,9 @@ xgps -- test client for gpsd usage: xgps [-D level] [-hV?] [-l degmfmt] [-u units] [server[:port[:device]]] ''' -# This code runs under both Python 2 and Python 3. Preserve this property! -from __future__ import print_function, division +# This code runs compatibly under Python 2 and 3.x for x >= 2. +# Preserve this property! +from __future__ import absolute_import, print_function, division gui_about = '''\ This is xgps, a test client for the gpsd daemon. @@ -7,8 +7,9 @@ # # BSD terms apply: see the file COPYING in the distribution root for details. -# This code runs under both Python 2 and Python 3. Preserve this property! -from __future__ import division +# This code runs compatibly under Python 2 and 3.x for x >= 2. +# Preserve this property! +from __future__ import absolute_import, print_function, division import gi gi.require_version('Gtk', '3.0') |