comparison bin/plinks.py @ 4:462179da7dc2

try harder not to write empty links files
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Wed, 19 Feb 2020 10:39:05 +0000
parents 83ed7c5846b2
children a28d731977da
comparison
equal deleted inserted replaced
2:83ed7c5846b2 4:462179da7dc2
11 with open('/dev/shm/x/badpdfs_%s'%me,'w') as bf: 11 with open('/dev/shm/x/badpdfs_%s'%me,'w') as bf:
12 for l in sys.stdin: 12 for l in sys.stdin:
13 (fno,f)=l.rstrip().split() 13 (fno,f)=l.rstrip().split()
14 try: 14 try:
15 links=run(f) 15 links=run(f)
16 with open('/dev/shm/x/links_%s'%fno,'w') as of: 16 if bool(links) and (links.get('scrape',False) or
17 for k in links.keys(): 17 links.get('annot',False)):
18 for l in links[k]: 18 with open('/dev/shm/x/links_%s'%fno,'w') as of:
19 print("%s\t%s"%(k,l),file=of) 19 for k in links.keys():
20 for l in links[k]:
21 print("%s\t%s"%(k,l),file=of)
20 except Exception as e: 22 except Exception as e:
21 print("%s\t%s"%(fno,e),file=bf) 23 print("%s\t%s"%(fno,e),file=bf)
22 if (path.exists('/dev/shm/stopJob')): 24 if (path.exists('/dev/shm/stopJob')):
23 print("Quiting early: %s %s"%(me,fno),file=sys.stderr) 25 print("Quiting early: %s %s"%(me,fno),file=sys.stderr)
24 exit(1) 26 exit(1)