Skip to content

Commit

Permalink
Merge 0891573 into 13c407d
Browse files Browse the repository at this point in the history
  • Loading branch information
sushain97 committed Mar 25, 2018
2 parents 13c407d + 0891573 commit 8e9de45
Show file tree
Hide file tree
Showing 43 changed files with 3,014 additions and 3,659 deletions.
4 changes: 2 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
max-line-length = 180
exclude = toro.py, streamparser
max-line-length = 140
ignore = C815, C816
111 changes: 107 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,109 @@
/t/apertium-apy.err
/t/apertium-apy.log
/__pycache__/
/tests/apertium-apy.err
/tests/apertium-apy.log
/langNames.db
/cache/
/.mypy_cache/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

40 changes: 19 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
language: python

# let linux be Ubuntu 14.04 Trusty
cache: pip
sudo: required
dist: trusty

python:
- "3.4"
- "3.5"
- "3.6"
- "nightly"

- '3.4'
- '3.5'
- '3.6'
- 'nightly'
install:
- pip3 install tornado mypy
- pip3 install flake8

- travis_retry pip install -r requirements-dev.txt
before_script:
- wget http://apertium.projectjj.com/apt/install-nightly.sh -O - | sudo bash
- sudo apt-get -f --allow-unauthenticated install apertium-all-dev
- sudo apt-get -f --allow-unauthenticated install apertium-sme-nob apertium-es-en
- svn co https://svn.code.sf.net/p/apertium/svn/languages/apertium-nno /tmp/languages/apertium-nno
- git clone --depth 1 https://github.com/apertium/apertium-nno /tmp/languages/apertium-nno
- ( cd /tmp/languages/apertium-nno && ./autogen.sh && make -j2 )
- flake8
- mypy --config-file mypy.ini **/*.py

script:
- NONPAIRS=/tmp/languages t/run-tests


- flake8 **/*.py
- if [[ $TRAVIS_PYTHON_VERSION != 3.4 ]]; then
mypy --config-file mypy.ini **/*.py;
fi
- NONPAIRS=/tmp/languages coverage run --source apertium_apy -m unittest tests/test*.py
- coverage report --fail-under 20
after_success:
- coveralls
notifications:
irc:
channels:
- secure: "jMRqT7lndd2vTXON34HHdNQ6v+DSOSUQZwKXsJytw9F55pPPS4z+76vTChHKdNcp4nV5nWhCarZR2X4bK7qWO5i25XIXsffFm4TK/XWDdZgLKHCS431mzcSVrYYASC0nn15HgGAl/H6dMksNThuV5gaItSPcKNXC9amBYLbTeSt/H+rxDBuPs+m7yy049EySTWjUoFacel7HDoTEXQyl82Ks5I0oJM+ErgS1VAe6RPiXIH+eBGbPT0YoVYUS1WoKSZYaLhLZ/jOLDnnTiFhTn/f8+uZrbAfLGWzkp9/NbyMCByQFH48HFzjudOD6BgxRumJaDFhImrKrDvPpMulXB1MLl+JD9mK+lioLaqUiUu+2wkBJ90bvOCNqhKLR94upev7Skg52n96Wc91EfiVxuwiLDJOzwFAbZ9VaziNI/Ld3y1qHO84spV7R7AWFhI34xGNkAOCJ1sZZWcH2rGFjsldLNPHeyhNBaZhxGdGdVvrbTm0jbR4G0iD54BLK1IPuJt/eaETWrAnE2XgDnJ3PE9JKtFOe5tpuhF/R9s8qFYGEVmG9SnSxqJax7K6XcQ6utla10qFX0mR5Ub8S+Ryu9fN5+g+U2fCrfJrH44RhDCz961SGcRYVaWDITtDTeAtBGP6G0jOkNv8yi21ha50y4uDxvXq1ETfoHLeYwzzCHmU="
on_failure: always
on_success: never
- secure: 'jMRqT7lndd2vTXON34HHdNQ6v+DSOSUQZwKXsJytw9F55pPPS4z+76vTChHKdNcp4nV5nWhCarZR2X4bK7qWO5i25XIXsffFm4TK/XWDdZgLKHCS431mzcSVrYYASC0nn15HgGAl/H6dMksNThuV5gaItSPcKNXC9amBYLbTeSt/H+rxDBuPs+m7yy049EySTWjUoFacel7HDoTEXQyl82Ks5I0oJM+ErgS1VAe6RPiXIH+eBGbPT0YoVYUS1WoKSZYaLhLZ/jOLDnnTiFhTn/f8+uZrbAfLGWzkp9/NbyMCByQFH48HFzjudOD6BgxRumJaDFhImrKrDvPpMulXB1MLl+JD9mK+lioLaqUiUu+2wkBJ90bvOCNqhKLR94upev7Skg52n96Wc91EfiVxuwiLDJOzwFAbZ9VaziNI/Ld3y1qHO84spV7R7AWFhI34xGNkAOCJ1sZZWcH2rGFjsldLNPHeyhNBaZhxGdGdVvrbTm0jbR4G0iD54BLK1IPuJt/eaETWrAnE2XgDnJ3PE9JKtFOe5tpuhF/R9s8qFYGEVmG9SnSxqJax7K6XcQ6utla10qFX0mR5Ub8S+Ryu9fN5+g+U2fCrfJrH44RhDCz961SGcRYVaWDITtDTeAtBGP6G0jOkNv8yi21ha50y4uDxvXq1ETfoHLeYwzzCHmU='
on_failure: change
on_success: change

# The irc channel is encrypted for goavki/apertium-apy, so build notifications from forks won't show up on the IRC channel
# Encrypt with:
# $ gem install --user-install travis
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include COPYING
include langNames.db
include servlet.py
include tools/systemd/*
include tools/sysvinit/*
include tools/upstart/*
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
langNames.db: language-names/scraped.sql language-names/scraped-sil.sql language-names/manual.sql language-names/variants.sql
langNames.db: language_names/scraped.sql language_names/scraped-sil.sql language_names/manual.sql language_names/variants.sql
@if test -f unicode.db; then echo "WARNING: unicode.db now called langNames.db"; fi
rm -f $@
cat $^ | sqlite3 $@

release: langNames.db
python3 setup.py sdist bdist_wheel

publish: release
python3 setup.py upload --repository https://test.pypi.org/legacy/ --sign

test:
flake8 **/*.py
mypy --config-file mypy.ini **/*.py
coverage run --source apertium_apy -m unittest tests/test*.py
coverage report --fail-under 20

clean:
rm -f langNames.db
rm -rf langNames.db dist/ build/
133 changes: 131 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,132 @@
See http://wiki.apertium.org/wiki/Apertium-apy
Apertium APy
============

[![TravisCI](https://travis-ci.org/apertium/apertium-apy.svg)](https://travis-ci.org/apertium/apertium-apy)
[![Build Status](https://travis-ci.org/apertium/apertium-apy.svg)](https://travis-ci.org/apertium/apertium-apy)
[![Coverage Status](https://coveralls.io/repos/github/apertium/apertium-apy/badge.svg?branch=master)](https://coveralls.io/github/apertium/apertium-apy?branch=master)
[![PyPI](https://img.shields.io/pypi/v/apertium-apy.svg)](https://pypi.org/project/apertium-apy/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/apertium-apy.svg)]((https://pypi.org/project/apertium-apy/))

Apertium APy, **Apertium A**PI in **Py**thon, is a web server exposing Apertium
morphological functions including text, document and webpage translation. More
information is available on the [Apertium Wiki][1].

Requirements
------------

- Python 3.4+
- Tornado 4.3+ (`python3-tornado` on Debian)

Additional functionality is provided by installation
of the following packages:

- `apertium-stremparser` enables spell checking
- `requests` enables suggestion handling
- `cld2` enables improved language detection
- `chardet` enables website character encoding detection

Precise versions are available in `requirements.txt` and `setup.py`.

Installation
------------

Before you install, you can try out a live version of APy at [apertium.org][2].

APy is available through [PyPi](https://pypi.org/project/apertium-apy/):

$ pip install apertium-apy
$ apertium-apy --help

usage: apertium-apy [-h] [-s NONPAIRS_PATH] [-l LANG_NAMES] [-f MISSING_FREQS]
[-p PORT] [-c SSL_CERT] [-k SSL_KEY] [-t TIMEOUT]
[-j [NUM_PROCESSES]] [-d] [-P LOG_PATH]
[-i MAX_PIPES_PER_PAIR] [-n MIN_PIPES_PER_PAIR]
[-u MAX_USERS_PER_PIPE] [-m MAX_IDLE_SECS]
[-r RESTART_PIPE_AFTER] [-v VERBOSITY] [-V] [-S]
[-M UNKNOWN_MEMORY_LIMIT] [-T STAT_PERIOD_MAX_AGE]
[-wp WIKI_PASSWORD] [-wu WIKI_USERNAME] [-b]
[-rs RECAPTCHA_SECRET] [-md MAX_DOC_PIPES] [-C CONFIG]
pairs_path

Apertium APY -- API server for machine translation and language analysis

positional arguments:
pairs_path path to Apertium installed pairs (all modes files in
this path are included)

optional arguments:
-h, --help show this help message and exit
-s NONPAIRS_PATH, --nonpairs-path NONPAIRS_PATH
path to Apertium tree (only non-translator debug modes
are included from this path)
-l LANG_NAMES, --lang-names LANG_NAMES
path to localised language names sqlite database
(default = langNames.db)
-f MISSING_FREQS, --missing-freqs MISSING_FREQS
path to missing word frequency sqlite database
(default = None)
-p PORT, --port PORT port to run server on (default = 2737)
-c SSL_CERT, --ssl-cert SSL_CERT
path to SSL Certificate
-k SSL_KEY, --ssl-key SSL_KEY
path to SSL Key File
-t TIMEOUT, --timeout TIMEOUT
timeout for requests (default = 10)
-j [NUM_PROCESSES], --num-processes [NUM_PROCESSES]
number of processes to run (default = 1; use 0 to run
one http server per core, where each http server runs
all available language pairs)
-d, --daemon daemon mode: redirects stdout and stderr to files
apertium-apy.log and apertium-apy.err; use with --log-
path
-P LOG_PATH, --log-path LOG_PATH
path to log output files to in daemon mode; defaults
to local directory
-i MAX_PIPES_PER_PAIR, --max-pipes-per-pair MAX_PIPES_PER_PAIR
how many pipelines we can spin up per language pair
(default = 1)
-n MIN_PIPES_PER_PAIR, --min-pipes-per-pair MIN_PIPES_PER_PAIR
when shutting down pipelines, keep at least this many
open per language pair (default = 0)
-u MAX_USERS_PER_PIPE, --max-users-per-pipe MAX_USERS_PER_PIPE
how many concurrent requests per pipeline before we
consider spinning up a new one (default = 5)
-m MAX_IDLE_SECS, --max-idle-secs MAX_IDLE_SECS
if specified, shut down pipelines that have not been
used in this many seconds
-r RESTART_PIPE_AFTER, --restart-pipe-after RESTART_PIPE_AFTER
restart a pipeline if it has had this many requests
(default = 1000)
-v VERBOSITY, --verbosity VERBOSITY
logging verbosity
-V, --version show APY version
-S, --scalemt-logs generates ScaleMT-like logs; use with --log-path;
disables
-M UNKNOWN_MEMORY_LIMIT, --unknown-memory-limit UNKNOWN_MEMORY_LIMIT
keeps unknown words in memory until a limit is
reached; use with --missing-freqs (default = 1000)
-T STAT_PERIOD_MAX_AGE, --stat-period-max-age STAT_PERIOD_MAX_AGE
How many seconds back to keep track request timing
stats (default = 3600)
-wp WIKI_PASSWORD, --wiki-password WIKI_PASSWORD
Apertium Wiki account password for SuggestionHandler
-wu WIKI_USERNAME, --wiki-username WIKI_USERNAME
Apertium Wiki account username for SuggestionHandler
-b, --bypass-token ReCAPTCHA bypass token
-rs RECAPTCHA_SECRET, --recaptcha-secret RECAPTCHA_SECRET
ReCAPTCHA secret for suggestion validation
-md MAX_DOC_PIPES, --max-doc-pipes MAX_DOC_PIPES
how many concurrent document translation pipelines we
allow (default = 3)
-C CONFIG, --config CONFIG
Configuration file to load options from

Contributing
------------

APy using [TravisCI][3] to run tests. Locally, use `make test` to run the same
checks it does. Use `pip install -r requirements-dev.txt` to install the
requirements required for development, e.g. linters.

[1]: http://wiki.apertium.org/wiki/Apertium-apy
[2]: https://www.apertium.org/apy/listPairs
[3]: https://travis-ci.org/apertium/apertium-apy
Empty file added apertium_apy/__init__.py
Empty file.
Loading

0 comments on commit 8e9de45

Please sign in to comment.