MCPcopy Create free account
hub / github.com/Card-Forge/forge / processcards

Function processcards

forge-gui/tools/JapaneseTranslations.py:130–171  ·  view source on GitHub ↗
(cardfile, cur_set)

Source from the content-addressed store, hash-verified

128
129
130def processcards(cardfile, cur_set):
131 datafilename = f'ja-JP/{cur_set}.txt'
132 if not os.path.exists(datafilename):
133 if cur_set == 'CFX':
134 cur_set = 'CON'
135 card_data = urllib.request.urlopen(f'http://whisper.wisdom-guild.net/cardlist/{cur_set}.txt').read().decode('shift_jis')
136 with open(datafilename, 'w', encoding='utf8') as datafile:
137 datafile.write(card_data)
138 with open(datafilename, 'r', encoding='utf8') as datafile:
139 cardname = ''
140 jap_name = ''
141 jap_type = ''
142 jap_text = ''
143 text_mode = False
144 for line in datafile:
145 if line.startswith(' 英語名:'):
146 if text_mode is True:
147 text_mode = False
148 jap_text = jap_text.rstrip('\n')
149 writecard(cardfile, cardname, jap_name, jap_type, jap_text)
150 jap_name = ''
151 jap_type = ''
152 jap_text = ''
153 cardname = line[len(' 英語名:'):].rstrip('\n')
154 cardname = cardname.replace('AEther', 'Aether')
155 elif line.startswith('日本語名:'):
156 jap_name = line[len('日本語名:'):].rstrip('\n')
157 elif line.startswith(' タイプ:'):
158 jap_type = line[len(' タイプ:'):].rstrip('\n')
159 text_mode = True
160 elif line.startswith('イラスト:'):
161 text_mode = False
162 jap_text = jap_text.rstrip('\n')
163 writecard(cardfile, cardname, jap_name, jap_type, jap_text)
164 cardname = ''
165 jap_name = ''
166 jap_type = ''
167 jap_text = ''
168 elif line.startswith(' P/T:'):
169 continue
170 elif text_mode and not line.isspace():
171 jap_text += line
172
173
174def cleanfile(filename, extension1, extension2):

Callers 1

mainFunction · 0.85

Calls 5

writecardFunction · 0.85
writeMethod · 0.65
decodeMethod · 0.45
readMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected