Skip to content

Unable to determine if target exists #843

Closed
@centromere

Description

@centromere
>>> from pyroute2 import NDB
>>> n = NDB()
>>> list(n.sources)
['localhost', 'localhost/nsmanager']
>>> 'localhost' in n.sources
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nix/store/6znbgb3w3r7hnld4gydqs75mib9qsm59-python3.9-pyroute2-ndb-0.6.4/lib/python3.9/site-packages/pr2modules/ndb/main.py", line 659, in __contains__
    return key in self.dump()
  File "/nix/store/6znbgb3w3r7hnld4gydqs75mib9qsm59-python3.9-pyroute2-ndb-0.6.4/lib/python3.9/site-packages/pr2modules/ndb/auth_manager.py", line 69, in guard
    return f(obj, *argv, **kwarg)
  File "/nix/store/6znbgb3w3r7hnld4gydqs75mib9qsm59-python3.9-pyroute2-ndb-0.6.4/lib/python3.9/site-packages/pr2modules/ndb/main.py", line 699, in dump
    return RecordSet(self._native(iclass.dump(self)))
TypeError: 'NoneType' object is not callable
>>> n.sources.exists('localhost')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nix/store/6znbgb3w3r7hnld4gydqs75mib9qsm59-python3.9-pyroute2-ndb-0.6.4/lib/python3.9/site-packages/pr2modules/ndb/main.py", line 617, in exists
    key = iclass.new_spec(key, self.default_target).load_context(context).get_spec
AttributeError: type object 'Source' has no attribute 'new_spec'
>>>

As a workaround I can do 'localhost' in list(n.sources).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions