Skip to content

Commit 250cff9

Browse files
chg: ♻️ prepared publish
1 parent 78cb993 commit 250cff9

File tree

2 files changed

+142
-20
lines changed

2 files changed

+142
-20
lines changed

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,86 @@
11
# Mindee API helper library for python
2+
3+
The full documentation is availabale [here](https://mindee.com/documentation/get-started/setup-your-account)
4+
5+
## Install
6+
7+
Install from PyPi using pip, a package manager for Python.
8+
9+
```shell script
10+
pip install mindee
11+
```
12+
13+
Don't have pip installed? Try installing it, by running this from the command line:
14+
15+
```shell script
16+
$ curl https://bootstrap.pypa.io/get-pip.py | python
17+
```
18+
19+
Getting started with the Mindee API couldn't be easier. Create a Client and you're ready to go.
20+
21+
22+
## Create your Client
23+
24+
The mindee.Client needs your API credentials. You can either pass these directly to the constructor (see the code below) or via environment variables.
25+
26+
27+
28+
Depending on what type of document you want to parse, you need to add specifics auth token for each endpoint.
29+
30+
```python
31+
from mindee import Client
32+
33+
mindee_client = Client(
34+
expense_receipts_token="your_expense_receipts_api_token_here",
35+
invoice_token="your_invoice_api_token_here",
36+
passport_token="your_passport_api_token_here",
37+
license_plate_token="your_license_plate_api_token_here",
38+
raise_on_error=True
39+
)
40+
```
41+
42+
We suggest storing your credentials as environment variables. Why? You'll never have to worry about committing your credentials and accidentally posting them somewhere public.
43+
44+
45+
## Parsing methods
46+
47+
```python
48+
# Call the receipt parsing API and create a receipt object under parsed_data.receipt
49+
parsed_data = mindee_client.parse_receipt("/path/to/file")
50+
51+
# Call the invoice parsing API and create an invoice object under parsed_data.invoice
52+
parsed_data = mindee_client.parse_invoice("/path/to/file")
53+
54+
# If you have a mixed data flow of invoice and receipt, use financial_document class
55+
# Call the invoice or receipt parsing API according to your input data type
56+
# and create a FinancialDocument object under parsed_data.financial_document
57+
parsed_data = mindee_client.parse_financial_document("/path/to/file")
58+
59+
# Call the passport parsing API and create a Passport object under parsed_data.passport
60+
parsed_data = mindee_client.parse_passport("/path/to/file")
61+
62+
# Call the license_plates parsing API and create a CarPlate object under parsed_data.license_plate
63+
parsed_data = mindee_client.parse_license_plate("/path/to/file")
64+
```
65+
66+
## Input data
67+
68+
You can pass your input file in three ways:
69+
70+
71+
From file path
72+
```python
73+
receipt_data = mindee_client.parse_receipt('/path/to/file', input_type="path")
74+
```
75+
76+
From a file object
77+
```python
78+
with open('/path/to/file', 'rb') as fp:
79+
receipt_data = mindee_client.parse_receipt(fp, input_type="file")
80+
```
81+
82+
From a base64
83+
```python
84+
receipt_data = mindee_client.parse_receipt(base64_string, input_type="base64")
85+
```
86+

setup.py

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,65 @@
1-
import pathlib
2-
from setuptools import setup
1+
import os
2+
import subprocess
3+
import re
4+
from setuptools import find_packages, setup
35

4-
# The directory containing this file
5-
HERE = pathlib.Path(__file__).parent
6-
# The text of the README file
6+
__version__ = None
7+
8+
9+
with open("README.md", "r", newline="", encoding="utf-8") as fh:
10+
long_description = fh.read()
11+
12+
13+
def get_latest_git_tag(filepath):
14+
try:
15+
return (
16+
subprocess.check_output(
17+
["git", "describe", "--tags", "--abbrev=0"],
18+
cwd=os.path.dirname(filepath),
19+
)
20+
.strip()
21+
.decode()
22+
)
23+
except subprocess.CalledProcessError:
24+
return "no_tag_found"
25+
26+
27+
APP_NAME = "mindee"
28+
PACKAGE_NAME = "mindee"
29+
GIT_URL = "https://github.com/publicMindee/mindee-api-python"
30+
VERSION = "v0.3"
31+
32+
33+
def make_requirements_list(file="requirements.txt", only_regular=True):
34+
"""
35+
Make a list of package requirements from a requirements.txt file
36+
:param file: path to txt file
37+
:param only_regular: remove rows with /, #, space or empty
38+
:return:
39+
"""
40+
41+
with open(file) as f:
42+
lines = f.read().splitlines()
43+
if only_regular:
44+
regex = (
45+
"\/$|^#|^$$|^git\+"
46+
) # remove line with /, starting by # or space or empty
47+
return [line for line in lines if not re.findall(regex, line)]
48+
else:
49+
return lines
750

8-
README = (HERE / "README.md").read_text()
9-
# This call to setup() does all the work
1051

1152
setup(
12-
name="mindee",
13-
version="0.0.1",
14-
description="Mindee SDK repository",
15-
long_description=README,
53+
python_requires=">=3.0",
54+
name=f"{PACKAGE_NAME}",
55+
description="Mindee API helper library for python",
56+
version=VERSION,
57+
long_description=long_description,
1658
long_description_content_type="text/markdown",
17-
# url="https://github.com/publicMindee/python-sdk",
59+
url=GIT_URL,
60+
packages=find_packages(),
1861
author="Mindee",
1962
author_email="contact@mindee.com",
20-
license="MIT",
21-
classifiers=[
22-
"License :: OSI Approved :: MIT License",
23-
"Programming Language :: Python :: 3",
24-
],
25-
packages=["mindee"],
26-
include_package_data=True,
27-
install_requires=[]
63+
install_requires=make_requirements_list(),
64+
include_package_data=True
2865
)

0 commit comments

Comments
 (0)