-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·51 lines (39 loc) · 1.26 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/python3
import click
import requests
__author__ = "hs3city"
"""EAN Barcode of Club Mate"""
mate_barcode = 4029764001807
@click.group()
def main():
"""
Simple CLI using EAN Barcodes for managing Club Mate and (soon) other things @ hs3city.
"""
pass
@main.command()
@click.argument('barcode', type=click.IntRange(1000000000000, 9999999999999))
def add(barcode):
"""Add the product to the database"""
amount = click.prompt('Please enter the amount', type=click.IntRange(0, 40), default=1)
if(barcode == mate_barcode):
url = 'https://mate.at.hs3.pl/add/{}'.format(amount)
response = requests.get(url)
click.echo(response.text)
@main.command()
@click.argument('barcode', type=click.IntRange(1000000000000, 9999999999999))
def withdraw(barcode):
"""Withdraw one item of the product in the database"""
if(barcode == mate_barcode):
url = 'https://mate.at.hs3.pl/one'
response = requests.get(url)
click.echo(response.text)
@main.command()
@click.argument('barcode', type=click.IntRange(1000000000000, 9999999999999))
def get(barcode):
"""Return the information about the product in the database"""
if(barcode == mate_barcode):
url = 'https://mate.at.hs3.pl/'
response = requests.get(url)
click.echo(response.text)
if __name__ == "__main__":
main()