-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathextract-external-links.py
executable file
·43 lines (34 loc) · 1.15 KB
/
extract-external-links.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
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import sys
from zipfile import ZipFile
from extractor import KPP
from bundle import Bundle
def process(filename, rtypes=None):
if not rtypes:
rtypes = ['requiredBrushFile']
def process_kpp(kpp, bundle=None):
links = kpp.get_links()
for name, value in links.iteritems():
if bundle is not None:
if name not in rtypes:
continue
if name == 'requiredBrushFile':
ok = bundle.find_brush(value)
if ok:
print("required brush file {} found in the same bundle.".format(value))
continue
if not value:
continue
print(u"{}: {}".format(name, value).encode('utf-8'))
if filename.endswith(".bundle"):
bundle = Bundle.open(filename)
presets = bundle.presets_data
else:
bundle = None
presets = [KPP(filename)]
for preset in presets:
process_kpp(preset, bundle)
for fname in sys.argv[1:]:
print(u"Processing: {}".format(fname))
process(fname)