File: compat.py

package info (click to toggle)
pylint-django 0.7.2-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 204 kB
  • sloc: python: 787; makefile: 7
file content (39 lines) | stat: -rw-r--r-- 976 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

try:
    from astroid.nodes import ClassDef, FunctionDef, ImportFrom, AssignName, Attribute
except ImportError:
    from astroid.nodes import Class as ClassDef, \
        Function as FunctionDef, \
        From as ImportFrom, \
        AssName as AssignName, \
        Getattr as Attribute

try:
    from astroid.bases import YES as Uninferable
except ImportError:
    try:
        from astroid.util import YES as Uninferable
    except ImportError:
        from astroid.util import Uninferable


try:
    django = __import__('django')
    django_version = django.VERSION
except ImportError:
    # if not available, will be handled by the django_installed checker
    django_version = (1, 5)


def inferred(node):
    if hasattr(node, 'inferred'):
        return node.inferred
    else:
        return node.infered


def instantiate_class(node):
    if hasattr(node, 'instantiate_class'):
        return node.instantiate_class
    else:
        return node.instanciate_class