def check(filename): f = os.path.splitext(os.path.basename(files))[0] with codecs.open(files, mode='r', encoding='utf-8') as json_file: djson = json.load(json_file) update = False for entry in djson: te = entry["tr_explainLong"] je = entry["jp_explainLong"] an = entry["assign"] if te == "" or je.replace("\r\n", "\n") == te: continue c = remove_html_markup(te) if te in FS: continue ce = remove_html_markup(te) fc = "{}:{}:{}".format(f, an, ce) FS[fc] = _fonts.textlength(c) if (FS[fc] >= linelimit): ww = word_wrap(te, linelimit) FS[fc] = 0 ce = remove_html_markup(ww) fc = "{}:{}:{}".format(f, an, ce) FS[fc] = _fonts.textlength(ce) entry["tr_explainLong"] = ww update = True if (update): print("Updating {}".format(filename)) with codecs.open(filename, mode='w+', encoding='utf-8') as json_file: json.dump( djson, json_file, ensure_ascii=False, indent="\t", sort_keys=False) json_file.write("\n") return 1 return 0
def check(files): f = os.path.splitext(os.path.basename(files))[0] with codecs.open(files, mode='r', encoding='utf-8') as json_file: djson = json.load(json_file) for entry in djson: tt = entry["tr_text"] if tt == "": continue fc = "{}:{}".format(f, tt) FS[fc] = _fonts.textlength(tt)
def check(filename): f = os.path.splitext(os.path.basename(filename))[0] with codecs.open(filename, mode='r', encoding='utf-8') as json_file: djson = json.load(json_file) update = False for entry in djson: tt = entry["tr_text"] jt = entry["jp_text"] te = entry["tr_explain"] je = entry["jp_explain"] if tt == "": t = jt else: t = tt if te == "" or je == te: continue ce = remove_html_markup(te) fc = "{}:{}:{}".format(f, t, ce) FS[fc] = _fonts.textlength(ce) if (FS[fc] >= linelimit): ww = word_wrap(te, linelimit) FS[fc] = 0 ce = remove_html_markup(ww) fc = "{}:{}:{}".format(f, t, ce) FS[fc] = _fonts.textlength(ce) entry["tr_explain"] = ww update = True if (update): print("Updating {}".format(filename)) with codecs.open(filename, mode='w+', encoding='utf-8') as json_file: json.dump(djson, json_file, ensure_ascii=False, indent="\t", sort_keys=False) json_file.write("\n") return 1 return 0
def word_wrap(string, width=00.00): words = string.replace(" \n", " ").replace("\n", " ").split(" ") newstrings = [] current = "" wordi = 0 while True: current = "" lastgood = "" if len(words) == wordi: break while len(words) > wordi: current = current if (current == ""): current += words[wordi] else: current += " " + words[wordi] if (_fonts.textlength(remove_html_markup(current)) >= width): break lastgood = current wordi += 1 if (lastgood == "" and len(words) > wordi): lastgood = words[wordi] wordi += 1 if (lastgood != ""): newstrings.append(lastgood) warped = "\n".join(newstrings) return warped
os.path.join(dirpath, f) for dirpath, dirnames, files in os.walk(dir) for f in fnmatch.filter(files, 'Items_Leftovers.txt') ] if len(sys.argv) == 3 and sys.argv[2] != "0": _fonts.init(int(sys.argv[2])) else: _fonts.init() for files in items_files: with codecs.open(files, mode='r', encoding='utf-8') as json_file: djson = json.load(json_file) for entry in djson: t = entry["tr_explain"] j = entry["jp_explain"] if t == "" or j == t: continue FS[t] = _fonts.textlength(t) FSk = OrderedDict(sorted(FS.items(), key=lambda t: t[0])) FSs = OrderedDict(sorted(FSk.items(), key=lambda t: t[1])) if len(sys.argv) == 3: print(json.dumps(FSs, ensure_ascii=False, indent="\t", sort_keys=False)) else: for e in FSs: # JP MAX: 48.34 if FS[e] > 33: # MAX: ??? t = e.replace("\n", "<br>") print("Item Desc '{}' is too long: {}".format(t, FS[e]))
_fonts.init(int(sys.argv[2])) else: _fonts.init() for files in dice_files: with codecs.open(files, mode='r', encoding='utf-8') as json_file: djson = json.load(json_file) for entry in djson: te = entry["tr_patterns"] je = entry["jp_patterns"] for b in te: if (b == ""): continue if (b not in FS): continue FS[b] = _fonts.textlength(b) FSk = OrderedDict(sorted(FS.items(), key=lambda t: t[0])) FSs = OrderedDict(sorted(FSk.items(), key=lambda t: t[1])) FSER = OrderedDict((key, value) for key, value in FSs.items() if value > 21.58) if len(sys.argv) == 3: print(json.dumps(FSs, ensure_ascii=False, indent="\t", sort_keys=False)) else: # JP MAX: 31.12 for e, s in FSER.items(): # MAX: 41.7? t = e.replace("\r\n", "\\r\\n") counterr += 1 print("Dice SpeakText '{}' is too long: {}".format(t, s)) if counterr > 0:
out = out + c return out for files in chip_files: with codecs.open(files, mode='r', encoding='utf-8') as json_file: djson = json.load(json_file) for entry in djson: t = entry["tr_explainShort"] j = entry["jp_explainShort"] if t == "" or j == t: continue c = remove_html_markup(t) if (t in FS): continue FS[t] = _fonts.textlength(c) FSk = OrderedDict(sorted(FS.items(), key=lambda t: t[0])) FSs = OrderedDict(sorted(FSk.items(), key=lambda t: t[1])) if len(sys.argv) == 3: print(json.dumps(FSs, ensure_ascii=False, indent="\t", sort_keys=False)) else: # JP MAX: 36.79 FSEP = OrderedDict((key, value) for key, value in FSs.items() if value > 21.5) for e, s in FSEP.items(): counterr += 1 print("Chip Short explain '{}' is too big: {}".format(e, s)) # Disable error # counterr = -counterr
if len(sys.argv) == 3 and sys.argv[2] != "0": _fonts.init(int(sys.argv[2])) else: _fonts.init() for files in chip_files: with codecs.open(files, mode='r', encoding='utf-8') as json_file: djson = json.load(json_file) for entry in djson: t = entry["tr_text"] j = entry["jp_text"] if j == "" or j == "-": continue if j not in FS and False: FS[j] = _fonts.textlength(j) if t == "" or j == t: continue if t in FS: continue FS[t] = _fonts.textlength(t) for files in wpn_files: with codecs.open(files, mode='r', encoding='utf-8') as json_file: djson = json.load(json_file) for entry in djson: t = entry["tr_text"] j = entry["jp_text"] if j == "" or j == "-": continue if False: