Completed
Push — master ( 57e7bf...8a74a7 )
by P.R.
01:36
created

sdoc.sdoc2.SDoc2Interpreter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %
Metric Value
dl 0
loc 29
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A SDoc2Interpreter.__init__() 0 5 1
A SDoc2Interpreter.process() 0 17 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
    def __init__(self):
23
        """
24
        Object constructor.
25
        """
26
        pass
27
28
    # ------------------------------------------------------------------------------------------------------------------
29
    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...
30
        """
31
        Processes a SDoc1 document.
32
33
        :param str infile: The input filename with the SDoc2 document.
34
        """
35
        in_stream = antlr4.FileStream(infile, 'utf-8')
36
37
        lexer = sdoc2Lexer(in_stream)
38
        tokens = antlr4.CommonTokenStream(lexer)
39
        parser = sdoc2Parser(tokens)
40
        tree = parser.sdoc()
41
        visitor = SDoc2Visitor()
42
43
        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...
44
45
        sdoc.sdoc2.node_store.prepare_content_tree()
46
47
48
# ----------------------------------------------------------------------------------------------------------------------
49