summaryrefslogtreecommitdiff
path: root/indra/lib/python
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2012-02-10 16:45:18 -0500
committerNat Goodspeed <nat@lindenlab.com>2012-02-10 16:45:18 -0500
commitacd46062fd2edf4b45ab646cbacaf865b169ec30 (patch)
treed1d0582ae3e7e7b88ff9f6401fcb1f32630ff3bb /indra/lib/python
parent9011b04496796d7e51c20af0241ec05796e1ccac (diff)
Eliminate ManifestError for wildcards matching 0 files.
Turns out that some (many?) wildcard LLManifest.path(wildcard) calls are "just in case": sweep up any (e.g.) "*.tga" files there may be, but no problem if there are none. Change path() logic so it tries the next tree (source, artwork, build) if either a specific (non-wildcard) filename doesn't exist, as now, OR if a wildcard matches 0 files in the current tree. This continues to support "just in case" wildcards, while permitting wildcards to work in the artwork and build trees as well as the source tree. Use a more specific exception than ManifestError for missing file. Only in that case should we try the next tree. Any other ManifestError should propagate.
Diffstat (limited to 'indra/lib/python')
-rw-r--r--indra/lib/python/indra/util/llmanifest.py33
1 files changed, 22 insertions, 11 deletions
diff --git a/indra/lib/python/indra/util/llmanifest.py b/indra/lib/python/indra/util/llmanifest.py
index 237153b756..a4fb77357c 100644
--- a/indra/lib/python/indra/util/llmanifest.py
+++ b/indra/lib/python/indra/util/llmanifest.py
@@ -42,6 +42,11 @@ import errno
import subprocess
class ManifestError(RuntimeError):
+ """Use an exception more specific than generic Python RuntimeError"""
+ pass
+
+class MissingError(ManifestError):
+ """You specified a file that doesn't exist"""
pass
def path_ancestors(path):
@@ -604,16 +609,12 @@ class LLManifest(object):
def check_file_exists(self, path):
if not os.path.exists(path) and not os.path.islink(path):
- raise ManifestError("Path %s doesn't exist" % (os.path.abspath(path),))
+ raise MissingError("Path %s doesn't exist" % (os.path.abspath(path),))
wildcard_pattern = re.compile(r'\*')
def expand_globs(self, src, dst):
src_list = glob.glob(src)
- # Assume that if caller specifies a wildcard, s/he wants it to match
- # at least one file...
- if not src_list:
- raise ManifestError("Path %s doesn't exist" % (os.path.abspath(src),))
src_re, d_template = self.wildcard_regex(src.replace('\\', '/'),
dst.replace('\\', '/'))
for s in src_list:
@@ -646,13 +647,23 @@ class LLManifest(object):
else:
count += self.process_file(src, dst)
return count
- try:
- count = try_path(os.path.join(self.get_src_prefix(), src))
- except ManifestError:
+
+ for pfx in self.get_src_prefix(), self.get_artwork_prefix(), self.get_build_prefix():
try:
- count = try_path(os.path.join(self.get_artwork_prefix(), src))
- except ManifestError:
- count = try_path(os.path.join(self.get_build_prefix(), src))
+ count = try_path(os.path.join(pfx, src))
+ except MissingError:
+ # If src isn't a wildcard, and if that file doesn't exist in
+ # this pfx, try next pfx.
+ count = 0
+ continue
+
+ # Here try_path() didn't raise MissingError. Did it process any files?
+ if count:
+ break
+ # Even though try_path() didn't raise MissingError, it returned 0
+ # files. src is probably a wildcard meant for some other pfx. Loop
+ # back to try the next.
+
print "%d files" % count
def do(self, *actions):