_Mock.__call__()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
"""This module handles loading of the libtcod cffi API.
2
"""
3
from __future__ import absolute_import as _
4
5
import sys as _sys
6
import os as _os
7
8
import platform as _platform
9
10
11
from tcod import __path__
12
13
if _sys.platform == 'win32':
14
    # add Windows dll's to PATH
15
    _bits, _linkage = _platform.architecture()
0 ignored issues
show
Coding Style Naming introduced by
The name _bits does not conform to the constant naming conventions ((([A-Z_][A-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...
Coding Style Naming introduced by
The name _linkage does not conform to the constant naming conventions ((([A-Z_][A-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...
16
    _os.environ['PATH'] = '%s;%s' % (
17
        _os.path.join(__path__[0], 'x86' if _bits == '32bit' else 'x64'),
18
        _os.environ['PATH'],
19
        )
20
21
def _import_library_functions(lib):
0 ignored issues
show
Comprehensibility Bug introduced by
lib is re-defining a name which is already available in the outer-scope (previously defined on line 87).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
22
    # imports libtcod namespace into thie module
23
    # does not override existing names
24
    g = globals()
0 ignored issues
show
Coding Style Naming introduced by
The name g does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

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...
25
    for name in dir(lib):
26
        if name[:5] == 'TCOD_':
27
            if name.isupper():
28
                g[name[5:]] = getattr(lib, name) # const names
29
        elif name.startswith('FOV'):
30
            g[name] = getattr(lib, name) # fov const names
31
        elif name[:6] == 'TCODK_': # key name
32
            g['KEY_' + name[6:]] = getattr(lib, name)
33
34
NOISE_DEFAULT_HURST = 0.5
35
NOISE_DEFAULT_LACUNARITY = 2.0
36
37
def FOV_PERMISSIVE(p) :
0 ignored issues
show
Coding Style introduced by
No space allowed before :
def FOV_PERMISSIVE(p) :
^
Loading history...
Coding Style Naming introduced by
The name FOV_PERMISSIVE does not conform to the function naming conventions ([a-z_][a-z0-9_]{2,30}$).

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...
Coding Style Naming introduced by
The name p does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

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...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
38
    return FOV_PERMISSIVE_0+p
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'FOV_PERMISSIVE_0'
Loading history...
39
40
def BKGND_ALPHA(a):
0 ignored issues
show
Coding Style Naming introduced by
The name BKGND_ALPHA does not conform to the function naming conventions ([a-z_][a-z0-9_]{2,30}$).

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...
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

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...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
41
    return BKGND_ALPH | (int(a * 255) << 8)
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'BKGND_ALPH'
Loading history...
42
43
def BKGND_ADDALPHA(a):
0 ignored issues
show
Coding Style Naming introduced by
The name BKGND_ADDALPHA does not conform to the function naming conventions ([a-z_][a-z0-9_]{2,30}$).

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...
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

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...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
44
    return BKGND_ADDA | (int(a * 255) << 8)
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'BKGND_ADDA'
Loading history...
45
46
class _Mock(object):
47
    """Mock object needed for ReadTheDocs."""
48
49
    TCOD_RENDERER_GLSL = 0
50
    TCOD_RENDERER_OPENGL = 1
51
    TCOD_RENDERER_SDL = 2
52
    TCOD_FONT_LAYOUT_ASCII_INCOL = 1
53
    TCOD_BKGND_SET = 1
54
    TCOD_BKGND_DEFAULT = 13
55
    TCOD_KEY_RELEASED = 2
56
    TCOD_NOISE_DEFAULT = 0
57
    TCOD_NOISE_SIMPLEX = 2
58
    TCOD_NOISE_WAVELET = 4
59
    FOV_RESTRICTIVE = 12
60
61
    TCOD_RNG_MT = 0
62
    TCOD_RNG_CMWC = 1
63
64
    CData = () # This gets passed to an isinstance call.
65
66
    @staticmethod
67
    def def_extern():
68
        """Pass def_extern call silently."""
69
        return lambda func:func
0 ignored issues
show
Coding Style introduced by
Exactly one space required after :
return lambda func:func
^
Loading history...
70
71
    def __getattr__(self, attr):
72
        """This object pretends to have everything."""
73
        return self
74
75
    def __call__(self, *args, **kargs):
76
        """Suppress any other calls"""
77
        return self
78
79
    def __str__(self):
80
        """Just have ? in case anything leaks as a parameter default."""
81
        return '?'
82
83
84
if _os.environ.get('READTHEDOCS'):
85
    # Mock the lib and ffi objects needed to compile docs for readthedocs.io
86
    # Allows an import without building the cffi module first.
87
    lib = ffi = _Mock()
0 ignored issues
show
Coding Style Naming introduced by
The name lib does not conform to the constant naming conventions ((([A-Z_][A-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...
Coding Style Naming introduced by
The name ffi does not conform to the constant naming conventions ((([A-Z_][A-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...
88
else:
89
    from tcod._libtcod import lib, ffi
0 ignored issues
show
Bug introduced by
The name _libtcod does not seem to exist in module tcod.
Loading history...
Configuration introduced by
The import tcod._libtcod could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
Unused Code introduced by
Unused ffi imported from tcod._libtcod
Loading history...
90
91
_import_library_functions(lib)
92