irie 0.0.45__py3-none-any.whl → 0.0.46__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.

Potentially problematic release.


This version of irie might be problematic. Click here for more details.

@@ -11,18 +11,9 @@
11
11
  # https://github.com/psychogeekir/ScrapeNBIBridgeInfo/raw/master/getNBIClimateData.py
12
12
  #
13
13
  # Claudio M. Perez
14
+ # Jose S. Yeckle
14
15
  #
15
- # TODO:
16
16
  #
17
- # - Add option for "SELECTED_TAB": "NBETab",
18
- #
19
- # - Perhaps add something like:
20
- # --filter-calid calids.txt
21
- # This will be useful for testing, eg, (chrystal's first version)
22
- # python getNBIData.py yearly.json --filter-calid <(echo "33 0214L")
23
- #
24
- # or
25
- # python getNBIData.py | python getNBIData.py /dev/stdin <(echo "33 0214L")
26
17
  #
27
18
  import sys
28
19
  import json
@@ -32,32 +23,38 @@ from pathlib import Path
32
23
 
33
24
  NAME = Path(__file__).name
34
25
 
35
- EXAMPLES= """"
26
+ EXAMPLES = f""""
36
27
  Examples:
37
28
  run to obtain structure numbers list:
38
29
  $ {NAME}
39
- run to obtain data from JSON list:
40
- $ {NAME} [structure_numbers]
30
+ run to obtain NBI data from JSON list:
31
+ $ {NAME} <file>
41
32
  run filtering for given structure 33 0214L:
42
- $ {NAME} [structure_numbers] --filter-calid "33 0214L"
43
- run filtering for given structures:
44
- $ {NAME} [structure_numbers] --filter-list [list]
33
+ $ {NAME} <file> --filter-calid "33 0214L"
34
+ run filtering for file list of given structures:
35
+ $ {NAME} <file> --filter-list <file>
36
+ run to obtain NBI Element data:
37
+ $ {NAME} <file> --selected-tab "nbe"
38
+ output prints to standard out. to save the output:
39
+ $ {NAME} <file> [options] > out.json
45
40
  """
46
41
 
47
- HELP=f"""
42
+ HELP = f"""
48
43
 
49
44
  usage: $ {NAME}
50
45
  $ {NAME} --help
51
- $ {NAME} [structure_numbers] [options]
46
+ $ {NAME} <file> [options]
47
+ $ {NAME} <file> [options] > out.json
52
48
 
53
- Two-step process to obtain data from the National Bridge Inventory.
49
+ Two-step process to obtain data from the National Bridge Inventory (InfoBridge platform).
54
50
 
55
51
  Positional Arguments:
56
52
 
57
53
  Options:
58
54
  -fc, --filter-calid filter for specific structure.
59
- -fl, --filter-list filter for specified structures in txt file.
60
- -h, --help print this message and exit.
55
+ -fl, --filter-list filter for specified structures in plaintext or json file.
56
+ -t, --selected-tab allows to extract different sources of bridge data, currently supports "nbi" and "nbe".
57
+ -h, --help print this message and exit.
61
58
 
62
59
  {EXAMPLES}
63
60
  """
@@ -108,8 +105,8 @@ def getBridgeList(headers, start_page=1, totalpages=3, pagesize=10, totalbridges
108
105
  return pages
109
106
 
110
107
 
111
- def getNBIData(headers, bridgeTable, years, tab="NBI",
112
- keep_query=False):
108
+ def getBridgeData(headers, bridgeTable, years,
109
+ keep_query=False,tab="nbi"):
113
110
 
114
111
  url = 'https://infobridge.fhwa.dot.gov/Data/getBridgeInformation'
115
112
 
@@ -134,7 +131,7 @@ def getNBIData(headers, bridgeTable, years, tab="NBI",
134
131
 
135
132
  payload = {
136
133
  "requestModel":{
137
- "SELECTED_TAB": f"{tab}Tab",
134
+ "SELECTED_TAB": "NBITab", # Change this to get other tab information
138
135
  "SELECTED_YEAR_ID": None,
139
136
  "IS_NEW_RECORD": False,
140
137
  "IS_YEAR_SELECTED": False,
@@ -148,7 +145,16 @@ def getNBIData(headers, bridgeTable, years, tab="NBI",
148
145
  #"MERRA_ID": 0,"IS_NBI_TREE_SELECTED": False,"Folder_Name": None,"tabChange": False,
149
146
  }
150
147
  }
151
-
148
+
149
+ if tab.lower() == "nbi":
150
+ pass
151
+ elif tab.lower() == "nbe":
152
+ payload["requestModel"].update({
153
+ "SELECTED_TAB": "NBETab"
154
+ })
155
+ else:
156
+ print("ERROR: Please select valid tab.")
157
+ sys.exit()
152
158
 
153
159
  referer = 'https://infobridge.fhwa.dot.gov/Data/BridgeDetail/'
154
160
  data = {}
@@ -189,6 +195,7 @@ def getNBIData(headers, bridgeTable, years, tab="NBI",
189
195
  else:
190
196
  print(f">> Error ({year}) {r.status_code}: {r.content}", file=sys.stderr)
191
197
 
198
+ # Every 500 records, save a json as a progress and sanity check
192
199
  if i % 500 == 0:
193
200
  with open(f"nbi_data-{i}.json", "w") as f:
194
201
  json.dump(data, f, indent=2)
@@ -225,12 +232,15 @@ if __name__ == '__main__':
225
232
 
226
233
  bridgeTable = getBridgeList(headers, start_page=511, totalpages=808, pagesize=100)
227
234
  print(json.dumps(bridgeTable, indent=2))
228
- with open(f"nbi_codes-california-test.json","w") as f:
235
+ # with open(f"nbi_codes-california-test.json","w") as f:
229
236
  # with open(f"nbi_codes-california.json","w") as f:
230
- json.dump(bridgeTable,f,indent=2)
237
+ # json.dump(bridgeTable,f,indent=2)
231
238
  sys.exit()
232
239
 
233
240
  elif len(sys.argv) == 2:
241
+ if sys.argv[1] in ["--help", "-h"]:
242
+ print(HELP)
243
+ sys.exit()
234
244
  headers.update({
235
245
  'datatype': 'json',
236
246
  'content-type': 'application/json; charset=UTF-8',
@@ -245,11 +255,11 @@ if __name__ == '__main__':
245
255
  # calids = list(map(str.strip, open("init/calid.txt").readlines()))
246
256
  # bridgeTable = [i for i in bridgeTable if i["STRUCTURE_NUMBER"] in calids]
247
257
 
248
- nbi_data = getNBIData(headers, bridgeTable[:], years=(2024,)) #range(2020, 2024))
258
+ nbi_data = getBridgeData(headers, bridgeTable[:], years=(2024,)) #range(2020, 2024))
249
259
  print(json.dumps(nbi_data, indent=2))
250
- with open(f"nbi_data-california-test.json","w") as f:
251
- # with open(f"nbi_data-california.json","w") as f:
252
- json.dump(nbi_data,f,indent=2)
260
+ # with open(f"nbi_data-california-test.json","w") as f:
261
+ # with open(f"data/nbi_data-california.json","w") as f:
262
+ # json.dump(nbi_data,f,indent=2)
253
263
 
254
264
  else:
255
265
  arg1 = sys.argv[1]
@@ -257,7 +267,7 @@ if __name__ == '__main__':
257
267
 
258
268
  if arg1 in ["--help", "-h"]:
259
269
  print(HELP)
260
- sys.exit
270
+ sys.exit()
261
271
  else:
262
272
  headers.update({
263
273
  'datatype': 'json',
@@ -265,40 +275,45 @@ if __name__ == '__main__':
265
275
  'accept': 'application/json, text/plain, */*'
266
276
  })
267
277
  bridgeTable = json.load(open(sys.argv[1]))
278
+ selected_tab="nbi"
268
279
  for arg in args2:
269
280
  if arg in ["--help", "-h"]:
270
281
  print(HELP)
271
- sys.exit
282
+ sys.exit()
283
+ elif arg in ["--selected-tab","-t"]:
284
+ selected_tab=next(args2)
272
285
  elif arg in ["--filter-calid", "-fc"]:
273
286
  calid = next(args2)
274
287
  bridgeTable = [
275
288
  i for i in bridgeTable
276
289
  if calid in i["STRUCTURE_NUMBER"]
277
290
  ]
278
- file_ending = calid
279
291
  elif arg in ["--filter-list", "-fl"]:
280
- filename = next(args2)
281
- with open(filename, 'r') as file:
282
- # Check if this is dependent on a specific txt structure (currently 1 bridge/line)
283
- calid = [line.strip() for line in file]
292
+ filter_file = next(args2)
293
+ with open(filter_file, 'r') as file:
294
+ # print(file)
295
+ extension = Path(filter_file).suffix
296
+ # if json, load as json
297
+ if extension==".json":
298
+ calid = json.load(file)
299
+ # all other file extensions, including
300
+ # .txt and none, should be plaintext
301
+ # and will be read line-by-line
302
+ else:
303
+ calid = [line.strip() for line in file]
284
304
  # print(calid)
285
305
  bridgeTable = [
286
306
  i for i in bridgeTable
287
307
  if any(j in i["STRUCTURE_NUMBER"] for j in calid)
288
308
  ]
289
309
  # print(bridgeTable)
290
- file_ending = Path(filename).name
291
310
 
292
311
  # calids = list(map(str.strip, open("init/calid.txt").readlines()))
293
312
  # bridgeTable = [i for i in bridgeTable if i["STRUCTURE_NUMBER"] in calids]
294
313
 
295
- nbi_data = getNBIData(headers, bridgeTable[:], years=(2024,)) #range(2020, 2024))
296
- print(json.dumps(nbi_data, indent=2))
297
-
298
- # TODO: remove this and replace with arg parsing
299
- tab = ...
300
-
301
- with open(f"{tab}_data-{file_ending}.json","w") as f:
302
- # with open(f"nbi_data-california.json","w") as f:
303
- json.dump(nbi_data,f,indent=2)
314
+ bridge_data = getBridgeData(headers, bridgeTable[:], years=(2024,), tab=selected_tab) #range(2020, 2024))
315
+ print(json.dumps(bridge_data, indent=2))
316
+ # with open(f"nbi_data-california-test.json","w") as f:
317
+ # with open(f"data/{selected_tab}_data-california.json","w") as f:
318
+ # json.dump(bridge_data,f,indent=2)
304
319
 
irie/init/getNBIData.py CHANGED
@@ -185,7 +185,7 @@ if __name__ == '__main__':
185
185
  }
186
186
 
187
187
  if len(sys.argv) == 1:
188
-
188
+
189
189
  headers.update({
190
190
  'x-requested-with': 'XMLHttpRequest',
191
191
  'content-type': 'application/json; charset=UTF-8',
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: irie
3
- Version: 0.0.45
3
+ Version: 0.0.46
4
4
  Summary: An infrastructure resilience engine
5
5
  Author-email: "Claudio M. Perez" <50180406+claudioperez@users.noreply.github.com>
6
6
  Project-URL: Repository, https://github.com/STAIRLab
@@ -59,13 +59,13 @@ irie/apps/inventory/__init__.py,sha256=wkkNngGxgYcCM745-rlvP6ynrI0b0QN3aWmLWDsR8
59
59
  irie/apps/inventory/admin.py,sha256=e_W8ls_ARLLf8rn3oJd-YkPdTGMIrcN-mRrxk2BcY3c,472
60
60
  irie/apps/inventory/apps.py,sha256=bZ6qYIwPMG4_4IeLfg9N4WuZAEgEVj84oOswV-7_MAI,424
61
61
  irie/apps/inventory/fields.py,sha256=J3nTImPsuCeiOWBizSL4tnuKs36sPfXALNTKEZY-wVg,79
62
- irie/apps/inventory/filters.py,sha256=ZEM4aubBqATThyaUhdFFoZnZBUASGj5pwtsXcgyOz8Q,2295
62
+ irie/apps/inventory/filters.py,sha256=P0L1AFCcK8X8NWLn0tBVVfEdtCHqzTWUPTeUGflGdk0,2539
63
63
  irie/apps/inventory/forms.py,sha256=y8tcIGInXDg7KCf1OWd1jtc4umJsm8rf8-4O8nDhNd4,1244
64
64
  irie/apps/inventory/models.py,sha256=ie7XhFDujpoyIinmX-YfScVx28SkkRhFadU0iNLC9HI,6073
65
65
  irie/apps/inventory/sitemaps.py,sha256=Nha1MTsIH_ad7JyoxwonPytp7MNuEhDNszkEUOmlN0o,826
66
66
  irie/apps/inventory/tables.py,sha256=vZdPOcbN1ibuWXqLwbBUoQw9iavwa1GJ5fd83k8bu7Y,27874
67
67
  irie/apps/inventory/urls.py,sha256=u2LNLB4K4fDq3yPYtREKf3i7_yHRzrTP3cb22G8Brvk,1578
68
- irie/apps/inventory/views.py,sha256=t-RgtEhSkv1VrvO3d2tvytp81TTlmObQcB2Y04w8zg8,21234
68
+ irie/apps/inventory/views.py,sha256=cjL2v4_7q2S7OczeNdh_g7pVxXdkKgaqj60oQaOEED8,21422
69
69
  irie/apps/inventory/archive/CESMD.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
70
70
  irie/apps/inventory/archive/calid.py,sha256=3L8MbPIGOE3kzDnqeyY055pRBiF2O2l0cmpuDbTsdTg,3014
71
71
  irie/apps/inventory/migrations/0001_initial.py,sha256=PwTHv4Q3gqWFha--8Zp9kUOh-cYalB14jXj7RVJUVnw,1786
@@ -398,7 +398,7 @@ irie/apps/templates/inventory/asset-event-summary.html,sha256=5G7uZVf7kVL0wBaAfs
398
398
  irie/apps/templates/inventory/asset-on-map.html,sha256=LsnvUmTi6TkHSv9sZ_L4KMOwipP_4fkQXDqLUjLS0uo,17062
399
399
  irie/apps/templates/inventory/asset-profile.html,sha256=oJiHwQ7ilmRUQy31PMXJgZUPbefJKBNWhjV6IF8UgR0,13576
400
400
  irie/apps/templates/inventory/asset-sensors.html,sha256=qLnlhnmOeT5uL1xH67mFPOgufXV_PJ31KEx5Aqt0TTw,2406
401
- irie/apps/templates/inventory/asset-table.html,sha256=hHjZqBBE7FfJPUxVAfpfD4w4C3KiJCdr-rEQHnMbDAE,13204
401
+ irie/apps/templates/inventory/asset-table.html,sha256=QAziJ_VKc_BOmJ6YCrNbm_QUd9qqMwFZsWNieIVLlq4,13202
402
402
  irie/apps/templates/inventory/bridge-dashboard.html,sha256=67zrDlih3LOi9xFVwPVZZkgRT3DO-lE_qRL7q8Uz9GY,45472
403
403
  irie/apps/templates/inventory/bridge.html,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
404
404
  irie/apps/templates/inventory/dashboard.html,sha256=_qhFiPP6xN-UzZj5NuM5e9NxsgDHJkQ89oXN1cBwhj0,7505
@@ -466,15 +466,18 @@ irie/init/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
466
466
  irie/init/__main__.py,sha256=waUELqnhqZirROMIb5wMzD4mK5fgrUvWRsXoTXhjtxY,807
467
467
  irie/init/bridges.py,sha256=OBBKnLx2lmMKDfeR0C8CBSbnpnzO0lfokBypD2nEFcM,74198
468
468
  irie/init/calid.py,sha256=-861tihqB-u2ZfXWqAW6RzgSmR1UvcSX4Y_ZzfJVWMw,10883
469
+ irie/init/getBridgeData.py,sha256=PU4OcdXCR0D-CCBX_T3PjyYL0QJKYyz2I4AMhaYKaZk,12650
469
470
  irie/init/getCGSData.py,sha256=iZG3Ab1Y_rhiliKCPNy0MZrKBsfEe6ShgSFz2ttvTUU,2916
470
471
  irie/init/getCGSevents.py,sha256=4dBkFFJQrUs6gfl1Nj-_R2UOZj0B_T017a6tC7fUHOw,421
471
- irie/init/getNBIData.py,sha256=qCd2377wt1MmRuMm-mgRzUxQGKQBYwhMxwxyRLhVe-k,9404
472
- irie/init/getNBIData2.py,sha256=JIbdG2iMq9mUNXBlw_3j_lr71wk7ScVgSWYZOUdZBvo,11782
472
+ irie/init/getNBIData.py,sha256=LJ3GycQ_0A-TbevlRr4zplwz3KDJHZFK1WGEK1hufoU,9392
473
473
  irie/init/hayward.zip,sha256=WECOnYLP_3EeKHQzdxm17MHTncF2QdgXI28Vm6Iopt0,124675
474
474
  irie/init/data/cgs-stations.json,sha256=h-KKF-u31j_OQnQZQlmFzDjqgi0AcsPNzohn7bCNq0Q,105563
475
475
  irie/init/data/cgs_data.json,sha256=l2lADALMXVLKY6jn-rvEZjYWcZjGHLk22ZudocdR81Q,27752
476
+ irie/init/data/nbe_data-california.json,sha256=1bUojfq0ES98O8G606jPOx4wSox_GxTkwkj_SgG6ymo,8101291
477
+ irie/init/data/nbi_codes-california-filtered.json,sha256=FgpvLdc7X1O27H-35ZPYyxKKfyQ87rW5Onpmtp51OWw,814
476
478
  irie/init/data/nbi_codes-california.json,sha256=UPFbBzxY2NshREecsP4evCA8vdvXFRvG4rYT4_KHmQs,2398694
477
479
  irie/init/data/nbi_data-california.json,sha256=nyslZbMf30WrtdyqCpMvxd-NNxNzFHtZX_TDWRZFob0,8534365
480
+ irie/init/data/nbi_data_cesmd.json,sha256=6FkK7dOx3oK7-_ew0jS4F2owRH-tueiE-y7kU9V_Png,11234353
478
481
  irie/init/data/nbi_definitions.json,sha256=NS3yNP1i1E_JXfGW_I_xOoNRsfeljDA5BZ_1h0Cu_1I,4301
479
482
  irie/init/data/nbi/04.tar,sha256=ubRgxWBshe0cNKxftbEVyFeh1HcUmFarVL2BBHo9Tyk,1884160
480
483
  irie/init/data/networks/soga_corridors.json,sha256=AQOUaKGNWkQxQKLfqphE9Qb_-NRmjN9IwK59SGjutxE,45496
@@ -486,8 +489,8 @@ irie/init/management/commands/make_asset.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm
486
489
  irie/pull/nbi.py,sha256=KpBjJ9GEU72Qk1t4bGN9cg0QBeVJ8k9XcI3Y1oSgIR0,11478
487
490
  irie/rest/__main__.py,sha256=6Nf_-Rr9zGmMyp_wqCFDO7ls9QPnPd9UyUgN17rIGYw,3680
488
491
  irie/usgs/__main__.py,sha256=HiSvPn5IW5IqRiCk1qRRq5dCy3-7iISw7v1P_w2rLrk,5049
489
- irie-0.0.45.dist-info/METADATA,sha256=Sfs8DI6WGsfvEHkGCAHCp256LDnelpkFeHsEBkVOVLc,3207
490
- irie-0.0.45.dist-info/WHEEL,sha256=tTnHoFhvKQHCh4jz3yCn0WPTYIy7wXx3CJtJ7SJGV7c,91
491
- irie-0.0.45.dist-info/entry_points.txt,sha256=A_3h9wPBGfxGQ78_MGa-nO6Z0foxOYeAnIE47jxEztg,44
492
- irie-0.0.45.dist-info/top_level.txt,sha256=zVCxi5E2nkISZPzKq8VEhWe_dGuPcefLYV1tYqQdwlY,5
493
- irie-0.0.45.dist-info/RECORD,,
492
+ irie-0.0.46.dist-info/METADATA,sha256=xy70P74HMWw2NTd1QS8Ce0YOjB99wwY7IDUYUT6B_Iw,3207
493
+ irie-0.0.46.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
494
+ irie-0.0.46.dist-info/entry_points.txt,sha256=A_3h9wPBGfxGQ78_MGa-nO6Z0foxOYeAnIE47jxEztg,44
495
+ irie-0.0.46.dist-info/top_level.txt,sha256=zVCxi5E2nkISZPzKq8VEhWe_dGuPcefLYV1tYqQdwlY,5
496
+ irie-0.0.46.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (77.0.1)
2
+ Generator: setuptools (77.0.3)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5