File tree Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ from .get import *
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
+
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
+ )
You can’t perform that action at this time.
0 commit comments