isexternalobject()   B
last analyzed

Complexity

Conditions 6

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
c 1
b 0
f 0
dl 0
loc 14
rs 8
1
#!/usr/bin/env python
2
import inspect
3
from pkgname import pkgname
4
from public import public
5
6
7
@public
8
def isexternalobject(obj, module):
9
    if obj is None:
10
        return
11
    parent = inspect.getmodule(obj)
12
    if parent == module:
13
        return False
14
    if parent:
15
        return pkgname(module) != pkgname(parent)
16
    # not object (variable?)
17
    for _, _object in inspect.getmembers(module):
18
        if _object == obj:
19
            return False
20
    return None  # unknown
21