Skip to content

Commit

Permalink
bug fixes (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjelev authored May 24, 2024
1 parent b25293d commit ad6b240
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
import subprocess
import config

def safe_literal_eval(node):
try:
return ast.literal_eval(node)
except ValueError:
return None

def get_assignments(filename):
with open(filename) as f:
tree = ast.parse(f.read(), filename)

assignments = {node.targets[0].id: ast.literal_eval(node.value) for node in ast.walk(tree) if isinstance(node, ast.Assign)}
assignments = {node.targets[0].id: safe_literal_eval(node.value) for node in ast.walk(tree) if isinstance(node, ast.Assign)}
return assignments


Expand Down

0 comments on commit ad6b240

Please sign in to comment.