Failed Conditions
Pull Request — master (#1099)
by Mischa
01:56
created

coalib.results.TextPosition   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %
Metric Value
dl 0
loc 28
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A column() 0 3 1
A line() 0 3 1
A __init__() 0 17 3
1
from coalib.misc.Decorators import (enforce_signature,
2
                                    generate_ordering,
3
                                    generate_repr)
4
5
6
@generate_repr("line", "column")
7
@generate_ordering("line", "column")
8
class TextPosition:
9
    @enforce_signature
10
    def __init__(self, line: (int, None)=None, column: (int, None)=None):
11
        """
12
        Creates a new TextPosition object that represents the position inside
13
        a string with line/column numbers.
14
15
        :param line:        The line in file or None, the first line is 1.
16
        :param column:      The column indicating the character. The first one
17
                            in a line is 1.
18
        :raises TypeError:  Raised when line or columns are no integers.
19
        :raises ValueError: Raised when a column is set but line is None.
20
        """
21
        if line is None and column is not None:
22
            raise ValueError("A column can only be set if a line is set.")
23
24
        self._line = line
25
        self._column = column
26
27
    @property
28
    def line(self):
29
        return self._line
30
31
    @property
32
    def column(self):
33
        return self._column
34