Improve parsing of job IDs

This commit is contained in:
Jose Gracia 2024-02-15 11:06:54 +01:00
parent a5435e65dc
commit 11f334d2b4

View file

@ -25,7 +25,8 @@ def parse_jobid(s):
import re
hawkpbs = r'.hawk-pbs5'
jobid = re.sub(hawkpbs, '', s)
if not jobid.isdigit():
not_allowed = r'[^0-9\[\]]' # Jobid can be more complex than just digits, eg 2444420[201]
if re.search(not_allowed, jobid):
raise argparse.ArgumentTypeError(f'invalid job ID "{s}"')
return jobid