Skip to content
Snippets Groups Projects
Commit 7b379c46 authored by Bensong Liu's avatar Bensong Liu
Browse files

Disallow `.` in ID string

parent 5478fa68
No related branches found
No related tags found
No related merge requests found
...@@ -23,9 +23,13 @@ import config, xlsx_conv, utils ...@@ -23,9 +23,13 @@ import config, xlsx_conv, utils
def main(): def main():
def contains_id(fname, _id): def contains_id(fname, _id):
s = xlsx_conv.read_as_csv(fname) try:
s = s.replace(' ', '').replace(',', '') s = xlsx_conv.read_as_csv(fname)
return s.find(_id) != -1 s = s.replace(' ', '').replace(',', '')
return s.find(_id) != -1
except:
# Catch PermissionError etc.
return False
if len(sys.argv) == 1: if len(sys.argv) == 1:
raise RuntimeError('Usage: drag a file into me...') raise RuntimeError('Usage: drag a file into me...')
......
...@@ -40,7 +40,7 @@ def npmat_truncate_cols(mat, max_cols): ...@@ -40,7 +40,7 @@ def npmat_truncate_cols(mat, max_cols):
def get_id_prefix_from_string(s): def get_id_prefix_from_string(s):
first_illegal_char_index = 0 first_illegal_char_index = 0
for i, c in enumerate(s.replace(' ', '')): for i, c in enumerate(s.replace(' ', '')):
if c not in 'QWERTYUIOPASDFGHJKLZXCVBNM1234567890qwertyuiopasdfghjklzxcvbnm.-': if c not in 'QWERTYUIOPASDFGHJKLZXCVBNM1234567890qwertyuiopasdfghjklzxcvbnm-':
break break
else: else:
first_illegal_char_index = i + 1 first_illegal_char_index = i + 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment