[Git][NTPsec/ntpsec][master] 2 commits: Restore Yoda expressions from "python library revision"

Matt Selsky gitlab at mg.gitlab.com
Tue Aug 14 16:54:24 UTC 2018


Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
eb7019a8 by James Browning at 2018-08-14T16:50:06Z
Restore Yoda expressions from "python library revision"

- - - - -
208d8965 by James Browning at 2018-08-14T16:50:06Z
variable name change

- - - - -


2 changed files:

- pylib/statfiles.py
- pylib/util.py


Changes:

=====================================
pylib/statfiles.py
=====================================
@@ -65,9 +65,9 @@ class NTPStats:
         assuming values are already split and sorted"""
         ret = {}
         length = len(values)
-        if length <= 1:
+        if 1 >= length:
             # uh, oh...
-            if length == 1:
+            if 1 == length:
                 # just one data value, set all to that one value
                 value = values[0]
             else:
@@ -125,7 +125,7 @@ class NTPStats:
         self.endtime = endtime
 
         self.sitename = sitename or os.path.basename(statsdir)
-        if self.sitename == 'ntpstats':
+        if 'ntpstats' == self.sitename:
             # boring, use hostname
             self.sitename = socket.getfqdn()
 
@@ -173,7 +173,7 @@ class NTPStats:
             # temps and gpsd are already in UNIX time
             for line in lines:
                 split = line.split()
-                if len(split) < 3:
+                if 3 > len(split):
                     # skip short lines
                     continue
 
@@ -254,8 +254,8 @@ def iso_to_posix(time_string):
     return calendar.timegm(time_struct)
 
 
-def posix_to_iso(utc_time):
+def posix_to_iso(unix_time):
     "ISO 8601 string in UTC from Unix time."
-    return time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(utc_time))
+    return time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(unix_time))
 
 # end


=====================================
pylib/util.py
=====================================
@@ -51,7 +51,7 @@ unitgroups = (UNITS_SEC, UNITS_PPX)
 # for everything else, and they are simple.
 
 def check_unicode():  # pragma: no cover
-    if sys.stdout.encoding != "UTf-8":
+    if "UTF-8" != sys.stdout.encoding:
         deunicode_units()
         return True  # needed by ntpmon
     return False



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/36ec5bfb3d2e0180567246784f557bf1f2e9a7ae...208d89656662dcbb499e7de1e411c525ef1d2ce0

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/36ec5bfb3d2e0180567246784f557bf1f2e9a7ae...208d89656662dcbb499e7de1e411c525ef1d2ce0
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20180814/78d9674b/attachment-0001.html>


More information about the vc mailing list