Make it easier to exclude directories for VCSes from resource trees.
This commit is contained in:
parent
64ad6085c0
commit
ee929c7ef2
1 changed files with 5 additions and 2 deletions
|
@ -8,6 +8,7 @@ import sys, os, re, sre_constants, hashlib, glob, gzip
|
|||
map_extensions = ("map", "mask")
|
||||
image_extensions = ("png", "jpg", "jpeg")
|
||||
sound_extensions = ("ogg", "wav")
|
||||
vc_directories = (".git", ".svn")
|
||||
resource_extensions = map_extensions + image_extensions + sound_extensions
|
||||
image_reference = r"[A-Za-z0-9{}.][A-Za-z0-9_/+{}.-]*\.(png|jpg)(?=(~.*)?)"
|
||||
|
||||
|
@ -74,7 +75,7 @@ def parse_attribute(line):
|
|||
class Forest:
|
||||
"Return an iterable directory forest object."
|
||||
def __init__(self, dirpath, exclude=None):
|
||||
"Get the names of all files under dirpath, ignoring .svn and .git directories."
|
||||
"Get the names of all files under dirpath, ignoring version-control directories."
|
||||
self.forest = []
|
||||
self.dirpath = dirpath
|
||||
for dir in dirpath:
|
||||
|
@ -88,7 +89,9 @@ class Forest:
|
|||
self.forest.append(subtree)
|
||||
for i in range(len(self.forest)):
|
||||
# Ignore version-control subdirectories and Emacs tempfiles
|
||||
self.forest[i] = filter(lambda x: ".svn" not in x and ".git" not in x and '.#' not in x, self.forest[i])
|
||||
for dirkind in vc_directories:
|
||||
self.forest[i] = filter(lambda x: dirkind not in x, self.forest[i])
|
||||
self.forest[i] = filter(lambda x: '.#' not in x, self.forest[i])
|
||||
self.forest[i] = filter(lambda x: not os.path.isdir(x), self.forest[i])
|
||||
if exclude:
|
||||
self.forest[i] = filter(lambda x: not re.search(exclude, x), self.forest[i])
|
||||
|
|
Loading…
Add table
Reference in a new issue