nfelodcm 0.0.1__py3-none-any.whl → 0.1.1__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.
@@ -2,4 +2,5 @@ from .extract_map import extract_map
2
2
  from .retrieve_season_state import current_season
3
3
  from .set_season_state import set_season_state
4
4
  from .checks import check_struc
5
- from .checks import check_map_type
5
+ from .checks import check_map_type
6
+ from .checks import check_data
@@ -4,7 +4,7 @@ import pathlib
4
4
  import json
5
5
  import datetime
6
6
 
7
- ## script that runs on package import to check format of config file, existance of csvs, and columns ##
7
+
8
8
  def check_struc(config):
9
9
  """
10
10
  Checks to ensure the config structure is valid
@@ -79,3 +79,32 @@ def check_map_type(map):
79
79
  ## return ##
80
80
  return passing, errors
81
81
 
82
+ def check_data():
83
+ '''
84
+ Runs on load and checks for the existence of local data for each map. If data does not exist,
85
+ freshness meta data in the map is reset
86
+ '''
87
+ ## get maps ##
88
+ maps_dir = pathlib.Path(__file__).parent.parent.resolve() / 'Maps'
89
+ maps = list(maps_dir.glob('*.json'))
90
+ ## check that maps were found ##
91
+ if len(maps) == 0:
92
+ return
93
+ ## for each map, parse name, check for csv, and make updates as needed ##
94
+ for map_path in maps:
95
+ ## parse the name ##
96
+ table = map_path.stem
97
+ ## check for the csv ##
98
+ csv_path = pathlib.Path(
99
+ pathlib.Path(__file__).parent.parent.resolve() / 'Data' / '{0}.csv'.format(table)
100
+ )
101
+ csv_path.exists()
102
+ if not csv_path.exists():
103
+ ## if the csv does not exist, update the map file ##
104
+ with open(map_path, 'r+') as config_file:
105
+ data = json.load(config_file)
106
+ data['last_local_update'] = None
107
+ data['freshness']['last_freshness_check'] = None
108
+ config_file.seek(0) # reset file position to the beginning
109
+ json.dump(data, config_file, indent=2)
110
+ config_file.truncate() # remove remaining part```
nfelodcm/nfelodcm.py CHANGED
@@ -6,6 +6,8 @@ import nfelodcm.nfelodcm.Utilities as utils
6
6
 
7
7
  ## init season state on load ##
8
8
  utils.set_season_state()
9
+ ## update local data freshness meta as needed ##
10
+ utils.check_data()
9
11
 
10
12
  ## wrappers and classes to interact with the package ##
11
13
  def get_df(table):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nfelodcm
3
- Version: 0.0.1
3
+ Version: 0.1.1
4
4
  Summary: Python package for loading and caching CSVs hosted on github into pandas dataframes
5
5
  Author-email: Robert Greer <nfl@robbygreer.com>
6
6
  Maintainer-email: Robert Greer <nfl@robbygreer.com>
@@ -1,4 +1,4 @@
1
- nfelodcm/nfelodcm.py,sha256=1VP3UOAckQNqIVOoE5MkDUE_KQfp3tnHDVO-jzDS0rY,996
1
+ nfelodcm/nfelodcm.py,sha256=bqN1HBVV6xs6eC0vAy0QFLz7ljCfO9CKA22QEJEs3cE,1064
2
2
  nfelodcm/Engine/DCMTable.py,sha256=9_x82HKPWOwkIqQF4qZvUCLg8n6IUQfrtLlaU4bPIxM,2646
3
3
  nfelodcm/Engine/__init__.py,sha256=vEEWcIBE4KLHoBCT1s2AIeSZxMfv1bcAqUNAJzSMSMo,31
4
4
  nfelodcm/Engine/Assignments/__init__.py,sha256=IPKxTBbO3b0xaO922zkwif0FFd8Xqe3ZvCIFjhYg1oE,80
@@ -10,12 +10,12 @@ nfelodcm/Engine/Primatives/Freshness.py,sha256=5dGPoFCeCBdhvr5g_Ey-xAK742F596uQf
10
10
  nfelodcm/Engine/Primatives/LocalIO.py,sha256=aVdPiz-gkyrJLPOHBg87PiNWZAI6EZGfyJVej9Z2uk0,1527
11
11
  nfelodcm/Engine/Primatives/TableMap.py,sha256=M_T2TTxbT2B1Mv9hY3Ocli_AkoPirNUJDZ8n1HQPlgM,2636
12
12
  nfelodcm/Engine/Primatives/__init__.py,sha256=JUHF_8_1vqbp7M5rJfDwzqkgi6UuLTPp_lxCw7t1uwc,124
13
- nfelodcm/Utilities/__init__.py,sha256=HImBvAfYeQeGAYj-kNWDCXZzSWibQ22m_jBIDc2FGsU,200
14
- nfelodcm/Utilities/checks.py,sha256=B8yptuVCj_Dwi8OQBjilT0uZduET7GpqpdL1Q8KZv_g,2746
13
+ nfelodcm/Utilities/__init__.py,sha256=mV5mBnrWIVItpVuQ2sYQWDxm1DpMFIgAxYoQLP79lF0,231
14
+ nfelodcm/Utilities/checks.py,sha256=5bFdlDpejJIyNZnXDWKMdst0Jy7YGPx591dEgKePuEM,3894
15
15
  nfelodcm/Utilities/extract_map.py,sha256=DVITMr0mlP6p2V1ZdaIcbEavs-FZ28-EZ885maiS_KU,969
16
16
  nfelodcm/Utilities/retrieve_season_state.py,sha256=ZrBaMWmo2DA9OZqZ6MBWmrY9Llkc5OUfxmDk7EB1tRU,579
17
17
  nfelodcm/Utilities/set_season_state.py,sha256=Y5fvop3EZfWcx2F85MtSNEGnwjofWyEMg4_HLTenAUA,3737
18
- nfelodcm-0.0.1.dist-info/METADATA,sha256=u0sWsUNg5RiQRxP6Qy6mD5iqYXDRzrmeCbCgkqivuwQ,4409
19
- nfelodcm-0.0.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
20
- nfelodcm-0.0.1.dist-info/top_level.txt,sha256=SlNA7_yZSwWvZIl9Md6brBH_C7nAYnATe4CrvuUXOGo,9
21
- nfelodcm-0.0.1.dist-info/RECORD,,
18
+ nfelodcm-0.1.1.dist-info/METADATA,sha256=WC-C5lajCs5IzyVlyVh2t282gTRdO3SCwXZBFe00hsQ,4409
19
+ nfelodcm-0.1.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
20
+ nfelodcm-0.1.1.dist-info/top_level.txt,sha256=SlNA7_yZSwWvZIl9Md6brBH_C7nAYnATe4CrvuUXOGo,9
21
+ nfelodcm-0.1.1.dist-info/RECORD,,