From 5e096c6aa69ef072b9bb049b7def429465b4651e Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Sun, 13 Nov 2016 18:54:11 +0300 Subject: [PATCH] reorga files --- MANIFEST.in | 2 + generate_bilan/__main__.py | 56 ------------------ notes_tools/__init__.py | 7 +-- .../generate_bilan}/__init__.py | 0 notes_tools/generate_bilan/__main__.py | 59 +++++++++++++++++++ .../generate_bilan}/generate_bilan.py | 4 +- .../generate_bilan}/templates/tpl_bilan.tex | 0 .../generate_bilan}/texenv.py | 2 +- notes_tools/tools/__init__.py | 13 ++++ notes_tools/{ => tools}/df_marks_manip.py | 0 notes_tools/{ => tools}/extract.py | 0 .../{ => tools}/test/test_df_marks_manip.py | 2 +- notes_tools/{ => tools}/test/test_extract.py | 4 +- pytest.ini | 2 + setup.py | 32 ++++++++++ 15 files changed, 116 insertions(+), 67 deletions(-) create mode 100644 MANIFEST.in delete mode 100644 generate_bilan/__main__.py rename {generate_bilan => notes_tools/generate_bilan}/__init__.py (100%) create mode 100644 notes_tools/generate_bilan/__main__.py rename {generate_bilan => notes_tools/generate_bilan}/generate_bilan.py (96%) rename {generate_bilan => notes_tools/generate_bilan}/templates/tpl_bilan.tex (100%) rename {generate_bilan => notes_tools/generate_bilan}/texenv.py (93%) create mode 100644 notes_tools/tools/__init__.py rename notes_tools/{ => tools}/df_marks_manip.py (100%) rename notes_tools/{ => tools}/extract.py (100%) rename notes_tools/{ => tools}/test/test_df_marks_manip.py (97%) rename notes_tools/{ => tools}/test/test_extract.py (97%) create mode 100644 pytest.ini create mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..8f6b12d --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include samples *.xlsx +recursive-include generate_bilan *.tex diff --git a/generate_bilan/__main__.py b/generate_bilan/__main__.py deleted file mode 100644 index b57fb39..0000000 --- a/generate_bilan/__main__.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python -# encoding: utf-8 - -from generate_bilan import generate_bilan -import optparse -import os -from path import Path - -# Defaults settings -this_dir, this_filename = os.path.split(__file__) -default_template = "tpl_bilan.tex" - - -parser = optparse.OptionParser() -parser.add_option("-c", - "--classe", - action="store", - type="string", - dest="classe", - help="The classe") -parser.add_option("-e", - "--evaluation", - action="store", - type="string", - dest="ds_name", - help="The evaluation name.") -parser.add_option("-p", - "--path", - action="store", - type="string", - dest="path", - default=Path("./"), - help="Path where xlsx are stored") -parser.add_option("-t", - "--template", - action="store", - type="string", - dest="template", - default=default_template, - help="The template file") -(options, args) = parser.parse_args() - -if not options.classe: - raise ValueError("Need to pass a class with -c. See -h for help") -if not options.ds_name: - raise ValueError("Need to pass a evaluation name with -e. See -h for help") - -generate_bilan(options.classe, - options.ds_name, - options.path, - options.template) - -# ----------------------------- -# Reglages pour 'vim' -# vim:set autoindent expandtab tabstop=4 shiftwidth=4: -# cursor: 16 del diff --git a/notes_tools/__init__.py b/notes_tools/__init__.py index c6975c2..ab2f3a6 100644 --- a/notes_tools/__init__.py +++ b/notes_tools/__init__.py @@ -1,11 +1,8 @@ #!/usr/bin/env python # encoding: utf-8 - -from notes_tools.extract import extract_flat_marks, get_class_ws -from notes_tools.df_marks_manip import digest_flat_df, students_pov - - +from .generate_bilan import generate_bilan +from .tools import extract_flat_marks, get_class_ws, digest_flat_df, students_pov # ----------------------------- # Reglages pour 'vim' diff --git a/generate_bilan/__init__.py b/notes_tools/generate_bilan/__init__.py similarity index 100% rename from generate_bilan/__init__.py rename to notes_tools/generate_bilan/__init__.py diff --git a/notes_tools/generate_bilan/__main__.py b/notes_tools/generate_bilan/__main__.py new file mode 100644 index 0000000..814e967 --- /dev/null +++ b/notes_tools/generate_bilan/__main__.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# encoding: utf-8 + +from .generate_bilan import generate_bilan +import optparse +import os +from path import Path + +# Defaults settings +default_template = "tpl_bilan.tex" + + +def main(): + parser = optparse.OptionParser() + parser.add_option("-c", + "--classe", + action="store", + type="string", + dest="classe", + help="The classe") + parser.add_option("-e", + "--evaluation", + action="store", + type="string", + dest="ds_name", + help="The evaluation name.") + parser.add_option("-p", + "--path", + action="store", + type="string", + dest="path", + default=Path("./"), + help="Path where xlsx are stored") + parser.add_option("-t", + "--template", + action="store", + type="string", + dest="template", + default=default_template, + help="The template file") + (options, args) = parser.parse_args() + + if not options.classe: + raise ValueError("Need to pass a class with -c. See -h for help") + if not options.ds_name: + raise ValueError("Need to pass a evaluation name with -e. See -h for help") + + generate_bilan(options.classe, + options.ds_name, + options.path, + options.template) + +if __name__ == "__main__": + main() + +# ----------------------------- +# Reglages pour 'vim' +# vim:set autoindent expandtab tabstop=4 shiftwidth=4: +# cursor: 16 del diff --git a/generate_bilan/generate_bilan.py b/notes_tools/generate_bilan/generate_bilan.py similarity index 96% rename from generate_bilan/generate_bilan.py rename to notes_tools/generate_bilan/generate_bilan.py index 2b8af59..b62bd16 100755 --- a/generate_bilan/generate_bilan.py +++ b/notes_tools/generate_bilan/generate_bilan.py @@ -1,8 +1,8 @@ #!/usr/bin/env python # encoding: utf-8 -from notes_tools import extract_flat_marks, get_class_ws, digest_flat_df, students_pov -from generate_bilan.texenv import texenv +from notes_tools.tools import extract_flat_marks, get_class_ws, digest_flat_df, students_pov +from .texenv import texenv import pandas as pd import numpy as np import xlrd diff --git a/generate_bilan/templates/tpl_bilan.tex b/notes_tools/generate_bilan/templates/tpl_bilan.tex similarity index 100% rename from generate_bilan/templates/tpl_bilan.tex rename to notes_tools/generate_bilan/templates/tpl_bilan.tex diff --git a/generate_bilan/texenv.py b/notes_tools/generate_bilan/texenv.py similarity index 93% rename from generate_bilan/texenv.py rename to notes_tools/generate_bilan/texenv.py index 536bec2..c85dca5 100644 --- a/generate_bilan/texenv.py +++ b/notes_tools/generate_bilan/texenv.py @@ -12,7 +12,7 @@ texenv = jinja2.Environment( block_end_string = '}', variable_start_string = '\Var{', variable_end_string = '}', - loader = jinja2.PackageLoader("generate_bilan", "templates"), + loader = jinja2.PackageLoader("notes_tools.generate_bilan", "templates"), extensions = ['jinja2.ext.do'] ) diff --git a/notes_tools/tools/__init__.py b/notes_tools/tools/__init__.py new file mode 100644 index 0000000..f8e5df5 --- /dev/null +++ b/notes_tools/tools/__init__.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +# encoding: utf-8 + + +from .extract import extract_flat_marks, get_class_ws +from .df_marks_manip import digest_flat_df, students_pov + + + +# ----------------------------- +# Reglages pour 'vim' +# vim:set autoindent expandtab tabstop=4 shiftwidth=4: +# cursor: 16 del diff --git a/notes_tools/df_marks_manip.py b/notes_tools/tools/df_marks_manip.py similarity index 100% rename from notes_tools/df_marks_manip.py rename to notes_tools/tools/df_marks_manip.py diff --git a/notes_tools/extract.py b/notes_tools/tools/extract.py similarity index 100% rename from notes_tools/extract.py rename to notes_tools/tools/extract.py diff --git a/notes_tools/test/test_df_marks_manip.py b/notes_tools/tools/test/test_df_marks_manip.py similarity index 97% rename from notes_tools/test/test_df_marks_manip.py rename to notes_tools/tools/test/test_df_marks_manip.py index 2b9058e..fa78634 100644 --- a/notes_tools/test/test_df_marks_manip.py +++ b/notes_tools/tools/test/test_df_marks_manip.py @@ -2,7 +2,7 @@ # encoding: utf-8 -from notes_tools import df_marks_manip +from notes_tools.tools import df_marks_manip import pandas diff --git a/notes_tools/test/test_extract.py b/notes_tools/tools/test/test_extract.py similarity index 97% rename from notes_tools/test/test_extract.py rename to notes_tools/tools/test/test_extract.py index c2271c6..f488ca8 100644 --- a/notes_tools/test/test_extract.py +++ b/notes_tools/tools/test/test_extract.py @@ -2,8 +2,8 @@ # encoding: utf-8 -from notes_tools import extract -import pandas +from notes_tools.tools import extract +import pandas import pytest diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..df3eb51 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = --doctest-modules diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..6ca8486 --- /dev/null +++ b/setup.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# encoding: utf-8 + +from setuptools import setup, find_packages + +#import generate_bilan +#import notes_tools + +setup(name="notes_analysis", + version = "0.1", + description = "Outils d'analyse de notes", + author = "Benjamin Bertrand", + include_package_data=True, + packages=find_packages(), + install_requires=['jinja2', + 'pandas', + 'xlrd', + 'path.py', + ], + entry_points = { + "console_scripts": ['generate_bilan = generate_bilan.generate_bilan:main'] + }, + zip_safe=False + ) + + + +# ----------------------------- +# Reglages pour 'vim' +# vim:set autoindent expandtab tabstop=4 shiftwidth=4: +# cursor: 16 del +