__Factory.__init__()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
dl 0
loc 3
rs 10
1
class Factory:
2
    class __Factory:
0 ignored issues
show
Coding Style Naming introduced by
The name __Factory does not conform to the class naming conventions ([A-Z_][a-zA-Z0-9]+$).

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.

Loading history...
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)