INNER CODE UNIT · Python
process_file
crocs-muni/JCAlgTest · AlgTest_JavaCard/preprocess_jcapi.py:12
def process_file(file_name, enable_api_map):
with open(file_name, 'r') as f:
lines = f.readlines()
output_lines = []
for line in lines:
output_line = line
for api in enable_api_map.keys():
if line.find(api) != -1:
# we found line with api to enable or disable
if enable_api_map[api]:
# make sure there is no '//' at the begin of the line
if line.startswith('//'):
output_line = line[2:]
else:
# add '//' at the beginning of line (if not already)
if not line.startswith('//'):
output_line = '//' + line