-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalternate-series.py
60 lines (47 loc) · 1.83 KB
/
alternate-series.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
#!/usr/bin/python3
import sys
from comictagger_utils import *
from titleparsing import *
def main():
print(__name__)
filename = getFilename()
ca = getComicArchive(filename)
style = MetaDataStyle.CIX #ComicRack Style metadata
if ca.hasMetadata( style ):
md = ca.readMetadata( style )
print("{0} #{1} ({2})".format(md.series, md.issue, md.year))
print("Title={0}".format(md.title))
print("SA={0}".format(md.storyArc))
print("AS={0} #{1}".format(md.alternateSeries, md.alternateNumber))
#move story arc to Alternate series
#then process for numbers
if md.alternateSeries is None:
#don't overwrite non empty alternate series
md.alternateSeries = md.storyArc
md.storyArc = None
if md.title is not None or md.alternateSeries is not None:
SingleStoryArcFromTitle(md)
if md.alternateNumber is None:
print("no alternate Number found")
print("---After Modifications---")
print("SA={0}".format(md.storyArc))
print("AS={0} #{1}".format(md.alternateSeries, md.alternateNumber))
writeMetadata(md, ca, style)
else:
print("Comic archive does not have metadata", file=sys.stderr)
def SingleStoryArcFromTitle(metadata, overwrite = False):
config.LoadSettings()
books = []
books.append(metadata)
MultipleStoryArcsFromTitles(books,0)
#end SingleStoryArcFromTitle
def MultipleStoryArcsFromTitles(books,method_selected):
titleArray = makeTitleArray(books)
storyarcs = prefix_groups(titleArray,method_selected)
if storyarcs:
#invert dictionary, so book title is now the key, story arc the value
inv = InvertDictionary(storyarcs)
updateBooksAlternateSeries(books, inv, False)
#end MultipleStoryArcsFromTitles
if __name__ == '__main__':
main()