split up util.py into files.py and logger.py, moved code appropriately
This commit is contained in:
@@ -24,7 +24,7 @@ from PIL import Image
|
||||
|
||||
import world
|
||||
import util
|
||||
import overviewer_version
|
||||
from files import FileReplacer, mirror_dir
|
||||
|
||||
class AssetManager(object):
|
||||
"""\
|
||||
@@ -150,13 +150,13 @@ directory.
|
||||
global_assets = os.path.join(util.get_program_path(), "overviewer_core", "data", "web_assets")
|
||||
if not os.path.isdir(global_assets):
|
||||
global_assets = os.path.join(util.get_program_path(), "web_assets")
|
||||
util.mirror_dir(global_assets, self.outputdir)
|
||||
mirror_dir(global_assets, self.outputdir)
|
||||
|
||||
# create overviewer.js from the source js files
|
||||
js_src = os.path.join(util.get_program_path(), "overviewer_core", "data", "js_src")
|
||||
if not os.path.isdir(js_src):
|
||||
js_src = os.path.join(util.get_program_path(), "js_src")
|
||||
with util.FileReplacer(os.path.join(self.outputdir, "overviewer.js")) as tmpfile:
|
||||
with FileReplacer(os.path.join(self.outputdir, "overviewer.js")) as tmpfile:
|
||||
with open(tmpfile, "w") as fout:
|
||||
# first copy in js_src/overviewer.js
|
||||
with open(os.path.join(js_src, "overviewer.js"), 'r') as f:
|
||||
@@ -169,7 +169,7 @@ directory.
|
||||
|
||||
# write out config
|
||||
jsondump = json.dumps(dump, indent=4)
|
||||
with util.FileReplacer(os.path.join(self.outputdir, "overviewerConfig.js")) as tmpfile:
|
||||
with FileReplacer(os.path.join(self.outputdir, "overviewerConfig.js")) as tmpfile:
|
||||
with codecs.open(tmpfile, 'w', encoding='UTF-8') as f:
|
||||
f.write("var overviewerConfig = " + jsondump + ";\n")
|
||||
|
||||
@@ -179,9 +179,9 @@ directory.
|
||||
index = codecs.open(indexpath, 'r', encoding='UTF-8').read()
|
||||
index = index.replace("{title}", "Minecraft Overviewer")
|
||||
index = index.replace("{time}", time.strftime("%a, %d %b %Y %H:%M:%S %Z", time.localtime()).decode(locale.getpreferredencoding()))
|
||||
versionstr = "%s (%s)" % (overviewer_version.VERSION, overviewer_version.HASH[:7])
|
||||
versionstr = "%s (%s)" % (util.findGitVersion(), util.findGitHash()[:7])
|
||||
index = index.replace("{version}", versionstr)
|
||||
|
||||
with util.FileReplacer(indexpath) as indexpath:
|
||||
with FileReplacer(indexpath) as indexpath:
|
||||
with codecs.open(indexpath, 'w', encoding='UTF-8') as output:
|
||||
output.write(index)
|
||||
|
||||
Reference in New Issue
Block a user