modified method to copy web_assets
This commit is contained in:
25
quadtree.py
25
quadtree.py
@@ -26,6 +26,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import util
|
import util
|
||||||
import cPickle
|
import cPickle
|
||||||
|
import stat
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
@@ -38,6 +39,26 @@ This module has routines related to generating a quadtree of tiles
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def mirror_dir(src, dst, entities=None):
|
||||||
|
'''copies all of the entities from src to dst'''
|
||||||
|
if not os.path.exists(dst):
|
||||||
|
os.mkdir(dst)
|
||||||
|
if entities and type(entities) != list: raise Exception("Expected a list, got a %r instead" % type(entities))
|
||||||
|
|
||||||
|
for entry in os.listdir(src):
|
||||||
|
if entities and entry not in entities: continue
|
||||||
|
if os.path.isdir(os.path.join(src,entry)):
|
||||||
|
mirror_dir(os.path.join(src, entry), os.path.join(dst, entry))
|
||||||
|
elif os.path.isfile(os.path.join(src,entry)):
|
||||||
|
try:
|
||||||
|
shutil.copy(os.path.join(src, entry), os.path.join(dst, entry))
|
||||||
|
except IOError:
|
||||||
|
# maybe permission problems?
|
||||||
|
os.chmod(os.path.join(src, entry), stat.S_IRUSR)
|
||||||
|
os.chmod(os.path.join(dst, entry), stat.S_IWUSR)
|
||||||
|
shutil.copy(os.path.join(src, entry), os.path.join(dst, entry))
|
||||||
|
# if this stills throws an error, let it propagate up
|
||||||
|
|
||||||
def iterate_base4(d):
|
def iterate_base4(d):
|
||||||
"""Iterates over a base 4 number with d digits"""
|
"""Iterates over a base 4 number with d digits"""
|
||||||
return itertools.product(xrange(4), repeat=d)
|
return itertools.product(xrange(4), repeat=d)
|
||||||
@@ -147,9 +168,7 @@ class QuadtreeGen(object):
|
|||||||
blank.save(os.path.join(tileDir, "blank."+self.imgformat))
|
blank.save(os.path.join(tileDir, "blank."+self.imgformat))
|
||||||
|
|
||||||
# copy web assets into destdir:
|
# copy web assets into destdir:
|
||||||
for root, dirs, files in os.walk(os.path.join(util.get_program_path(), "web_assets")):
|
mirror_dir(os.path.join(util.get_program_path(), "web_assets"), self.destdir)
|
||||||
for f in files:
|
|
||||||
shutil.copy(os.path.join(root, f), self.destdir)
|
|
||||||
|
|
||||||
if skipjs:
|
if skipjs:
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user