Test Failed
Push — master ( db4166...efa4d0 )
by Thomas
11:36
created

exabgp.environment.hashtable   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A HashTable.__setattr__() 0 2 1
A HashTable.__getattr__() 0 2 1
A GlobalHashTable.__new__() 0 4 2
A HashTable.__setitem__() 0 2 1
A HashTable.__getitem__() 0 2 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A _() 0 2 1
1
# encoding: utf-8
2
"""
3
hashtable.py
4
5
Created by Thomas Mangin on 2009-09-06.
6
Copyright (c) 2009-2017 Exa Networks. All rights reserved.
7
License: 3-clause BSD. (See the COPYRIGHT file)
8
"""
9
10
11
def _(key):
12
    return key.replace('_', '-')
13
14
15
class HashTable(dict):
16
    def __getitem__(self, key):
17
        return dict.__getitem__(self, _(key))
18
19
    def __setitem__(self, key, value):
20
        return dict.__setitem__(self, _(key), value)
21
22
    def __getattr__(self, key):
23
        return dict.__getitem__(self, _(key))
24
25
    def __setattr__(self, key, value):
26
        return dict.__setitem__(self, _(key), value)
27
28
29
class GlobalHashTable(HashTable):
30
    _instance = None
31
32
    def __new__(cls):
33
        if cls._instance is None:
34
            cls._instance = super(GlobalHashTable, cls).__new__(cls)
35
        return cls._instance
36