Skip to content

Commit

Permalink
moved files for nicer python package structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Echsecutor committed Mar 23, 2020
1 parent f18a91d commit 5663273
Show file tree
Hide file tree
Showing 50 changed files with 55 additions and 15 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
cd src
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
cd src
cd epcis_event_hash_generator
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
cd src
cd tests
pip install pytest
pytest
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This is a proposal/reference implementation for a method to uniquely identify an EPCIS event or validate the integrity thereof. To this end, a syntax-/representation-agnostic approach based on hashing is developed.
The <b>PROTOTYPAL DEMO SOFTWARE</b> takes an EPCIS Document (either formatted in XML or JSON-LD) and returns the hash value(s) of the contained EPCIS events representing a unique fingerprint of the latter.

<img src="epcisEventHashGenerator.jpg">
![EPCIS event hash generator algorithm illustration](docs/epcisEventHashGenerator.jpg)


## Usage (for the inconvenient)
Expand Down Expand Up @@ -238,10 +238,7 @@ ni:///sha-512;daef4953b9783365cad6615223720506cc46c5167cd16ab500fa597aa08ff964<b

For better understanding, the following illustration includes the data content of a simple EPCIS event (including a couple of user extensions - all defined under 'https://ns.example.com/epcis'), shows the corresponding pre-hash string as well as the canonical hash value of that event.

<img src="hashingAlgorithmLogicIllustration.jpg">

## Installation
tbd
![Example EPCIS event pre-hash computation](docs/hashingAlgorithmLogicIllustration.jpg)

## References
* EPCIS Standard, v. 1.2: https://www.gs1.org/standards/epcis
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions epcis_event_hash_generator/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import setuptools

with open("README.md", "r") as fh:
long_description = fh.read()

setuptools.setup(
name="epcis-event-hash-generator",
version="1.0.1",
author=" Ralph Troeger; Sebastian Schmittner",
author_email="ralph.troeger@gs1.de;schmittner@eecc.info",
description="Exemplary implementation of the epcis event hash generator algorithm described in the README",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/RalphTro/epcis-event-hash-generator",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
)
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions tests/context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

import epcis_event_hash_generator
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from .epcis_event_hash_generator import epcis_hash
try:
from .context import epcis_event_hash_generator
except ImportError:
from context import epcis_event_hash_generator

from epcis_event_hash_generator.epcis_event_hash_generator import epcis_hash

from os import walk, path

TEST_FILE_PATH = "../testFiles/examples/"
TEST_FILE_PATH = "examples/"

def test_explicit_hash_values():
num_tested = 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
from .epcis_event_hash_generator import epcis_hash
try:
from .context import epcis_event_hash_generator
except ImportError:
from context import epcis_event_hash_generator


from epcis_event_hash_generator.epcis_event_hash_generator import epcis_hash


from os import walk

TEST_FILE_PATH = "../testFiles/examples/"
TEST_FILE_PATH_SAME_EVENT = "../testFiles/expected_equal/"
TEST_FILE_PATH = "examples/"
TEST_FILE_PATH_SAME_EVENT = "expected_equal/"


def test_distinct():
Expand Down
9 changes: 7 additions & 2 deletions src/test_xml_to_py.py → tests/test_xml_to_py.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from . import xml_to_py
try:
from .context import epcis_event_hash_generator
except ImportError:
from context import epcis_event_hash_generator

from epcis_event_hash_generator import xml_to_py

import xml.etree.ElementTree as ElementTree

Expand All @@ -22,7 +27,7 @@ def test_docstring_example():


def test_epcsi_reference_example():
actual_obj = xml_to_py.event_list_from_epcis_document_xml("../testFiles/examples/ReferenceEventHashAlgorithm.xml")
actual_obj = xml_to_py.event_list_from_epcis_document_xml("examples/ReferenceEventHashAlgorithm.xml")

print(actual_obj)

Expand Down

0 comments on commit 5663273

Please sign in to comment.