2 # -*- coding: utf-8 -*-
4 # Run this script to generate the comic .md files from the CSV files
5 # and put them into content/comic.
8 csvfile_main
= open('./comic_data.csv', newline
='')
9 if csvfile_main
== None:
10 print('Could not load main CSV file!')
16 csvfile
= open('./comic_data_'+lang
+'.csv', newline
='')
18 print('Could not load language CSV file!')
20 csvfiles_lang
[lang
] = csvfile
23 # Re-open main file to reset read/write pointer
24 # TODO: Properly use seek function...
25 csvfile_main
= open('./comic_data.csv', newline
='')
26 if csvfile_main
== None:
27 print('Could not re-open main CSV file!')
31 reader_main
= csv
.reader(csvfile_main
, delimiter
=',', quotechar
='"')
32 for row
in reader_main
:
37 # The version of the comic, in case a comic needs updating
38 # The first version is always 1 and is incremented later.
42 csvfile_lang
= csvfiles_lang
[lang
]
43 reader_lang
= csv
.reader(csvfile_lang
, delimiter
=',', quotechar
='"')
44 for row_lang
in reader_lang
:
45 _id_lang
= row_lang
[0]
46 if _id_main
== _id_lang
:
47 if (len(row_lang
) < 4):
48 print('Insufficient columns in line '+_id_main
+' (lang='+lang
+')')
53 authorComment
= row_lang
[3]
54 table
.append([_id_main
, topics
, creationDate
, publishDate
, version
, title
, altText
, authorComment
, series
])
60 topics_t
= topics
.replace("|", "\",\"")
62 topics_t
= "\"" + topics_t
+ "\""
68 authorComment
= row
[7]
71 if title
!= "___UNUSED___":
74 out
+= "weight= \"" + _id
+ "\"\n"
75 out
+= "title = \"" + title
+ "\"\n"
76 out
+= "topics = [" + topics_t
+ "]\n"
77 out
+= "series = \"" + series
+ "\"\n"
78 out
+= "creationDate = \"" + creationDate
+ "\"\n"
79 out
+= "date = \"" + publishDate
+ "\"\n"
80 out
+= "publishDate = \"" + publishDate
+ "\"\n"
81 out
+= "comic_version = \"" + version
+ "\"\n"
82 if altText
!= "" and altText
!= None:
83 out
+= "alt_text = \"" + altText
+ "\"\n"
84 if authorComment
!= "" and authorComment
!= None:
85 out
+= "author_comment = \"" + authorComment
+ "\"\n"
92 with
open("./content/comic/"+_id
+lang_tag
+".md", "w", encoding
='utf-8') as file: