From d1aaf3344a9825b525f770855d54a7a092e7acf1 Mon Sep 17 00:00:00 2001 From: janmax <j.michal@stud.uni-goettingen.de> Date: Sun, 4 Feb 2018 02:16:11 +0100 Subject: [PATCH] Made it a PyPi ready package --- .gitignore | 3 ++- bin/hektor | 9 +++++++++ hektor.py | 13 +++++++++---- setup.py | 16 ++++++++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 bin/hektor create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 70309cf..10c4073 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.json *.zip *.swp -__pychache__/ +__pycache__/ +*.egg-info/ diff --git a/bin/hektor b/bin/hektor new file mode 100644 index 0000000..8d68445 --- /dev/null +++ b/bin/hektor @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 + +import hektor +import sys + +if __name__ == '__main__': + if sys.version_info < (3, 4): + sys.exit("At least Python 3.4 is required.") + hektor.main() diff --git a/hektor.py b/hektor.py index 63d8a29..209b1f2 100644 --- a/hektor.py +++ b/hektor.py @@ -16,7 +16,8 @@ tasks_path = ('./assessment/section') users = './tst_active/row' solutions = './tst_solutions/row[@question_fi="%s"]' -lecturer_xpath = './MetaData/Lifecycle/Contribute[@Role="Author"]/Entity/text()' +lecturer_xpath = ('./MetaData/Lifecycle/Contribute' + '[@Role="Author"]/Entity/text()') def eat_qti(tree, only_of_type=('assSourceCode',), **kwargs): @@ -132,8 +133,8 @@ def eat_zipfile(input_file, output): structured_data = give_me_structure(data) - with open(output, 'w', encoding='utf-8') as out: - json.dump(structured_data, out, indent=2) + with open(output, 'w') as out: + json.dump(structured_data, out, indent=2, sort_keys=True) def parseme(): @@ -151,6 +152,10 @@ def parseme(): return parser.parse_args() -if __name__ == '__main__': +def main(): args = parseme() eat_zipfile(args.input, args.output) + + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..60009f2 --- /dev/null +++ b/setup.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from setuptools import setup + +setup( + name='hektor', + version='0.1', + description='A QTI-XML to JSON converter for humans', + author='Jan Maximilian Michal', + author_email='mail@janmax.org', + url='https://gitlab.gwdg.de/j.michal/hektor', + license='MIT', + scripts=['bin/hektor'], + install_requires=['lxml'], + py_modules=['hektor'] +) -- GitLab