Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'hotfix/1.0.2'

  • Loading branch information...
commit 175036a3ad8b8354aedbcdf0c589fd56960af273 2 parents 66dbe9f + 97dc972
@mathuin authored
Showing with 11 additions and 7 deletions.
  1. +4 −6 region.py
  2. +7 −1 utils.py
View
10 region.py
@@ -12,7 +12,7 @@
from time import sleep
import zipfile
import tarfile
-from utils import cleanmkdir
+from utils import cleanmkdir, locate
from terrain import Terrain
from pymclevel import mclevel
@@ -472,7 +472,8 @@ def buildvrts(self):
(compbase, compext) = os.path.splitext(compfile)
fullfile = os.path.join(layerdir, compfile)
datasubdir = os.path.join(layerdir, compbase)
- compimage = os.path.join(compbase, "%s.%s" % (compbase, iType))
+ # tar (at least) expects Unix pathnames
+ compimage = '/'.join([compbase, "%s.%s" % (compbase, iType)])
cleanmkdir(datasubdir)
if (Region.zipfileBroken == False):
if (cType == "tgz"):
@@ -493,10 +494,7 @@ def buildvrts(self):
os.rename(os.path.join(datasubdir, omfgcompimage), os.path.join(layerdir, compimage))
cFile.close()
vrtfile = '%s.vrt' % layerID
- #buildvrtcmd = 'gdalbuildvrt %s */*.%s >/dev/null' % (vrtfile, iType)
- # NB: make this work on Windows too!
- wildcard = '*'
- buildvrtcmd = 'gdalbuildvrt %s %s' % (vrtfile, os.path.join(wildcard, '%s.%s' % (wildcard, iType)))
+ buildvrtcmd = 'gdalbuildvrt %s %s' % (vrtfile, ' '.join(['"%s"' % x for x in locate('*.%s' % iType, layerdir)]))
os.system('cd %s && %s' % (layerdir, buildvrtcmd))
def getfiles(self):
View
8 utils.py
@@ -1,5 +1,5 @@
# utils module
-import os
+import os, fnmatch
import shutil
from memoize import memoize
from pymclevel.materials import alphaMaterials
@@ -51,3 +51,9 @@ def height(column):
retval = sum([pair[0] for pair in pairs])
return retval
+# http://code.activestate.com/recipes/499305-locating-files-throughout-a-directory-tree/
+def locate(pattern, root=os.curdir):
+ '''Locate all files matching supplied filename pattern in and below supplied root directory.'''
+ for path, dirs, files in os.walk(os.path.abspath(root)):
+ for filename in fnmatch.filter(files, pattern):
+ yield os.path.join(path, filename)
Please sign in to comment.
Something went wrong with that request. Please try again.