py/gadict_util.py
author Oleksandr Gavenko <gavenkoa@gmail.com>
Fri, 21 Aug 2020 14:16:03 +0300
changeset 1226 c525aca6d8f8
parent 1148 263e9e066981
permissions -rw-r--r--
Added build target 'deploy-www'.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1148
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     1
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
class ParseException(BaseException):
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     4
    def __init__(self, msg, lineno=None, line=None):
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     5
        BaseException.__init__(self)
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     6
        self.msg = msg
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     7
        self.lineno = lineno
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     8
        self.line = line
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     9
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    10
    def __repr__(self):
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    11
        if self.lineno is None:
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    12
            return self.msg
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    13
        elif self.line is None:
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    14
            return u":{:d}:{:s}".format(self.lineno, self.msg)
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    15
        else:
263e9e066981 Fixed: NameError: name 'ParseException' is not defined.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    16
            return u":{:d}: {:s}\nLINE: {:s}".format(self.lineno, self.msg, self.line)