Passed
Branch master (0442a2)
by P.R.
02:00
created

SDoc2Interpreter.process()   A

Complexity

Conditions 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
rs 9.4285
cc 1
1
"""
2
SDoc
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
# ----------------------------------------------------------------------------------------------------------------------
9
import antlr4
0 ignored issues
show
Configuration introduced by
The import antlr4 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...
10
11
import sdoc
12
from sdoc.antlr.sdoc2Lexer import sdoc2Lexer
13
from sdoc.antlr.sdoc2Parser import sdoc2Parser
14
from sdoc.sdoc2.SDoc2Visitor import SDoc2Visitor
15
16
17
class SDoc2Interpreter:
18
    """
19
    Class for processing SDoc1 documents.
20
    """
21
22
    # ------------------------------------------------------------------------------------------------------------------
23
    def __init__(self):
24
        """
25
        Object constructor.
26
        """
27
        pass
28
29
    # ------------------------------------------------------------------------------------------------------------------
30
    def process(self, infile):
0 ignored issues
show
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
31
        """
32
        Processes a SDoc1 document.
33
34
        :param str infile: The input filename with the SDoc2 document.
35
        """
36
        in_stream = antlr4.FileStream(infile, 'utf-8')
37
38
        lexer = sdoc2Lexer(in_stream)
39
        tokens = antlr4.CommonTokenStream(lexer)
40
        parser = sdoc2Parser(tokens)
41
        tree = parser.sdoc()
42
        visitor = SDoc2Visitor()
43
44
        visitor.visit(tree)
0 ignored issues
show
Bug introduced by
The Instance of SDoc2Visitor does not seem to have a member named visit.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
45
46
        sdoc.sdoc2.node_store.prepare_content_tree()
47
48
        return visitor.errors
49
50
# ----------------------------------------------------------------------------------------------------------------------
51