from pathlib import Path
import re,json
x=json.loads((Path(__file__).parent/'path-cases.json').read_text(encoding='utf-8'));reserved={'CON','PRN','AUX','NUL'}|{a+str(n) for a in ['COM','LPT'] for n in range(1,10)}|{a+n for a in ['COM','LPT'] for n in '¹²³'};r=[]
for path in x['names']:
 errors=[]
 for n in re.split(r'[\\/]',path):
  stem=n.split('.')[0].upper()
  if stem in reserved:errors.append('reserved_device_name')
  if n.endswith(('.', ' ')):errors.append('trailing_dot_or_space')
  if any(c in '<>:"|?*' or ord(c)<32 for c in n):errors.append('invalid_character')
 r.append({'path':path,'issues':errors})
assert not r[0]['issues'] and r[1]['issues'] and not r[7]['issues'] and r[8]['issues'];print(json.dumps(r,ensure_ascii=True,indent=2))
