[Git][NTPsec/ntpsec][master] PEP8: Use ''.startswith() and ''.endswith() instead of string slicing

Matt Selsky gitlab at mg.gitlab.com
Tue Feb 26 21:24:03 UTC 2019


Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
a91c94b1 by Matt Selsky at 2019-02-26T06:56:52Z
PEP8: Use ''.startswith() and ''.endswith() instead of string slicing

Use ''.startswith() and ''.endswith() instead of string slicing to check for
prefixes or suffixes to check for prefixes or suffixes.

- - - - -


2 changed files:

- ntpclients/ntpviz.py
- pylib/util.py


Changes:

=====================================
ntpclients/ntpviz.py
=====================================
@@ -987,7 +987,7 @@ plot \
             if "offset" == ptype:
                 # doing offset, not jitter
                 rtt = 1
-                if "127.127." == peerlist[0][:8]:
+                if peerlist[0].startswith("127.127."):
                     # don't do rtt for reclocks
                     rtt = 0
                     title = "Refclock Offset " + str(peerlist[0])
@@ -1023,7 +1023,7 @@ Time (rtt) is field 6 in the peerstats log file.</p>
 
             else:
                 # doing jitter, not offset
-                if "127.127." == peerlist[0][:8]:
+                if peerlist[0].startswith("127.127."):
                     title = "Refclock RMS Jitter " + str(peerlist[0])
                     exp = """\
 <p>The RMS Jitter of a local refclock.  Jitter is the


=====================================
pylib/util.py
=====================================
@@ -1138,7 +1138,7 @@ class PeerSummary:
         # slots setup via pool have only srcadr
         if srcadr is not None \
                 and srcadr != "0.0.0.0" \
-                and srcadr[:7] != "127.127" \
+                and not srcadr.startswith("127.127") \
                 and srcadr != "::":
             if self.showhostnames:
                 try:



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/a91c94b1171dd2500ef10e0830826ee31779b077

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/a91c94b1171dd2500ef10e0830826ee31779b077
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/20190226/852cb667/attachment-0001.html>


More information about the vc mailing list