diff options
author | Gary E. Miller <gem@rellim.com> | 2018-06-20 10:43:22 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2018-06-20 10:43:22 -0700 |
commit | 5e6edbe782b6ccd89557b4014b722366111f7031 (patch) | |
tree | e3d58ecead4397d7e075e5f0ee765d5a94dc4ccc /leapsecond.py | |
parent | ab4804c0355f9e98d7d40b4aa9c1b7136af98134 (diff) | |
download | gpsd-5e6edbe782b6ccd89557b4014b722366111f7031.tar.gz |
leapsecond.py: Fix for PEP8.
Diffstat (limited to 'leapsecond.py')
-rwxr-xr-x | leapsecond.py | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/leapsecond.py b/leapsecond.py index 3047bba7..3ab10e07 100755 --- a/leapsecond.py +++ b/leapsecond.py @@ -97,8 +97,10 @@ else: # Otherwise we do something real def isotime(s): - "Convert timestamps in ISO8661 format to and from Unix time including " \ - "optional fractional seconds." + """Convert timestamps in ISO8661 format to and from Unix time including + optional fractional seconds. + """ + if isinstance(s, int): return time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(s)) elif isinstance(s, float): @@ -189,11 +191,11 @@ def last_insertion_time(): tm_hour = tm_min = tm_sec = 0 tm_mon = 1 jan_t = (tm_year, tm_mon, tm_mday, tm_hour, tm_min, - tm_sec, tm_wday, tm_yday, tm_isdst) + tm_sec, tm_wday, tm_yday, tm_isdst) jan = int(calendar.timegm(jan_t)) tm_mon = 7 jul_t = (tm_year, tm_mon, tm_mday, tm_hour, tm_min, - tm_sec, tm_wday, tm_yday, tm_isdst) + tm_sec, tm_wday, tm_yday, tm_isdst) jul = int(calendar.timegm(jul_t)) # We have the UTC times of the potential insertion points this year. now = time.time() @@ -204,8 +206,10 @@ def last_insertion_time(): def save_leapseconds(outfile): - "Fetch the leap-second history data and make a leap-second list since " \ - "Unix epoch GMT (1970-01-01T00:00:00)." + """Fetch the leap-second history data and make a leap-second list since + Unix epoch GMT (1970-01-01T00:00:00). + """ + random.shuffle(__locations) # To spread the load for (_, _, _, _, url) in __locations: skip = True @@ -246,8 +250,10 @@ def fetch_leapsecs(filename): def make_leapsecond_include(infile): - "Get the current leap second count and century from the local cache " \ - "usable as C preprocessor #define" + """Get the current leap second count and century from the local cache + usable as C preprocessor #define + """ + # Underscore prefixes avoids warning W0612 from pylint, # which doesn't count substitution through locals() as use. leapjumps = fetch_leapsecs(infile) @@ -274,8 +280,10 @@ def make_leapsecond_include(infile): def conditional_leapsecond_fetch(outfile, timeout): - "Conditionally fetch leapsecond data, " \ - "w. timeout in case of evil firewalls." + """Conditionally fetch leapsecond data, + w. timeout in case of evil firewalls. + """ + if not os.path.exists(outfile): stale = True else: |