diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..7e4ef140ed14ffcd4929cef6673908575f6455f5 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,38 @@ +image: clarinpl/python:3.6 + +cache: + paths: + - .tox + +stages: + - check_style + - build + +before_script: + - pip install tox==2.9.1 + +pep8: + stage: check_style + script: + - tox -v -e pep8 + +docstyle: + stage: check_style + script: + - tox -v -e docstyle + +build_image: + stage: build + image: docker:18.09.7 + only: + - master + services: + - docker:18.09.7-dind + before_script: + - '' + script: + - docker build -t clarinpl/polem . + - echo $DOCKER_PASSWORD > pass.txt + - cat pass.txt | docker login --username $DOCKER_USERNAME --password-stdin + - rm pass.txt + - docker push clarinpl/polem diff --git a/polem_lemmatizer.py b/polem_lemmatizer.py index b32ea8271fbdbe5948838e3bea43e3c35a2d4ddc..ce0495f950f726e03cf161d4b8349ba0856e9c7a 100644 --- a/polem_lemmatizer.py +++ b/polem_lemmatizer.py @@ -1,35 +1,25 @@ +"""Implementation of polem service.""" import WrapLem import lex_ws class Polem(lex_ws.LexWorker): - @classmethod - def static_init(cls, config): - pass - - @classmethod - def static_close(cls): - pass + """Implements lex_worker for polem service. It's a mock object.""" def init(self): + """Initializes lemmatizer.""" self._lemmatizer = WrapLem.CascadeLemmatizer.assembleLemmatizer() - def processold(self, task_options): + def process(self, task_options): + """Runs single polem task.""" output = [] for lexeme in task_options['lexeme_polem']: - output.append(self._lemmatizer.lemmatizeS(lexeme[0], lexeme[1], lexeme[2], False)) - return output - - def process(self, task_options): - output = [] - for lexeme in task_options['lexeme_polem']: - if len(lexeme) == 3: - output.append(self._lemmatizer.lemmatizeS(lexeme[0], lexeme[1], lexeme[2], False)) - elif len(lexeme) == 5: - output.append(self._lemmatizer.lemmatizeS(lexeme[0], lexeme[1], lexeme[2], lexeme[3], lexeme[4], False)) + if len(lexeme) == 3 or len(lexeme) == 5: + output.append(self._lemmatizer.lemmatizeS(*lexeme, False)) else: - raise Exception("Invalid number of arguments") - return output + raise Exception("Invalid number of arguments") + return output + if __name__ == '__main__': lex_ws.LexService.main(Polem) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..10d7a73ed472853447f3d4e9ef0679fb399e177d --- /dev/null +++ b/tox.ini @@ -0,0 +1,44 @@ +[tox] +envlist = pep8,docstyle +skipsdist = True + +[testenv:pep8] +deps = + flake8 +basepython = python3 +commands = + flake8 {posargs} + +[testenv:docstyle] +deps = + pydocstyle +basepython = python3 +commands = + pydocstyle --verbose {posargs} + +[flake8] +# W504 skipped because it is overeager and unnecessary +ignore = W504 +show-source = True +exclude = .git,.venv,.tox,dist,doc,*egg,build,venv +import-order-style = pep8 +max-line-length = 80 + + +[pydocstyle] +# D104 Missing docstring in public package +# D203 1 blank line required before class docstring +# D213 Multi-line docstring summary should start at the second line +# D214 Section is over-indented +# D215 Section underline is over-indented +# D401 First line should be in imperative mood; try rephrasing +# D405 Section name should be properly capitalized +# D406 Section name should end with a newline +# D407 Missing dashed underline after section +# D408 Section underline should be in the line following the section’s name +# D409 Section underline should match the length of its name +# D410 Missing blank line after section +# D411 Missing blank line before section +ignore = D104,D203,D213,D214,D215,D401,D405,D406,D407,D408,D409,D410,D411 +match-dir = ^(?!\.tox|venv).* +match = ^(?!setup).*\.py