gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-dev] [PATCH 4/4] Makes "future imports" and Python version comment


From: Fred Wright
Subject: [gpsd-dev] [PATCH 4/4] Makes "future imports" and Python version comments consistent.
Date: Sat, 9 Apr 2016 19:57:16 -0700

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.
---
 gegps              | 5 +++--
 gps/__init__.py    | 4 +++-
 gps/client.py      | 2 +-
 gps/gps.py         | 2 +-
 gpscap.py          | 5 +++--
 gpscat             | 2 +-
 gpsfake            | 2 +-
 gpsprof            | 5 +++--
 jsongen.py         | 5 +++--
 leapsecond.py      | 5 +++--
 maskaudit.py       | 5 +++--
 test_maidenhead.py | 2 +-
 valgrind-audit.py  | 4 +++-
 xgps               | 5 +++--
 xgpsspeed          | 5 +++--
 15 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/gegps b/gegps
index 8ded4c9..2378cfc 100755
--- a/gegps
+++ b/gegps
@@ -20,8 +20,9 @@
 # Modified by Chen Wei <address@hidden> 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 4292098..553d30e 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 70f0b34..88d8054 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
 
diff --git a/gps/gps.py b/gps/gps.py
index 35a3707..bc66f7c 100755
--- a/gps/gps.py
+++ b/gps/gps.py
@@ -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
 
diff --git a/gpscap.py b/gpscap.py
index 32a854e..84e8e98 100644
--- a/gpscap.py
+++ b/gpscap.py
@@ -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
diff --git a/gpscat b/gpscat
index 53c3378..0d8505e 100755
--- a/gpscat
+++ b/gpscat
@@ -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
diff --git a/gpsfake b/gpsfake
index f687438..9a3f6f3 100755
--- a/gpsfake
+++ b/gpsfake
@@ -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
diff --git a/gpsprof b/gpsprof
index 6ed691e..5c9c52d 100755
--- a/gpsprof
+++ b/gpsprof
@@ -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
diff --git a/jsongen.py b/jsongen.py
index f42b401..db1f27f 100755
--- a/jsongen.py
+++ b/jsongen.py
@@ -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 e43f353..2f0ce8f 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 cfa0778..20bc5d0 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 13b6447..707a05f 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 caa56c0..c674ef7 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
 
diff --git a/xgps b/xgps
index f9b986e..2646e5f 100755
--- a/xgps
+++ b/xgps
@@ -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.
diff --git a/xgpsspeed b/xgpsspeed
index bba8ec4..30954b2 100755
--- a/xgpsspeed
+++ b/xgpsspeed
@@ -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')
-- 
2.8.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]