Skip to content

Commit

Permalink
only use usedforsecurity=False in 3.9+
Browse files Browse the repository at this point in the history
  • Loading branch information
bmos committed Sep 19, 2024
1 parent 821a591 commit 01ef28b
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions parsons/etl/etl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import sys

import petl

Expand Down Expand Up @@ -658,11 +659,20 @@ def unpack_nested_columns_as_rows(self, column, key="id", expand_original=False)
orig.concat(melted_list)
# Add unique id column by hashing all the other fields
if "uid" not in self.columns:
orig.add_column(
"uid",
lambda row: hashlib.md5(str.encode("".join([str(x) for x in row])),
usedforsecurity=False).hexdigest(),
)
if sys.version_info.minor >= 9:
orig.add_column(
"uid",
lambda row: hashlib.md5(
str.encode("".join([str(x) for x in row])), usedforsecurity=False
).hexdigest(),
)
elif sys.version_info.minor < 9:
orig.add_column(
"uid",
lambda row: hashlib.md5(
str.encode("".join([str(x) for x in row]))
).hexdigest(),
)
orig.move_column("uid", 0)

# Rename value column in case this is done again to this Table
Expand All @@ -674,11 +684,18 @@ def unpack_nested_columns_as_rows(self, column, key="id", expand_original=False)
else:
orig = self.remove_column(column)
# Add unique id column by hashing all the other fields
melted_list.add_column(
"uid",
lambda row: hashlib.md5(str.encode("".join([str(x) for x in row])),
usedforsecurity=False).hexdigest(),
)
if sys.version_info.minor >= 9:
melted_list.add_column(
"uid",
lambda row: hashlib.md5(
str.encode("".join([str(x) for x in row])), usedforsecurity=False
).hexdigest(),
)
elif sys.version_info.minor < 9:
melted_list.add_column(
"uid",
lambda row: hashlib.md5(str.encode("".join([str(x) for x in row]))).hexdigest(),
)
melted_list.move_column("uid", 0)
output = melted_list

Expand Down

0 comments on commit 01ef28b

Please sign in to comment.