diff --git a/.gitignore b/.gitignore index ce2bb99..50e2dad 100644 --- a/.gitignore +++ b/.gitignore @@ -74,7 +74,7 @@ odmltables/gui/graphics/*.dvi odmltables/gui/graphics/*.ps odmltables/gui/graphics/*.txt odmltables/gui/graphics/*.tex.backup -odmltables/gui/testfiles/* +src/odmltables/gui/testfiles/* doc/build/* doc/_build/* doc/requirements*.rst diff --git a/doc/conf.py b/doc/conf.py index e231947..afa1b71 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -13,10 +13,9 @@ # serve to show the default. import sys -import glob import subprocess import os - +import tomllib # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -24,7 +23,7 @@ #sys.path.insert(0, os.path.abspath('.')) sys.path.insert(0, os.path.abspath('../src')) sys.path.insert(0, os.path.abspath('../../python-odml/')) -sys.path.insert(0, os.path.abspath('../odmltables')) +sys.path.insert(0, os.path.abspath('../src/odmltables')) sys.path.insert(0, os.path.abspath('..')) # installing current odMLtables version @@ -33,25 +32,25 @@ output, error = process.communicate() import odmltables + VERSION = odmltables.VERSION # reformatting requirements files to be automatically included in docu -requirement_files = glob.glob('../requirements*.txt') -for requirement_file in requirement_files: - with open(requirement_file, 'r') as f: - lines = f.readlines() - # listify and increase readability - for line_id in range(len(lines)): - lines[line_id] = '* ' + lines[line_id] - lines[line_id] = lines[line_id].replace(';', ' in case of ') - new_filename = f'{os.path.splitext(os.path.basename(requirement_file))[0]}.rst' - with open(new_filename, 'w+') as f: - f.writelines(lines) - - +with open("../pyproject.toml", "rb") as f: + data = tomllib.load(f) +def format_dependencies(dependency_list): + # format a list of dependencies into a block text list + formatted_dependencies = '\n* '.join(dependency_list).replace(';', ' in case of ') + return formatted_dependencies +dependencies = data["project"]["dependencies"] +with open('requirements.rst', 'w+') as f: + f.write(format_dependencies(dependencies)) +for option, optional_dependencies in data["project"]["optional-dependencies"].items(): + with open(f'requirements_{option}.rst', 'w+') as f: + f.write(format_dependencies(optional_dependencies)) # -- General configuration ------------------------------------------------ diff --git a/doc/environment.yml b/doc/environment.yml index af1f85f..1513262 100644 --- a/doc/environment.yml +++ b/doc/environment.yml @@ -1,11 +1,14 @@ name: odmltables +channels: + - conda-forge + - free + - anaconda dependencies: -- python=3.7 -- setuptools -- snowballstemmer -- sphinx -- sphinx_rtd_theme -- pip -- pip: - - odml - - sphinx-rtd-theme + - python==3.11 + - setuptools + - snowballstemmer + - sphinx + - sphinx_rtd_theme + - pip + - pip: + - odml diff --git a/doc/tutorial.rst b/doc/tutorial.rst index 29836fe..90b7663 100644 --- a/doc/tutorial.rst +++ b/doc/tutorial.rst @@ -15,10 +15,11 @@ version `1.0 `_. -In addition to the detailed step-by-step instructions presented here, there are also two **interactive tutorials** available as `jupyter notebooks`_. Both tutorials can be directly executed using binder_ or run locally from the odmltables sources (:any:`tutorials/tutorial-1_scenarios/demo_scenarios.ipynb`) folder. The first notebook (|notebook1|) is giving a quick overview on how odMLtables can be used in a metadata workflow by presenting a number of small application scenarios. The second notebook (|notebook2|) shows the usage of odMLtables for handling large metadata collections and is based on two published experimental datasets. +In addition to the detailed step-by-step instructions presented here, there are also two **interactive tutorials** available as `jupyter notebooks`_. Both tutorials can be directly executed using binder_ or run locally from the odmltables `tutorial folder`_. The first notebook (|notebook1|) is giving a quick overview on how odMLtables can be used in a metadata workflow by presenting a number of small application scenarios. The second notebook (|notebook2|) shows the usage of odMLtables for handling large metadata collections and is based on two published experimental datasets. .. _binder: https://mybinder.org/ .. _jupyter notebooks: http://jupyter.org/ +.. _tutorial folder: https://github.com/INM-6/python-odmltables/tree/master/tutorials .. |notebook1| image:: https://mybinder.org/badge.svg :target: https://mybinder.org/v2/gh/inm-6/python-odmltables/master?filepath=tutorials%2Ftutorial-1_scenarios%2Fdemo_scenarios.ipynb diff --git a/examples/example1/example1-2.odml b/examples/example1/example1-2.odml index ed0ce4c..b5fdbce 100644 --- a/examples/example1/example1-2.odml +++ b/examples/example1/example1-2.odml @@ -1,58 +1,62 @@ - - + + ]> - 78c00ffd-881f-4e00-b999-4d6c22744884 +odML | The Open metaData Markup Language

odML metadata document

    (type: )

Section

Type:
Repository:
Repository:
Link:
Include:
Definition:

NameValueUnitTypeUncertaintyDefinitionDependencyDependency Value



top
+
+ + ecc070d0-91c1-4110-b22c-fe5bf992c395
- 0cdfdebe-7bd1-49e2-b2d6-9fb6be99d8e8 + 38d986da-6849-4818-b7aa-cd4ef5671fe5 Animal
- 241a1dba-83a3-4064-89d6-926939bd751e + 49dc25d5-d8be-4337-961b-f013c6c4e99f Surgery - 26afa401-5f09-424f-9608-aead03bf2c88 + 76786e2e-ca1d-44d2-82f6-f97b88cadbab Anaesthetic Type of anaesthetic string - 7c6cec3c-330a-4f03-a633-19722da9d512 + 064ff25a-ea6a-4731-8d9c-49bd5553929a Date Date of surgery conduction date - a8bac013-36ed-4331-b300-e150c3970522 + 4d7de105-09b5-46e3-9efb-2137d733d441 Link URL or folder containing surgery protocol url - 2ea17762-9713-4126-8bf8-36412c7fe3c0 + b6dc1272-711a-4833-b8fc-cfcb96546c97 Painkiller Name of painkiller, if used string - db15a30c-1cb9-4aa9-88af-3b3a132062b3 + fbe9e534-aff0-41a2-8b60-1006f92c2c77 Quality Quality of the surgery (good / ok / bad) string - 351d5f54-e144-47d9-bb1b-39411ad59bbd + c01d4b3e-6812-42fd-ab56-029787c63dda Surgeon Name of the surgeon string - f61542d8-23cd-49ee-9090-201f4a1bbc62 + 6e58030e-a625-49ae-9511-bda5f5e4621f Weight g @@ -61,42 +65,42 @@
- 44c2de81-1d99-49bc-84ef-53fc7c327d09 + dcd63471-0440-4c32-b675-6620bae2b032 AnimalID ID of the animal used for this experiment string - ca47031e-ce5e-45e2-ab6e-0a8c54f330a0 + b00e3fc0-b284-4383-98a3-ef4143466827 Birthdate - Birthdate of the animal + Birthdate of the animal date - 323e0428-ab68-4738-ba25-26c98feabd34 + c11544b9-9984-45b5-8ad5-8fb19a7d7057 Litter ID of the litter string - 82b37ab4-1b36-40bb-b725-06a33f3b4fd2 + 85cb2291-3e38-4202-a157-5a3cd9f1e961 Seizures Occurrence of seizures (observed / not observed) string - b5956ac0-6652-4370-9d69-3a98427c53a3 + 56986f70-e14a-4a42-afe2-030a93a1f087 Sex Sex of the animal string - 836c9e7d-9890-426d-8eea-76f50dd12d7c + 46c34c89-84b4-4fae-b1b2-ac1a4949aa11 Species Species of the animal diff --git a/examples/example1/example1.py b/examples/example1/example1.py index b25fc4f..00e4949 100644 --- a/examples/example1/example1.py +++ b/examples/example1/example1.py @@ -17,7 +17,7 @@ def run_example(): def setup_example(): # We are using the same csv table as used in the tutorial - filename = '../../doc/source/csv/example1-2.csv' + filename = 'example1-2.csv' xlstable = odml_xls_table.OdmlXlsTable() xlstable.load_from_csv_table(filename) diff --git a/examples/example2/example2.py b/examples/example2/example2.py index a930b4b..c122f1c 100644 --- a/examples/example2/example2.py +++ b/examples/example2/example2.py @@ -2,7 +2,6 @@ import datetime import odml.base import odmltables.odml_xls_table as odml_xls_table -from odmltables.xls_style import XlsStyle pre_enriched_file = 'example2-1.odml' diff --git a/examples/example3/example3.py b/examples/example3/example3.py index bbc292e..b36ec46 100644 --- a/examples/example3/example3.py +++ b/examples/example3/example3.py @@ -1,7 +1,6 @@ import datetime import odml -from odml import DType import odmltables.odml_xls_table as odml_xls_table diff --git a/odmltables/VERSION.txt b/odmltables/VERSION.txt deleted file mode 100644 index e29964d..0000000 --- a/odmltables/VERSION.txt +++ /dev/null @@ -1 +0,0 @@ -1.0.1dev diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5e000e3 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,78 @@ +[project] +name = "odmltables" +version = "1.0.1dev" +authors = [ + {name = "odMLtables authors and contributors"}, + {email = "julia.sprenger@rwth-aachen.de"} +] +description = "An interface to convert odML structues to and from table-like representations, such as spreadsheets" +readme = "README.rst" +requires-python = ">=3.6" +license = {text = "BSD 3-Clause License"} +keywords = ["odml", "excel", "metadata management"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python :: 3", + "Operating System :: OS Independent", + "Intended Audience :: Science/Research", + "Natural Language :: English", + "Topic :: Scientific/Engineering", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3 :: Only", +] + +dependencies = [ + "xlrd >= 0.9.4", + "xlwt >= 1.0.0", + "numpy >= 1.8.2", + "quantities >= 0.10.1", + "odml >= 1.4.2", + "future >= 0.16.0", + "argparse >= 1.0.0", +] + +[project.urls] +documentation = "http://odmltables.readthedocs.io/" +repository = "https://github.com/INM-6/python-odmltables" +download = "http://pypi.python.org/pypi/odmltables" + + +[build-system] +requires = ["setuptools>=62.0"] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.package-data] +odmltables = ["gui/graphics/*", "logo/*"] + +[tool.pytest.ini_options] +minversion = "7.0" +addopts = "-ra -q" +testpaths = [ + "tests", +] +pythonpath = [ + "src" +] + +[project.gui-scripts] +odmltables = "odmltables.gui.main:parse_args" + +[project.optional-dependencies] + +doc = [ + "numpydoc>=0.5.0", + "sphinx>=1.2.2", +] + +gui = ["PyQt5>=5.0.0"] + +test = ["pytest>=3.0.0"] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 55b5ebd..0000000 --- a/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -xlrd >= 0.9.4 -xlwt >= 1.0.0 -numpy >= 1.8.2 -quantities >= 0.10.1 -odml >= 1.4.2 -future >= 0.16.0 -argparse >= 1.0.0 -enum34 >= 0.4.6;python_version<"3.4" \ No newline at end of file diff --git a/requirements_doc.txt b/requirements_doc.txt deleted file mode 100644 index a812a3d..0000000 --- a/requirements_doc.txt +++ /dev/null @@ -1,2 +0,0 @@ -numpydoc>=0.5.0 -sphinx>=1.2.2 \ No newline at end of file diff --git a/requirements_gui.txt b/requirements_gui.txt deleted file mode 100644 index fdb6880..0000000 --- a/requirements_gui.txt +++ /dev/null @@ -1 +0,0 @@ -PyQt5>=5.0.0 \ No newline at end of file diff --git a/requirements_test.txt b/requirements_test.txt deleted file mode 100644 index 2e005dc..0000000 --- a/requirements_test.txt +++ /dev/null @@ -1 +0,0 @@ -pytest>=3.0.0 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 11e9ec4..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -description-file = README.rst \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index df0f085..0000000 --- a/setup.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import sys, os, glob -import warnings -from setuptools import setup, find_packages - -with open("README.rst") as f: - long_description = f.read() -with open('requirements.txt') as f: - install_requires = f.read().splitlines() -with open('requirements_doc.txt') as f: - doc_requires = f.read().splitlines() -with open('requirements_test.txt') as f: - test_requires = f.read().splitlines() -with open('requirements_gui.txt') as f: - gui_requires = f.read().splitlines() - -extras_require = {'doc': doc_requires, - 'test': test_requires, - 'gui': gui_requires - } - -# PyQt5 needs to be installed manually with python 2 when installing odmltables gui. -if sys.version_info.major < 3: - warnings.warn('The odMLtables gui requires PyQt5. Please install this dependency first before ' - 'installing the odmltables gui, eg. using "conda install -c anaconda ' - '\'pyqt>=5\'"') - -if sys.version_info.major < 3 or (sys.version_info.major == 3 and sys.version_info.minor < 6): - raise EnvironmentError('odMLtables requires Python version 3.6 or later.') - -VERSION = open('./odmltables/VERSION.txt', 'r').read().strip() - -setup( - name="odmltables", - version=VERSION, - packages=find_packages(), - package_data={'odmltables': ['gui/graphics/*', 'VERSION.txt']}, - install_requires=install_requires, - extras_require=extras_require, - - author="odMLtables authors and contributors", - author_email="j.sprenger@fz-juelich.de", - description="Interface to convert odML structures to and from table-like representations", - long_description=long_description, - license="BSD", - url='https://github.com/INM-6/python-odmltables', - download_url="https://github.com/INM-6/python-odmltables/archive/{}.tar.gz".format(VERSION), - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Topic :: Scientific/Engineering'], - entry_points={ - 'gui_scripts': ['odmltables = odmltables.gui.main:parse_args []']}, - zip_safe=False, - keywords=['odml', 'excel', 'metadata management'], - # Extension('foo', ['foo.c'], include_dirs=['.']), - data_files=[('share/pixmaps', glob.glob(os.path.join("logo", "*"))), - ('.', ['odmltables/VERSION.txt', - 'requirements.txt', - 'requirements_doc.txt', - 'requirements_gui.txt', - 'requirements_test.txt'])] -) \ No newline at end of file diff --git a/odmltables/gui/__init__.py b/src/__init__.py similarity index 100% rename from odmltables/gui/__init__.py rename to src/__init__.py diff --git a/odmltables/__init__.py b/src/odmltables/__init__.py similarity index 50% rename from odmltables/__init__.py rename to src/odmltables/__init__.py index 36c4634..c3f5195 100644 --- a/odmltables/__init__.py +++ b/src/odmltables/__init__.py @@ -1,8 +1,7 @@ -import os.path - -with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'VERSION.txt')) as version_file: - VERSION = version_file.read().strip() - +import importlib.metadata +# this need to be at the begining because some sub module will need the version +__version__ = importlib.metadata.version("odmltables") +VERSION = __version__ # -*- coding: utf-8 -*- """ @@ -15,9 +14,4 @@ .. autoclass:: odmltables.compare_section_csv_table.CompareSectionCsvTable """ - -from odmltables.odml_table import OdmlTable from odmltables.odml_csv_table import OdmlCsvTable -from odmltables.odml_xls_table import OdmlXlsTable -from odmltables.compare_section_csv_table import CompareSectionCsvTable -from odmltables.compare_section_xls_table import CompareSectionXlsTable diff --git a/odmltables/compare_section_csv_table.py b/src/odmltables/compare_section_csv_table.py similarity index 100% rename from odmltables/compare_section_csv_table.py rename to src/odmltables/compare_section_csv_table.py diff --git a/odmltables/compare_section_table.py b/src/odmltables/compare_section_table.py similarity index 100% rename from odmltables/compare_section_table.py rename to src/odmltables/compare_section_table.py diff --git a/odmltables/compare_section_xls_table.py b/src/odmltables/compare_section_xls_table.py similarity index 100% rename from odmltables/compare_section_xls_table.py rename to src/odmltables/compare_section_xls_table.py diff --git a/odmltables/create_examples.py b/src/odmltables/create_examples.py similarity index 100% rename from odmltables/create_examples.py rename to src/odmltables/create_examples.py diff --git a/odmltables/tests/__init__.py b/src/odmltables/gui/__init__.py similarity index 100% rename from odmltables/tests/__init__.py rename to src/odmltables/gui/__init__.py diff --git a/odmltables/gui/compsectionpages.py b/src/odmltables/gui/compsectionpages.py similarity index 98% rename from odmltables/gui/compsectionpages.py rename to src/odmltables/gui/compsectionpages.py index 75a0bcf..923803c 100644 --- a/odmltables/gui/compsectionpages.py +++ b/src/odmltables/gui/compsectionpages.py @@ -9,10 +9,9 @@ import subprocess from PyQt5.QtWidgets import (QVBoxLayout, QHBoxLayout, QMessageBox, - QLineEdit, QPushButton, QLabel, QGroupBox, - QGridLayout, QTreeWidget, QTreeWidgetItem, - QToolButton, QFileDialog, QCheckBox, QComboBox, - QFrame, QSizePolicy, QRadioButton) + QLineEdit, QPushButton, QLabel, QGroupBox, + QGridLayout, QTreeWidget, QTreeWidgetItem, + QToolButton, QFileDialog, QCheckBox, QRadioButton) from PyQt5.QtCore import Qt diff --git a/odmltables/gui/compsectionwiz.py b/src/odmltables/gui/compsectionwiz.py similarity index 100% rename from odmltables/gui/compsectionwiz.py rename to src/odmltables/gui/compsectionwiz.py diff --git a/odmltables/gui/converterpages.py b/src/odmltables/gui/converterpages.py similarity index 99% rename from odmltables/gui/converterpages.py rename to src/odmltables/gui/converterpages.py index 6af81bb..d97fd36 100644 --- a/odmltables/gui/converterpages.py +++ b/src/odmltables/gui/converterpages.py @@ -12,7 +12,7 @@ import PyQt5.QtGui as Qtg from .pageutils import QIWizardPage, clearLayout, get_property, get_rgb, shorten_path -from odmltables import odml_table, odml_xls_table, odml_csv_table, xls_style +from .. import odml_csv_table, odml_xls_table, xls_style, odml_table class LoadFilePage(QIWizardPage): diff --git a/odmltables/gui/converterwiz.py b/src/odmltables/gui/converterwiz.py similarity index 100% rename from odmltables/gui/converterwiz.py rename to src/odmltables/gui/converterwiz.py diff --git a/odmltables/gui/filterpages.py b/src/odmltables/gui/filterpages.py similarity index 99% rename from odmltables/gui/filterpages.py rename to src/odmltables/gui/filterpages.py index e2ee537..4b3d467 100644 --- a/odmltables/gui/filterpages.py +++ b/src/odmltables/gui/filterpages.py @@ -16,7 +16,7 @@ from PyQt5.QtCore import Qt import PyQt5.QtWidgets as Qtw -from odmltables import odml_table +from .. import odml_table from .pageutils import QIWizardPage, clearLayout, shorten_path diff --git a/odmltables/gui/filterwiz.py b/src/odmltables/gui/filterwiz.py similarity index 100% rename from odmltables/gui/filterwiz.py rename to src/odmltables/gui/filterwiz.py diff --git a/odmltables/gui/generatetemplatepages.py b/src/odmltables/gui/generatetemplatepages.py similarity index 99% rename from odmltables/gui/generatetemplatepages.py rename to src/odmltables/gui/generatetemplatepages.py index 5aba2b0..f1f0e81 100644 --- a/odmltables/gui/generatetemplatepages.py +++ b/src/odmltables/gui/generatetemplatepages.py @@ -12,7 +12,7 @@ from PyQt5.QtCore import Qt import odml -from odmltables import odml_table, odml_xls_table, odml_csv_table, xls_style +from .. import odml_xls_table, odml_table from .pageutils import QIWizardPage, clearLayout, shorten_path mandatory_headers = ['Path to Section', diff --git a/odmltables/gui/generatetemplatewiz.py b/src/odmltables/gui/generatetemplatewiz.py similarity index 100% rename from odmltables/gui/generatetemplatewiz.py rename to src/odmltables/gui/generatetemplatewiz.py diff --git a/odmltables/gui/graphics/comparetable.svg b/src/odmltables/gui/graphics/comparetable.svg similarity index 100% rename from odmltables/gui/graphics/comparetable.svg rename to src/odmltables/gui/graphics/comparetable.svg diff --git a/odmltables/gui/graphics/comparetable.tex b/src/odmltables/gui/graphics/comparetable.tex similarity index 100% rename from odmltables/gui/graphics/comparetable.tex rename to src/odmltables/gui/graphics/comparetable.tex diff --git a/odmltables/gui/graphics/convertodml.svg b/src/odmltables/gui/graphics/convertodml.svg similarity index 100% rename from odmltables/gui/graphics/convertodml.svg rename to src/odmltables/gui/graphics/convertodml.svg diff --git a/odmltables/gui/graphics/convertodml.tex b/src/odmltables/gui/graphics/convertodml.tex similarity index 100% rename from odmltables/gui/graphics/convertodml.tex rename to src/odmltables/gui/graphics/convertodml.tex diff --git a/odmltables/gui/graphics/createtemplate.svg b/src/odmltables/gui/graphics/createtemplate.svg similarity index 100% rename from odmltables/gui/graphics/createtemplate.svg rename to src/odmltables/gui/graphics/createtemplate.svg diff --git a/odmltables/gui/graphics/createtemplate.tex b/src/odmltables/gui/graphics/createtemplate.tex similarity index 100% rename from odmltables/gui/graphics/createtemplate.tex rename to src/odmltables/gui/graphics/createtemplate.tex diff --git a/odmltables/gui/graphics/filterodml.svg b/src/odmltables/gui/graphics/filterodml.svg similarity index 100% rename from odmltables/gui/graphics/filterodml.svg rename to src/odmltables/gui/graphics/filterodml.svg diff --git a/odmltables/gui/graphics/filterodml.tex b/src/odmltables/gui/graphics/filterodml.tex similarity index 100% rename from odmltables/gui/graphics/filterodml.tex rename to src/odmltables/gui/graphics/filterodml.tex diff --git a/odmltables/gui/graphics/mergeappend.svg b/src/odmltables/gui/graphics/mergeappend.svg similarity index 100% rename from odmltables/gui/graphics/mergeappend.svg rename to src/odmltables/gui/graphics/mergeappend.svg diff --git a/odmltables/gui/graphics/mergeappend.tex b/src/odmltables/gui/graphics/mergeappend.tex similarity index 100% rename from odmltables/gui/graphics/mergeappend.tex rename to src/odmltables/gui/graphics/mergeappend.tex diff --git a/odmltables/gui/graphics/mergeodml.svg b/src/odmltables/gui/graphics/mergeodml.svg similarity index 100% rename from odmltables/gui/graphics/mergeodml.svg rename to src/odmltables/gui/graphics/mergeodml.svg diff --git a/odmltables/gui/graphics/mergeodml.tex b/src/odmltables/gui/graphics/mergeodml.tex similarity index 100% rename from odmltables/gui/graphics/mergeodml.tex rename to src/odmltables/gui/graphics/mergeodml.tex diff --git a/odmltables/gui/graphics/mergestrict.svg b/src/odmltables/gui/graphics/mergestrict.svg similarity index 100% rename from odmltables/gui/graphics/mergestrict.svg rename to src/odmltables/gui/graphics/mergestrict.svg diff --git a/odmltables/gui/graphics/mergestrict.tex b/src/odmltables/gui/graphics/mergestrict.tex similarity index 100% rename from odmltables/gui/graphics/mergestrict.tex rename to src/odmltables/gui/graphics/mergestrict.tex diff --git a/odmltables/gui/graphics/odmlA.svg b/src/odmltables/gui/graphics/odmlA.svg similarity index 100% rename from odmltables/gui/graphics/odmlA.svg rename to src/odmltables/gui/graphics/odmlA.svg diff --git a/odmltables/gui/graphics/odmlA.tex b/src/odmltables/gui/graphics/odmlA.tex similarity index 100% rename from odmltables/gui/graphics/odmlA.tex rename to src/odmltables/gui/graphics/odmlA.tex diff --git a/odmltables/gui/graphics/odmlB.svg b/src/odmltables/gui/graphics/odmlB.svg similarity index 100% rename from odmltables/gui/graphics/odmlB.svg rename to src/odmltables/gui/graphics/odmlB.svg diff --git a/odmltables/gui/graphics/odmlB.tex b/src/odmltables/gui/graphics/odmlB.tex similarity index 100% rename from odmltables/gui/graphics/odmlB.tex rename to src/odmltables/gui/graphics/odmlB.tex diff --git a/odmltables/gui/main.py b/src/odmltables/gui/main.py similarity index 100% rename from odmltables/gui/main.py rename to src/odmltables/gui/main.py diff --git a/odmltables/gui/mainwindow.py b/src/odmltables/gui/mainwindow.py similarity index 95% rename from odmltables/gui/mainwindow.py rename to src/odmltables/gui/mainwindow.py index 5f0b792..5816162 100644 --- a/odmltables/gui/mainwindow.py +++ b/src/odmltables/gui/mainwindow.py @@ -2,13 +2,14 @@ """ Created on Tue Jan 26 12:57:46 2016 -@author: zehl +@author: Lyuba Zehl, Julia Sprenger """ import datetime import os import sys import traceback +from importlib.resources import files, as_file from PyQt5 import QtCore, QtWidgets, QtGui @@ -149,13 +150,10 @@ def initUI(self): icon = QtWidgets.QLabel() # icon.setGeometry(10, 10, 4, 100) logo_filename = "odMLtables_100x100.png" - logo_dirs = [os.path.join(os.path.dirname(__file__), '..', '..', 'logo'), - os.path.join(sys.prefix, 'share/pixmaps')] - for logo_dir in logo_dirs: - filepath = os.path.join(logo_dir, logo_filename) + logo_dir_object = files('odmltables.logo').joinpath(logo_filename) + with as_file(logo_dir_object) as filepath: if os.path.exists(filepath): - icon.setPixmap(QtGui.QPixmap(filepath)) - + icon.setPixmap(QtGui.QPixmap(str(filepath))) grid.addWidget(self.convertbutton, 0, 0, 1, 2, QtCore.Qt.AlignCenter) grid.addWidget(self.comparebutton, 1, 1) diff --git a/odmltables/gui/mergepages.py b/src/odmltables/gui/mergepages.py similarity index 99% rename from odmltables/gui/mergepages.py rename to src/odmltables/gui/mergepages.py index 91183db..c64b7d8 100644 --- a/odmltables/gui/mergepages.py +++ b/src/odmltables/gui/mergepages.py @@ -8,7 +8,7 @@ import PyQt5.QtWidgets as Qtw from PyQt5.QtCore import QSize, Qt -from odmltables import odml_table, odml_xls_table, odml_csv_table, xls_style +from .. import odml_table from .pageutils import QIWizardPage, shorten_path from .wizutils import get_graphic_path diff --git a/odmltables/gui/mergewiz.py b/src/odmltables/gui/mergewiz.py similarity index 100% rename from odmltables/gui/mergewiz.py rename to src/odmltables/gui/mergewiz.py diff --git a/odmltables/gui/pageutils.py b/src/odmltables/gui/pageutils.py similarity index 100% rename from odmltables/gui/pageutils.py rename to src/odmltables/gui/pageutils.py diff --git a/odmltables/gui/settings.py b/src/odmltables/gui/settings.py similarity index 100% rename from odmltables/gui/settings.py rename to src/odmltables/gui/settings.py diff --git a/odmltables/gui/wizutils.py b/src/odmltables/gui/wizutils.py similarity index 88% rename from odmltables/gui/wizutils.py rename to src/odmltables/gui/wizutils.py index 54b51b3..fcbfbb0 100644 --- a/odmltables/gui/wizutils.py +++ b/src/odmltables/gui/wizutils.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- -import os, sys +import os +from importlib.resources import files, as_file + from PyQt5.QtWidgets import (QWizard, QMessageBox) from PyQt5.QtGui import QPixmap from PyQt5.QtCore import pyqtSlot, Qt try: import odmltables - have_odmltables = True except: have_odmltables = False @@ -36,12 +37,10 @@ def __init__(self, wizname, parent=None): self.setWizardStyle(self.ModernStyle) self.setOption(self.HaveHelpButton, True) logo_filename = "odMLtables_100x100.png" - logo_dirs = [os.path.join(os.path.dirname(__file__), '..', '..', 'logo'), - os.path.join(sys.prefix, 'share/pixmaps')] - for logo_dir in logo_dirs: - filepath = os.path.join(logo_dir, logo_filename) + logo_dir_object = files('odmltables.logo').joinpath(logo_filename) + with as_file(logo_dir_object) as filepath: if os.path.exists(filepath): - self.setPixmap(QWizard.LogoPixmap, QPixmap(filepath)) + self.setPixmap(QWizard.LogoPixmap, QPixmap(str(filepath))) # set up help messages self._lastHelpMsg = '' diff --git a/logo/odMLtables.eps b/src/odmltables/logo/odMLtables.eps similarity index 100% rename from logo/odMLtables.eps rename to src/odmltables/logo/odMLtables.eps diff --git a/logo/odMLtables.pdf b/src/odmltables/logo/odMLtables.pdf similarity index 100% rename from logo/odMLtables.pdf rename to src/odmltables/logo/odMLtables.pdf diff --git a/logo/odMLtables.png b/src/odmltables/logo/odMLtables.png similarity index 100% rename from logo/odMLtables.png rename to src/odmltables/logo/odMLtables.png diff --git a/logo/odMLtables.svg b/src/odmltables/logo/odMLtables.svg similarity index 100% rename from logo/odMLtables.svg rename to src/odmltables/logo/odMLtables.svg diff --git a/logo/odMLtables_100x100.png b/src/odmltables/logo/odMLtables_100x100.png similarity index 100% rename from logo/odMLtables_100x100.png rename to src/odmltables/logo/odMLtables_100x100.png diff --git a/odmltables/odml_csv_table.py b/src/odmltables/odml_csv_table.py similarity index 100% rename from odmltables/odml_csv_table.py rename to src/odmltables/odml_csv_table.py diff --git a/odmltables/odml_table.py b/src/odmltables/odml_table.py similarity index 99% rename from odmltables/odml_table.py rename to src/odmltables/odml_table.py index f6bf460..c383f84 100644 --- a/odmltables/odml_table.py +++ b/src/odmltables/odml_table.py @@ -2,14 +2,14 @@ """ """ -import os -import re import copy -import odml import csv import datetime -import xlrd +import os +import re +import odml +import xlrd from future.utils import iteritems from six import string_types @@ -720,12 +720,14 @@ def filter_func(dict_prop): def merge(self, odmltable, overwrite_values=False, **kwargs): """ Merge odmltable into current odmltable. + :param odmltable: OdmlTable object or odML document object :param overwrite_values: Bool value to indicate whether values of odML Properties should - be merged (appended) or overwritten by the entries of the other odmltable object. - Default is False. - :return: + be merged (appended) or overwritten by the entries of the other odmltable object. + Default is False. + :return: None """ + if hasattr(odmltable, 'convert2odml'): doc2 = odmltable.convert2odml() else: diff --git a/odmltables/odml_xls_table.py b/src/odmltables/odml_xls_table.py similarity index 97% rename from odmltables/odml_xls_table.py rename to src/odmltables/odml_xls_table.py index d7d064f..27e0075 100644 --- a/odmltables/odml_xls_table.py +++ b/src/odmltables/odml_xls_table.py @@ -225,10 +225,10 @@ def write_row(row_id, row_content, stylestrings): row_id += 1 # set default styles as bool values for simplicity - if self._pattern is "checkerboard": + if self._pattern == "checkerboard": row_style_default = np.array([0, 1] * (len(self._header)), dtype=bool) row_style_default = row_style_default[:len(self._header)] - elif self._pattern is "alternating": + elif self._pattern == "alternating": row_style_default = np.array([0] * len(self._header), dtype=bool) else: raise Exception(f"{self._pattern} is not a valid pattern") @@ -268,9 +268,9 @@ def _switch_row_style(): # row_dic[h] = "" # handling row styles - if self._changing_point is 'properties': + if self._changing_point == 'properties': _switch_row_style() - elif self._changing_point is 'sections' and (row_dic["Path"] != oldpath): + elif self._changing_point == 'sections' and (row_dic["Path"] != oldpath): _switch_row_style() # row_content: only those elements of row_dic, that will be visible in the table @@ -301,7 +301,7 @@ def _switch_row_style(): if 'Value' not in self._header: break - if self._changing_point is 'values': + if self._changing_point == 'values': _switch_row_style() # adjust section and property entries for next value diff --git a/src/odmltables/tests/__init__.py b/src/odmltables/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/odmltables/tests/create_test_odmls.py b/src/odmltables/tests/create_test_odmls.py similarity index 100% rename from odmltables/tests/create_test_odmls.py rename to src/odmltables/tests/create_test_odmls.py diff --git a/odmltables/tests/test_compare_section_table.py b/src/odmltables/tests/test_compare_section_table.py similarity index 100% rename from odmltables/tests/test_compare_section_table.py rename to src/odmltables/tests/test_compare_section_table.py diff --git a/odmltables/tests/test_odml_csv_table.py b/src/odmltables/tests/test_odml_csv_table.py similarity index 100% rename from odmltables/tests/test_odml_csv_table.py rename to src/odmltables/tests/test_odml_csv_table.py diff --git a/odmltables/tests/test_odml_table.py b/src/odmltables/tests/test_odml_table.py similarity index 100% rename from odmltables/tests/test_odml_table.py rename to src/odmltables/tests/test_odml_table.py diff --git a/odmltables/tests/test_odml_xls_table.py b/src/odmltables/tests/test_odml_xls_table.py similarity index 99% rename from odmltables/tests/test_odml_xls_table.py rename to src/odmltables/tests/test_odml_xls_table.py index b386a1d..b67f4d6 100644 --- a/odmltables/tests/test_odml_xls_table.py +++ b/src/odmltables/tests/test_odml_xls_table.py @@ -11,8 +11,8 @@ import unittest import os from odmltables.tests.create_test_odmls import (create_2samerows_test_odml, - create_datatype_test_odml, - create_complex_test_odml, create_showall_test_odml) + create_datatype_test_odml, + create_complex_test_odml, create_showall_test_odml) import xlrd diff --git a/odmltables/xls_style.py b/src/odmltables/xls_style.py similarity index 100% rename from odmltables/xls_style.py rename to src/odmltables/xls_style.py