Failed Conditions
Pull Request — master (#1099)
by Mischa
02:17
created

coalib.results.SourcePosition.column()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 3
rs 10
1
from coalib.misc.Decorators import (enforce_signature,
2
                                    generate_ordering,
3
                                    generate_repr)
4
from coalib.results.TextPosition import TextPosition
5
6
7
@generate_repr("file", "line", "column")
8
@generate_ordering("file", "line", "column")
9
class SourcePosition(TextPosition):
10
    @enforce_signature
11
    def __init__(self, file: str, line=None, column=None):
12
        """
13
        Creates a new result position object that represents the position of a
14
        result in the source code.
15
16
        :param file:        The filename or None.
17
        :param line:        The line in file or None, the first line is 1.
18
        :param column:      The column indicating the character. The first one
19
                            in a line is 1.
20
        :raises TypeError:  Raised when line or columns are no integers.
21
        :raises ValueError: If a line number without a file is provided.
22
        """
23
        TextPosition.__init__(self, line, column)
24
25
        if file is None and line is not None:
26
            raise ValueError("A line must be associated to a file.")
27
28
        self._file = file
29
30
    @property
31
    def file(self):
32
        return self._file
33