Giter Club home page Giter Club logo

Comments (4)

exhuma avatar exhuma commented on June 17, 2024

I vaguely remember that I had a problem with generators somewhere, but I don't remember if that was here.

Maybe it was an oversight on my end. An easy way would be to modify it to yield immediately and see how the tests behave 😉

from puresnmp.

remdragon avatar remdragon commented on June 17, 2024

I tested the following against my fork and all tests passed in both py2 and py3. I should move the code duplication into an embedded function, but this was just a quick test to see if it would even work.

--- C:/Users/royce3/AppData/Local/Temp/TortoiseGit/__init__-fd35dc5.000.py	Sun Feb 11 09:35:47 2018
+++ C:/cvs/puresnmp_remdragon/puresnmp/__init__.py	Sun Feb 11 09:31:39 2018
@@ -188,7 +188,15 @@
     LOG.debug('%d of %d OIDs need to be continued',
               len(unfinished_oids),
               len(oids))
-    output = group_varbinds(varbinds, requested_oids)
+    yielded = _set([])
+    for v in group_varbinds(varbinds, requested_oids).values():
+        #print ( '1: v={!r}'.format ( v ) )
+        for varbind in v:
+            containment = [varbind.oid in _ for _ in requested_oids]
+            if not any(containment) or varbind.oid in yielded:
+                continue
+            yielded.add(varbind.oid)
+            yield varbind
 
     # As long as we have unfinished OIDs, we need to continue the walk for
     # those.
@@ -208,19 +216,15 @@
         LOG.debug('%d of %d OIDs need to be continued',
                   len(unfinished_oids),
                   len(oids))
-        for k, v in group_varbinds(varbinds, next_fetches).items():
-            for ko, vo in output.items():
-                if k in ko:
-                    vo.extend(v)
-
-    yielded = _set([])
-    for v in output.values():
-        for varbind in v:
-            containment = [varbind.oid in _ for _ in requested_oids]
-            if not any(containment) or varbind.oid in yielded:
-                continue
-            yielded.add(varbind.oid)
-            yield varbind
+        for v in group_varbinds(varbinds, next_fetches).values():
+            #print ( '2: v={!r}'.format ( v ) )
+            for varbind in v:
+                containment = [varbind.oid in _ for _ in requested_oids]
+                #print ( '2a: v={!r}, containment={!r}'.format ( v, containment ) )
+                if not any(containment) or varbind.oid in yielded:
+                    continue
+                yielded.add(varbind.oid)
+                yield varbind
 
 
 def set(ip, community, oid, value, port=161, timeout=2):

from puresnmp.

exhuma avatar exhuma commented on June 17, 2024

Looks good to me.

from puresnmp.

exhuma avatar exhuma commented on June 17, 2024

If you like you could create a PR from this and I'll see to it that I'll get it merged. Just do a bit of cleanup first, like removing the commented print statements & checking that it's mostly PEP8 compliant.

from puresnmp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.