[Git][NTPsec/ntpsec][master] 'six' module not available everywhere. Replaced with custom code.

Ian Bruene gitlab at mg.gitlab.com
Mon Mar 19 14:40:42 UTC 2018


Ian Bruene pushed to branch master at NTPsec / ntpsec


Commits:
2a302721 by Ian Bruene at 2018-03-19T14:38:13Z
'six' module not available everywhere. Replaced with custom code.

- - - - -


1 changed file:

- pylib/agentx.py


Changes:

=====================================
pylib/agentx.py
=====================================
--- a/pylib/agentx.py
+++ b/pylib/agentx.py
@@ -6,7 +6,6 @@ from __future__ import print_function, division
 import select
 import time
 import sys
-import six
 
 try:
     import ntp.util
@@ -23,6 +22,13 @@ defaultTimeout = 30
 pingTime = 60
 
 
+def gen_next(generator):
+    if str is bytes:  # Python 2
+        return generator.next()
+    else:  # Python 3
+        return next(generator)
+
+
 class MIBControl:
     def __init__(self, oidTree=None, mibRoot=(), rangeSubid=0, upperBound=None,
                  mibContext=None):
@@ -79,7 +85,7 @@ class MIBControl:
         gen = walkMIBTree(self.oidTree, self.mibRoot)
         while True:
             try:
-                oid, reader, writer = six.next(gen)
+                oid, reader, writer = gen_next(gen)
                 if nextP is True:  # GetNext
                     # For getnext any OID greater than the start qualifies
                     oidhit = (oid > searchoid)
@@ -115,7 +121,7 @@ class MIBControl:
         # Find the first OID
         while True:
             try:
-                oid, reader, writer = six.next(gen)
+                oid, reader, writer = gen_next(gen)
                 if reader is None:
                     continue  # skip unimplemented OIDs
                 elif oid.subids == oidrange.start.subids:
@@ -141,7 +147,7 @@ class MIBControl:
         # Start filling in the rest of the range
         while True:
             try:
-                oid, reader, writer = six.next(gen)
+                oid, reader, writer = gen_next(gen)
                 if reader is None:
                     continue  # skip unimplemented OIDs
                 elif (oidrange.end.isNull() is False) and \



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

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/2a302721f7353c5c79dbcfb28a6c7ad6237e1b56
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/20180319/f6aef44d/attachment.html>


More information about the vc mailing list