diff --git a/MANIFEST.in b/MANIFEST.in index 1cf24c9..69815ee 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include README.md include CHANGES.md +include requirements*.txt recursive-include yawlib/data *.json recursive-include yawlib/glosswordnet/script *.sql diff --git a/README.md b/README.md index f13a8f6..a55ac6a 100644 --- a/README.md +++ b/README.md @@ -98,9 +98,17 @@ Note: Extract the glosstag folder and sqlite-30.db to ~/wordnet. The directory s Go to yawlib folder, execute the config script and then run wntk.sh to generate the glosstab DB file. ``` -cd ~/workspace git clone https://github.com/letuananh/yawlib cd yawlib -bash config.sh -./wntk.sh -c + +# create virtual environment +python3 -m venv yawlib_py3 +. yawlib_py3/bin/activate + +# install required packages +pip install -r requirements.txt +pip install -r requirements-optional.txt + +# to show information +python -m yawlib info ``` diff --git a/logging.json b/logging.json index e4d2e5e..7168985 100644 --- a/logging.json +++ b/logging.json @@ -43,6 +43,10 @@ "handlers": ["file_handler_important", "file_handler_verbose"], "propagate": "no" }, + "chirptext": { + "level": "WARNING", + "handlers": ["file_handler_verbose"] + }, "puchikarui.puchikarui": { "level": "WARNING", "handlers": ["file_handler_verbose"] diff --git a/release.sh b/release.sh index f52303c..fd8b8e5 100755 --- a/release.sh +++ b/release.sh @@ -1,4 +1,4 @@ #!/bin/bash -pandoc --from=markdown --to=rst README.md -o README.rst +# pandoc --from=markdown --to=rst README.md -o README.rst python3 setup.py sdist diff --git a/requirements-optional.txt b/requirements-optional.txt index 7e10602..7426a56 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -1 +1,2 @@ -flask +flask >= 1.0 +django >= 2.0 diff --git a/requirements.txt b/requirements.txt index 8c49faf..e122ace 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ lxml fuzzywuzzy python-levenshtein -chirptext>=0.1a16 +chirptext>=0.1a18 puchikarui>=0.1a1 diff --git a/setup.py b/setup.py index 3a70b7e..5cb12f1 100755 --- a/setup.py +++ b/setup.py @@ -48,12 +48,18 @@ def read(*filenames, **kwargs): return sep.join(buf) -readme_file = 'README.rst' if os.path.isfile('README.rst') else 'README.md' +# readme_file = 'README.rst' if os.path.isfile('README.rst') else 'README.md' +readme_file = 'README.md' long_description = read(readme_file) pkg_info = {} exec(read('yawlib/__version__.py'), pkg_info) +with open('requirements.txt', 'r') as infile: + requirements = infile.read().splitlines() + print(requirements) + + setup( name='yawlib', # package file name (-version.tar.gz) version=pkg_info['__version__'], @@ -65,11 +71,12 @@ def read(*filenames, **kwargs): keywords="princeton wordnet glosstag omw", license=pkg_info['__license__'], author=pkg_info['__author__'], - tests_require=['lxml', 'fuzzywuzzy', 'python-levenshtein', 'chirptext>=0.1a16', 'puchikarui'], - install_requires=['lxml', 'fuzzywuzzy', 'python-levenshtein', 'chirptext>=0.1a16', 'puchikarui'], + tests_require=requirements, + install_requires=requirements, author_email=pkg_info['__email__'], description=pkg_info['__description__'], long_description=long_description, + long_description_content_type='text/markdown', packages=['yawlib', 'yawlib.glosswordnet', 'yawlib.yawol', diff --git a/yawlib/__init__.py b/yawlib/__init__.py index 1e0e8e4..d3d1bb5 100644 --- a/yawlib/__init__.py +++ b/yawlib/__init__.py @@ -10,6 +10,7 @@ :license: MIT, see LICENSE for more details. ''' +from . import __version__ as version_info from .__version__ import __author__, __email__, __copyright__, __maintainer__ from .__version__ import __credits__, __license__, __description__, __url__ from .__version__ import __version_major__, __version_long__, __version__, __status__ diff --git a/yawlib/__version__.py b/yawlib/__version__.py index baa4ef3..c5acf54 100644 --- a/yawlib/__version__.py +++ b/yawlib/__version__.py @@ -10,6 +10,6 @@ __url__ = "https://github.com/letuananh/yawlib" __maintainer__ = "Le Tuan Anh" __version_major__ = "0.1" -__version__ = "{}a1".format(__version_major__) +__version__ = "{}a2".format(__version_major__) __version_long__ = "{} - Alpha".format(__version_major__) __status__ = "Prototype" diff --git a/yawlib/config.py b/yawlib/config.py index 3257312..2346b03 100644 --- a/yawlib/config.py +++ b/yawlib/config.py @@ -89,6 +89,11 @@ def home_dir(): return yhome if yhome else __yawlib_home +def config_file_path(): + ''' get config location ''' + return _get_config_manager().locate_config() + + def get_file(file_key): _config = read_config() return _config.get(file_key).format(YAWLIB_HOME=home_dir()) diff --git a/yawlib/helpers.py b/yawlib/helpers.py index c8dbbfc..3f25fd3 100644 --- a/yawlib/helpers.py +++ b/yawlib/helpers.py @@ -50,6 +50,8 @@ from .models import SynsetID, SynsetCollection from yawlib import YLConfig +from yawlib import config +from yawlib import version_info from yawlib.glosswordnet.gwnmodels import GlossedSynset from yawlib import GWordnetXML as GWNXML from yawlib import GWordnetSQLite as GWNSQL @@ -325,12 +327,19 @@ def add_wordnet_config(parser): def show_info(cli, args): ''' Show configuration information ''' - print("GlossWordNet XML folder: %s" % args.gloss_xml) - print("GlossWordNet SQlite DB : %s" % args.glossdb) - print("Princeton WordnetSQL DB: %s" % args.wnsql) - print("OMW DB : %s" % args.omw) - print("Use mockup data : %s" % args.mockup) + report = TextReport(args.output) if 'output' in args else TextReport() + report.header("{} - Version: {}".format(version_info.__description__, version_info.__version__), level='h0') + report.header("Basic Configuration") + report.print("YAWLIB_HOME : {}".format(config.home_dir())) + report.print("Configuration file: {}".format(config.config_file_path())) + report.header("Data files") + report.print("GlossWordNet XML folder: %s" % args.gloss_xml) + report.print("GlossWordNet SQlite DB : %s" % args.glossdb) + report.print("Princeton WordnetSQL DB: %s" % args.wnsql) + report.print("OMW DB : %s" % args.omw) + report.header("Other settings") + report.print("Use mockup data : %s" % args.mockup) if args.verbose: - print("--verbose : %s" % args.verbose) + report.print("--verbose : %s" % args.verbose) if args.quiet: - print("--quiet : %s" % args.quiet) + report.print("--quiet : %s" % args.quiet) diff --git a/yawlib/wntk.py b/yawlib/wntk.py index 8ebaa00..8dcdf4c 100755 --- a/yawlib/wntk.py +++ b/yawlib/wntk.py @@ -188,6 +188,7 @@ def main(): # show info task = app.add_task('info', func=show_info) + task.add_argument('-o', '--output', help='Write information to a text file') # run app app.run()