mirror of https://github.com/patacrep/patacrep.git
Luthaf
10 years ago
33 changed files with 466 additions and 422 deletions
@ -0,0 +1,9 @@ |
|||||
|
git: |
||||
|
depth: 1 |
||||
|
language: python |
||||
|
python: |
||||
|
- 3.4 |
||||
|
install: |
||||
|
- pip install tox |
||||
|
script: |
||||
|
- tox |
@ -1,4 +1,4 @@ |
|||||
|
ply |
||||
Jinja2==2.7.3 |
Jinja2==2.7.3 |
||||
argparse==1.2.1 |
|
||||
chardet==2.2.1 |
chardet==2.2.1 |
||||
unidecode>=0.04.16 |
unidecode>=0.04.16 |
||||
|
@ -0,0 +1,33 @@ |
|||||
|
"""Generic parsing classes and methods""" |
||||
|
|
||||
|
import logging |
||||
|
|
||||
|
LOGGER = logging.getLogger() |
||||
|
|
||||
|
class Parser: |
||||
|
"""Parser class""" |
||||
|
# pylint: disable=too-few-public-methods |
||||
|
|
||||
|
def __init__(self): |
||||
|
self.filename = "" # Will be overloaded |
||||
|
|
||||
|
@staticmethod |
||||
|
def __find_column(token): |
||||
|
"""Return the column of ``token``.""" |
||||
|
last_cr = token.lexer.lexdata.rfind('\n', 0, token.lexpos) |
||||
|
if last_cr < 0: |
||||
|
last_cr = 0 |
||||
|
column = (token.lexpos - last_cr) + 1 |
||||
|
return column |
||||
|
|
||||
|
def p_error(self, token): |
||||
|
"""Manage parsing errors.""" |
||||
|
if token: |
||||
|
LOGGER.error( |
||||
|
"Error in file {}, line {}:{}.".format( |
||||
|
str(self.filename), |
||||
|
token.lineno, |
||||
|
self.__find_column(token), |
||||
|
) |
||||
|
) |
||||
|
|
@ -0,0 +1,5 @@ |
|||||
|
[VARIABLES] |
||||
|
dummy-variables-rgx=_|dummy |
||||
|
|
||||
|
[MESSAGES CONTROL] |
||||
|
disable= logging-format-interpolation |
@ -0,0 +1,15 @@ |
|||||
|
# To perform those tests, install `tox` and run "tox" from this directory. |
||||
|
|
||||
|
[tox] |
||||
|
# Uncomment to use more python versions |
||||
|
#envlist = py26, py27, py32, py34, lint |
||||
|
envlist = py34, lint |
||||
|
|
||||
|
[testenv] |
||||
|
commands = {envpython} setup.py test |
||||
|
deps = |
||||
|
|
||||
|
[testenv:lint] |
||||
|
basepython=python3.4 |
||||
|
deps=pylint |
||||
|
commands=pylint patacrep --rcfile=pylintrc |
Loading…
Reference in new issue