update formatting
This commit is contained in:
28
materials.py
28
materials.py
@@ -20,10 +20,10 @@ VERSION = """\
|
||||
EPILOG = """\
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def list():
|
||||
def list_files():
|
||||
"""\
|
||||
List all materials
|
||||
"""
|
||||
from os import listdir
|
||||
|
||||
for data in listdir("./data"):
|
||||
@@ -31,24 +31,29 @@ def list():
|
||||
if file_name != "INFO":
|
||||
print(file_name)
|
||||
|
||||
|
||||
def read(input, search_keys=None):
|
||||
def read(input_file, search_keys=None):
|
||||
"""\
|
||||
Read json file
|
||||
"""
|
||||
import os
|
||||
import json
|
||||
from pprint import pprint
|
||||
|
||||
def find_values(id, json_repr):
|
||||
def find_values(key, json_repr):
|
||||
results = []
|
||||
|
||||
def _decode_dict(a_dict):
|
||||
try: results.append(a_dict[id])
|
||||
except KeyError: pass
|
||||
try:
|
||||
results.append(a_dict[key])
|
||||
except KeyError:
|
||||
pass
|
||||
return a_dict
|
||||
|
||||
json.loads(json_repr, object_hook=_decode_dict) # return value ignored
|
||||
return results
|
||||
|
||||
try:
|
||||
with open(os.path.join('data', input + '.json')) as data_file:
|
||||
with open(os.path.join('data', input_file + '.json')) as data_file:
|
||||
if search_keys is not None:
|
||||
data = data_file.read()
|
||||
for search_key in search_keys:
|
||||
@@ -76,7 +81,6 @@ def read(input, search_keys=None):
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
"""\
|
||||
Main function
|
||||
@@ -117,7 +121,7 @@ def main():
|
||||
print(args)
|
||||
|
||||
if args.command == 'list':
|
||||
list()
|
||||
list_files()
|
||||
|
||||
elif args.command == 'material':
|
||||
if args.const_collection:
|
||||
|
||||
Reference in New Issue
Block a user