Skip to content

Commit e86c1cf

Browse files
committed
Initial tested commit
0 parents  commit e86c1cf

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

README.md

Whitespace-only changes.

braininventory/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .get import *

braininventory/get.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import requests
2+
import pandas as pd
3+
import json
4+
from datetime import date
5+
6+
def today():
7+
"""
8+
Get today's snapshot of Brain Image Library.
9+
"""
10+
11+
server = "https://download.brainimagelibrary.org/inventory/daily/reports/"
12+
filename = "today.json"
13+
14+
response = requests.get(f"{server}{filename}")
15+
16+
# Check if the request was successful
17+
if response.status_code == 200:
18+
# Parse the JSON data into a dictionary
19+
data = json.loads(response.text)
20+
data = pd.DataFrame(data)
21+
return data
22+
23+
else:
24+
print("Error: Failed to fetch JSON data")
25+
return pd.DataFrame()
26+
27+
def __get_number_of_datasets(df):
28+
return len(df)
29+
30+
def report():
31+
# Get today's date
32+
tdate = date.today()
33+
34+
# Convert date to string
35+
tdate = tdate.strftime("%Y-%m-%d")
36+
37+
df = today()
38+
39+
report = {}
40+
report['date'] = tdate
41+
report['number_of_datasets'] = __get_number_of_datasets(df)
42+
43+
return report

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", encoding="utf-8") as fh:
4+
long_description = fh.read()
5+
6+
setuptools.setup(
7+
name="braininventory",
8+
version="1.0.0",
9+
author="Ivan Cao-Berg, Eduardo Figueroa",
10+
author_email="[email protected]",
11+
description="A basic inventory management package",
12+
long_description=long_description,
13+
long_description_content_type="text/markdown",
14+
url="https://github.com/brain-image-library/py-bil-inventory",
15+
packages=setuptools.find_packages(),
16+
classifiers=[
17+
"Programming Language :: Python :: 3",
18+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
19+
"Operating System :: OS Independent",
20+
],
21+
python_requires=">=3.6",
22+
)

0 commit comments

Comments
 (0)