Skip to content

Commit

Permalink
usedforsecurity is 3.9+
Browse files Browse the repository at this point in the history
  • Loading branch information
zmoon committed Oct 26, 2023
1 parent 8284707 commit 462d488
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions monetio/obs/openaq.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
https://openaq-fetches.s3.amazonaws.com/index.html
"""
import json
import sys
import warnings

import pandas as pd
from numpy import NaN

_PY39_PLUS = sys.version_info >= (3, 9)

_URL_CAP_RANDOM_SAMPLE = False # if false, take from end of list
_URL_CAP = None # set to int to limit number of files loaded for testing

Expand Down Expand Up @@ -492,8 +495,15 @@ def add_data(self, dates, *, num_workers=1, wide_fmt=True):
# with different location names.
# Occasionally, there are rows that appear to actual duplicates
# (e.g. all same except one col is null in one or something)
def do_hash(b):
return hashlib.sha1(b, usedforsecurity=False).hexdigest()
if _PY39_PLUS:

def do_hash(b):
return hashlib.sha1(b, usedforsecurity=False).hexdigest()

else:

def do_hash(b):
return hashlib.sha1(b).hexdigest()

# to_hash = df.latitude.astype(str) + " " + df.longitude.astype(str)
to_hash = df.location + " " + df.latitude.astype(str) + " " + df.longitude.astype(str)
Expand Down

0 comments on commit 462d488

Please sign in to comment.