-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconf_fb.py
51 lines (36 loc) · 1.11 KB
/
conf_fb.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
# franko b config
from opex.util import AssetInfo
import re
from os.path import exists
GET_ID_EXT = re.compile(r'((FB(?:-\d+)+)-\d\d\d+)\.([0-9a-zA-Z_]+)$')
CONTAINER = 'opex_wildfilm'
def to_calm_id(name):
# CALM ids user forward slash, not dash
return name
#return re.sub('-', '/', name)
def get_info_for_file(path):
match = GET_ID_EXT.search(path)
if not match:
return None, None
parent, asset_id, ext = match.group(2), match.group(1), match.group(3)
if ext in ['md5']:
# Not a file type we care about
return None, None
md5file = path.replace(ext, 'md5')
if exists(md5file):
fixity_type = 'MD5'
fixity = open(md5file, 'r').read()
else:
fixity_type = None
fixity = None
# Map names to ids
target = [(name, to_calm_id(name)) for name in [parent, asset_id]]
info = AssetInfo(
filename=asset_id + '.' + ext,
asset_id=to_calm_id(asset_id),
source_path=path,
is_access="Preservica_access" in path,
fixity_type=fixity_type,
fixity=fixity
)
return target, info