From: Zac Medico Date: Sat, 20 Sep 2008 18:55:07 +0000 (-0000) Subject: As requested by jmbsvicetto, add support to StaticFileSet for sets within X-Git-Tag: v2.2_rc9~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=01b3ee6a8e47a1ce0c95bd5d4fec2ce38179c047;p=portage.git As requested by jmbsvicetto, add support to StaticFileSet for sets within subdirectories. This makes it possible to create a set name foo/bar by placing a file named bar inside a directory named foo. By allowing sets to be organized in subdirectories, it will allow us to avoid overcrowding as the number of sets grows. svn path=/main/trunk/; revision=11527 --- diff --git a/pym/portage/sets/files.py b/pym/portage/sets/files.py index e02c1e7b2..c9e71a332 100644 --- a/pym/portage/sets/files.py +++ b/pym/portage/sets/files.py @@ -7,7 +7,7 @@ import os import re from itertools import chain -from portage.util import grabfile, write_atomic, ensure_dirs +from portage.util import grabfile, write_atomic, ensure_dirs, normalize_path from portage.const import PRIVATE_PATH, USER_CONFIG_PATH from portage.locks import lockfile, unlockfile from portage import portage_gid @@ -123,12 +123,18 @@ class StaticFileSet(EditablePackageSet): except KeyError: raise SetConfigError("Could not find repository '%s'" % match.groupdict()["reponame"]) if os.path.isdir(directory): - for filename in os.listdir(directory): - if filename.endswith(".metadata"): - continue - myname = name_pattern.replace("$name", filename) - myname = myname.replace("${name}", filename) - rValue[myname] = StaticFileSet(os.path.join(directory, filename), greedy=greedy, dbapi=trees["vartree"].dbapi) + directory = normalize_path(directory) + for parent, dirs, files in os.walk(directory): + for filename in files: + if filename.endswith(".metadata"): + continue + filename = os.path.join(parent, + filename)[1 + len(directory):] + myname = name_pattern.replace("$name", filename) + myname = myname.replace("${name}", filename) + rValue[myname] = StaticFileSet( + os.path.join(directory, filename), + greedy=greedy, dbapi=trees["vartree"].dbapi) return rValue multiBuilder = classmethod(multiBuilder)