Skip to content

Commit 0ba8119

Browse files
Add v0.0.1, README with examples, and jupyter notebook.
1 parent d2ca599 commit 0ba8119

File tree

6 files changed

+168
-140
lines changed

6 files changed

+168
-140
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
all:
2+
python3 setup.py sdist bdist_wheel
3+
4+
upload:
5+
python3 -m twine upload dist/*

README.md

Whitespace-only changes.

python-tilt-example.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"cells":[{"metadata":{},"cell_type":"markdown","source":"## Installation\nInstall the python client library using pip. See the [project page](https://pypi.org/project/tilt/).****"},{"metadata":{"trusted":true},"cell_type":"code","source":"!pip3 install tilt\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Basic usage\n\n1) Import the transparency information language binding/library.\n2) Create your first object, e.g. a Data Protection Officer with their contact details.\n3) Continue creating your objects, i.e. a Controller and its Representative.\n4) ... (add all other fields, not shown in here) ..."},{"metadata":{"trusted":true},"cell_type":"code","source":"from tilt import tilt\n\ndpo = tilt.DataProtectionOfficer(name='Max Ninjaturtle', address='21 Jump Street', country='DE', email='jane@mycompany.com', phone='0142 43333')\nprint(dpo.to_dict())\n# {'address': '21 Jump Street', 'country': 'DE', 'email': 'jane@mycompany.com', 'name': 'Max Ninjaturtle', 'phone': '0142 43333'}\n\n\nr = tilt.ControllerRepresentative(name='Maxi Müller', email='maxi@mail.com', phone=None)\nc = tilt.Controller(name='MyCompany', address='Straße des 17. Juni', country='DE', division='Main', representative=r)\nprint(c.to_dict())\n# {'address': 'Straße des 17. Juni', 'country': 'DE', 'division': 'Main', 'name': 'MyCompany', 'representative': {'email': 'maxi@mail.com', 'name': 'Maxi Müller', 'phone': None}}","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Import existing documents\nIn order to import exisiting tilt documents (we call them instances), you can use your favorite HTTP client or load from your local disk. Then you can use the native python objects and do any manipulations as you like.[](http://)"},{"metadata":{"trusted":true},"cell_type":"code","source":"import json\nimport requests\n\nfile = requests.get('https://raw.githubusercontent.com/Transparency-Information-Language/schema/master/tilt.json')\ninstance = tilt.tilt_from_dict(json.loads(file.content))\n\nprint(instance.controller.to_dict())\n# {'address': 'Wolfsburger Ring 2, 38440 Berlin', 'country': 'DE', 'division': 'Product line e-mobility', 'name': 'Green Company AG', 'representative': {'email': 'contact@greencompany.de', 'name': 'Jane Super', 'phone': '0049 151 1234 5678'}}\n\nfor element in list(instance.data_disclosed):\n for recipient in element.recipients:\n print(recipient.category)\n# Marketing content provider\n# Responsible Statistical Institutes\n\n\ninstance.controller.name = 'Yellow Company Ltd.'\nprint(instance.controller.to_dict())\n# {'address': 'Wolfsburger Ring 2, 38440 Berlin', 'country': 'DE', 'division': 'Product line e-mobility', 'name': 'Yellow Company Ltd.', 'representative': {'email': 'contact@greencompany.de', 'name': 'Jane Super', 'phone': '0049 151 1234 5678'}}","execution_count":59,"outputs":[{"output_type":"stream","text":"{'address': 'Wolfsburger Ring 2, 38440 Berlin', 'country': 'DE', 'division': 'Product line e-mobility', 'name': 'Green Company AG', 'representative': {'email': 'contact@greencompany.de', 'name': 'Jane Super', 'phone': '0049 151 1234 5678'}}\nMarketing content provider\nResponsible Statistical Institutes\n{'address': 'Wolfsburger Ring 2, 38440 Berlin', 'country': 'DE', 'division': 'Product line e-mobility', 'name': 'Yellow Company Ltd.', 'representative': {'email': 'contact@greencompany.de', 'name': 'Jane Super', 'phone': '0049 151 1234 5678'}}\n","name":"stdout"}]},{"metadata":{},"cell_type":"markdown","source":"## Create new documents from scratch\nIn the example below we are using standard libraries (e.g. sha256 or datetime) in order to create formatted strings. All objects have `from_dict()` and `to_dict()` functions which help you to build or export them."},{"metadata":{"trusted":true},"cell_type":"code","source":"from hashlib import sha256\nfrom datetime import datetime\n\nresult = {}\nresult[\"_hash\"] = sha256('<insert hashable content here>'.encode('utf-8')).hexdigest()\nresult[\"_id\"] = '<your-id-01>'\nresult[\"created\"] = '2020-10-02T22:08:12.510696'\nresult[\"language\"] = 'en'\nresult[\"modified\"] = datetime.now().isoformat()\nresult[\"name\"] = 'Green Compancy SE'\nresult[\"status\"] = 'active'\nresult[\"url\"] = 'https://greencompany.implementation.cloud'\nresult[\"version\"] = 42\n\nmeta = tilt.Meta.from_dict(result)\n\nprint(meta)\n# <tilt.tilt.Meta object at 0x7fef287928d0>\n\nprint(meta.to_dict())\n# {'_hash': 'bd8f3c314b73d85175c8ccf15b4b8d26348beca96c9df39ba98fa5dda3f60fcc', '_id': '<your-id-01>', 'created': '2020-10-02T22:08:12.510696', 'language': 'en', 'modified': '2020-07-27T15:14:35.689606', 'name': 'Green Compancy SE', 'status': 'active', 'url': 'https://greencompany.implementation.cloud', 'version': 42}","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.7.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":4}

setup.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import setuptools
2+
3+
with open("README.md", "r") as fh:
4+
long_description = fh.read()
5+
6+
setuptools.setup(
7+
name="tilt",
8+
version="0.0.1",
9+
author="Elias Grünewald",
10+
author_email="gruenewald@tu-berlin.de",
11+
description="A python language binding for the Transparancy Information Language and Toolkit (TILT)",
12+
long_description=long_description,
13+
long_description_content_type="text/markdown",
14+
url="https://github.com/Transparency-Information-Language/python-tilt",
15+
packages=setuptools.find_packages(),
16+
classifiers=[
17+
"Programming Language :: Python :: 3",
18+
"License :: OSI Approved :: GNU Affero General Public License v3",
19+
"Operating System :: OS Independent",
20+
],
21+
python_requires='>=3.6',
22+
)

tilt/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)