-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pdfpath.py
executable file
·71 lines (58 loc) · 1.58 KB
/
Pdfpath.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#
# Pdfpath.py
#
# Purpose: provide PDF/path functions
#
# To call from littriageload:
# import Pdfpath
# pdfpath = Pdfpath.getPdfpath('/data/littriage', 'MGI:1095183')
#
# To test from command line ((output will be sent to standard out)
# python Pdfpath.py
#
# History
#
# 07/06/2017 lec
# - TR12250/Lit Triage
# 04/04/2019 jak
# - TR12763
import sys
import os
PROJECT_DIR_GROUPING = 1000
#
# Purpose: return pathname to the directory for a PDF based on the numeric
# part of the MGI:xxxx
#
def getPdfpath(parentpath, mgiID):
try:
prefix, numeric = mgiID.split(':')
numeric = int(numeric)
basepath = int(numeric / PROJECT_DIR_GROUPING) * PROJECT_DIR_GROUPING
return os.path.join( str(parentpath), str(basepath) )
except:
raise Exception('Failed to obtain pdf path: %s, %s' % (parentpath, mgiID))
if __name__ == '__main__':
#print 'MGI:'
#print getPdfpath('/data/littriage', 'MGI:')
#print ''
print ('MGI:1')
print (getPdfpath('/data/littriage', 'MGI:1'))
print ('')
print ('MGI:11')
print (getPdfpath('/data/littriage', 'MGI:11'))
print ('')
print ('MGI:111')
print (getPdfpath('/data/littriage', 'MGI:111'))
print ('')
print ('MGI:1111')
print (getPdfpath('/data/littriage/', 'MGI:1111'))
print ('')
print ('MGI:11111')
print (getPdfpath('/data/littriage/', 'MGI:11111'))
print ('')
print ('MGI:111111')
print (getPdfpath('/data/littriage/', 'MGI:111111'))
print ('')
print ('MGI:1111111')
print (getPdfpath('/data/littriage/', 'MGI:1111111'))
print ('')