cdapython 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cdapython/__init__.py ADDED
@@ -0,0 +1,7 @@
1
+ from cdapython.application_utilities import get_api_url, set_api_url
2
+ from cdapython.discover import cda_functions, column_values, columns, release_metadata, tables
3
+ from cdapython.summarize import expand_file_results, expand_subject_results, intersect_file_results, intersect_subject_results, summarize_files, summarize_subjects
4
+ from cdapython.get_data import get_file_data, get_subject_data
5
+
6
+ from cdapython.logging_wrappers import disable_console_logging, disable_file_logging, enable_console_logging, enable_file_logging, get_log_level, get_valid_log_levels, set_log_level
7
+
@@ -0,0 +1,54 @@
1
+ import os
2
+ import re
3
+ import pandas as pd
4
+
5
+ import cda_client
6
+
7
+ #############################################################################################################################
8
+ #
9
+ # get_api_url(): Return the current system URL for the CDA REST API.
10
+ #
11
+ #############################################################################################################################
12
+
13
+ def get_api_url():
14
+ """
15
+ Return the currently-set URL pointing to the CDA REST API.
16
+ """
17
+
18
+ # System default.
19
+
20
+ default_api_url = 'http://127.0.0.1:8000'
21
+
22
+ # Has the user set a non-default URL?
23
+
24
+ local_api_url = os.environ.get( '__CDA_API_URL' )
25
+
26
+ if local_api_url is not None and len( local_api_url ) > 0:
27
+
28
+ return local_api_url
29
+
30
+ else:
31
+
32
+ return default_api_url
33
+
34
+ #############################################################################################################################
35
+ #
36
+ # set_api_url(): Set the current system URL for the CDA REST API.
37
+ #
38
+ #############################################################################################################################
39
+
40
+ def set_api_url( new_api_url ):
41
+ """
42
+ Set the current system URL for the CDA REST API.
43
+ """
44
+
45
+ # Do some basic sanity checking.
46
+
47
+ if re.search( r'^https*:\/\/', new_api_url ) is None:
48
+ raise RuntimeError( 'set_api_url(): Only HTTP and HTTPS URLs are allowed.' )
49
+ elif len( new_api_url ) > 100:
50
+ raise RuntimeError( 'set_api_url(): Whatever that was, it wasn\'t the URL of the CDA REST API.' )
51
+
52
+ os.environ['__CDA_API_URL'] = new_api_url
53
+
54
+
File without changes
@@ -0,0 +1,19 @@
1
+ version: 1
2
+ formatters:
3
+ default:
4
+ format: '%(levelname)-8s [%(asctime)s] %(filename)s line %(lineno)5d, in %(funcName)s(): %(message)s'
5
+ handlers:
6
+ console:
7
+ class: logging.StreamHandler
8
+ formatter: default
9
+ stream: ext://sys.stdout
10
+ file:
11
+ class: logging.FileHandler
12
+ formatter: default
13
+ filename: cdapython_log.txt
14
+ encoding: utf8
15
+ mode: a
16
+ loggers:
17
+ default:
18
+ handlers: [console]
19
+ propagate: yes