On 19.01.2016 16:34, Christian Heimes wrote:
On 2016-01-19 13:43, Martin Basti wrote:
+
+def fake_class(name_or_class_obj, members=[]):
Please use a non-mutable argument here. members=() will do the job just
fine.
Fixed.
+ if isinstance(name_or_class_obj, scoped_nodes.Class):
+ cl = name_or_class_obj
+ else:
+ cl = scoped_nodes.Class(name_or_class_obj, None)
+
+ for m in members:
+ if isinstance(m, str):
+ if m in cl.locals:
+ _warning_already_exists(cl, m)
+ else:
+ cl.locals[m] = [scoped_nodes.Class(m, None)]
+ elif isinstance(m, dict):
+ for key, val in m.items():
+ assert isinstance(key, str), "key must be string"
+ if key in cl.locals:
+ _warning_already_exists(cl, key)
+ fake_class(cl.locals[key], val)
+ else:
+ cl.locals[key] = [fake_class(key, val)]
+ else:
+ # here can be used any astroid type
+ if m.name in cl.locals:
+ _warning_already_exists(cl, m.name)
+ else:
+ cl.locals[m.name] = [copy.copy(m)]
+ return cl
...
+ipa_class_members = {
+ # Python standard library & 3rd party classes
+ 'socket._socketobject': ['sendall'],
+# !!! 'datetime.tzinfo': ['houroffset', 'minoffset', 'utcoffset', 'dst'],
+# !!! 'nss.nss.subject_public_key_info': ['public_key'],
+
+ # IPA classes
+ 'ipalib.base.NameSpace': [
+ 'add',
+ 'mod',
+ 'del',
+ 'show',
+ 'find'
+ ],
+ 'ipalib.cli.Collector': ['__options'],
+ 'ipalib.config.Env': [
+ {'__d': ['get']},
+ {'__done': ['add']},
+ 'xmlrpc_uri',
+ 'validate_api',
+ 'startup_traceback',
+ 'verbose'
+ ] + LOGGING_ATTRS,
The rules for __options, __d and __done may lead to false detection.
Class member and attribute names with leading double underscore are
mangled, so Collector.__options is turned into __Collector_options.
self.__options works because it's also mangled. But from other classes,
the attribute must be referred to as __Collector_options.
Christian
This doesn't work for pylint
'ipalib.config.Env': [
{'_Env__d': ['get']},
{'_Env__done': ['add']},
'xmlrpc_uri',
'validate_api',
'startup_traceback',
'verbose'
] + LOGGING_ATTRS,
************* Module ipalib.config
ipalib/config.py:240: [E1101(no-member), Env.__setitem__] Instance of
'Env' has no '__d' member)
ipalib/config.py:242: [E1101(no-member), Env.__setitem__] Instance of
'Env' has no '__d' member)
ipalib/config.py:263: [E1101(no-member), Env.__setitem__] Instance of
'Env' has no '__d' member)
ipalib/config.py:269: [E1101(no-member), Env.__getitem__] Instance of
'Env' has no '__d' member)
ipalib/config.py:292: [E1101(no-member), Env.__contains__] Instance of
'Env' has no '__d' member)
ipalib/config.py:298: [E1101(no-member), Env.__len__] Instance of 'Env'
has no '__d' member)
ipalib/config.py:304: [E1101(no-member), Env.__iter__] Instance of 'Env'
has no '__d' member)
ipalib/config.py:408: [E1101(no-member), Env.__doing] Instance of 'Env'
has no '__done' member)
ipalib/config.py:412: [E1101(no-member), Env.__doing] Instance of 'Env'
has no '__done' member)
ipalib/config.py:415: [E1101(no-member), Env.__do_if_not_done] Instance
of 'Env' has no '__done' member)
ipalib/config.py:419: [E1101(no-member), Env._isdone] Instance of 'Env'
has no '__done' member)
ipalib/config.py:534: [E1101(no-member), Env._finalize_core] Instance of
'Env' has no '__d' member)
--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code