Total Complexity | 3 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | class Factory: |
||
2 | class __Factory: |
||
|
|||
3 | def __init__(self): |
||
4 | self._extend_registry = {} |
||
5 | self._class_registry = {} |
||
6 | |||
7 | def extend(self, object_name, extend_class, parent_class): |
||
8 | if object_name not in self._extend_registry: |
||
9 | self._extend_registry[object_name] = [] |
||
10 | try: |
||
11 | index_of_existent_extend = self._extend_registry[object_name].index(parent_class) |
||
12 | self._extend_registry[object_name][index_of_existent_extend] = extend_class |
||
13 | except ValueError: |
||
14 | self._extend_registry[object_name].append(extend_class) |
||
15 | # try: |
||
16 | # index = self._extend_registry[object_name].index(theclass.__bases__[0]) |
||
17 | # self._extend_registry[object_name][0] = theclass |
||
18 | # except ValueError: |
||
19 | # self._extend_registry[object_name].append(theclass) |
||
20 | |||
21 | def get_class(self, object_name): |
||
22 | if object_name not in self._class_registry: |
||
23 | # Construction d'une classe etendue a partir des sous classes existantes |
||
24 | # print self._extend_registry[object_name] |
||
25 | self._class_registry[object_name] = type('Final' + object_name, |
||
26 | tuple(self._extend_registry[object_name]), {}) |
||
27 | return self._class_registry[object_name] |
||
28 | |||
29 | instance = None |
||
30 | |||
31 | def __init__(self): |
||
32 | if not Factory.instance: |
||
33 | Factory.instance = Factory.__Factory() |
||
34 | |||
35 | def __getattr__(self, name): |
||
36 | return getattr(self.instance, name) |
This check looks for invalid names for a range of different identifiers.
You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.
If your project includes a Pylint configuration file, the settings contained in that file take precedence.
To find out more about Pylint, please refer to their site.