--- gentoolkit-0.2.1_rc2/src/equery/equery +++ gentoolkit-0.2.1_rc2/src/equery/equery @@ -278,7 +278,6 @@ def __init__(self): self.default_opts = { "category": "*", - "fullRegex": 0, "earlyOut": 0, "nameOnly": 0 } @@ -305,8 +304,6 @@ skip = 1 elif x in ["-e", "--earlyout"]: opts["earlyOut"] = 1 - elif x in ["-f", "--full-regex"]: - opts["fullRegex"] = 1 elif x in ["-n", "--name-only"]: opts["nameOnly"] = 1 else: @@ -321,16 +318,11 @@ def perform(self, args): (query, opts) = self.parseArgs(args) - if opts["fullRegex"]: - q = query - else: - q = map(lambda x: ((len(x) and x[0] == "/") and "^" or "/") - + re.escape(x) + "$", query) - try: - q = string.join(q, "|") - rx = re.compile(q) - except: - die(2, "The query '" + pp.regexpquery(q) + "' does not appear to be a valid regular expression") + q = map(os.path.split, query) + for c in q: + if len(c[0]) and c[0][0] != "/": + print_error("File names must be either include the full path or not include the path at all") + sys.exit(-1) # Pick out only selected categories cat = opts["category"] @@ -352,13 +344,16 @@ #cnt = pkg.get_contents() if not cnt: return for file in cnt.keys(): - if rx.search(file) and (opts["category"] == "*" or portage.catpkgsplit(pkg)[0] == opts["category"]): - if opts["nameOnly"]: - x = portage.catpkgsplit(pkg) - print x[0]+"/"+x[1] - else: - print pkg - return + if opts["category"] == "*" or portage.catpkgsplit(pkg)[0] == opts["category"]: + (dir, base) = os.path.split(file) + for c in q: + if base == c[1] and (c[0] == "" or dir == c[0] or os.path.samefile(dir, c[0])): + if opts["nameOnly"]: + x = portage.catpkgsplit(pkg) + print x[0]+"/"+x[1] + else: + print pkg + return class DummyExp: pass @@ -369,16 +364,19 @@ #cnt = pkg.get_contents() if not cnt: return for file in cnt.keys(): - if rx.search(file) and (opts["category"] == "*" or portage.catpkgsplit(pkg)[0] == opts["category"]): - if opts["nameOnly"]: - x = portage.catpkgsplit(pkg) - s = x[0]+"/"+x[1] - else: - s = pkg - s += " (" + pp.path(fileAsStr(file, cnt[file])) + ")" - print_info(0, s) - if opts["earlyOut"]: - raise DummyExp + if opts["category"] == "*" or portage.catpkgsplit(pkg)[0] == opts["category"]: + (dir, base) = os.path.split(file) + for c in q: + if base == c[1] and (c[0] == "" or dir == c[0] or os.path.samefile(dir, c[0])): + if opts["nameOnly"]: + x = portage.catpkgsplit(pkg) + s = x[0]+"/"+x[1] + else: + s = pkg + s += " (" + pp.path(fileAsStr(file, cnt[file])) + ")" + print_info(0, s) + if opts["earlyOut"]: + raise DummyExp try: if Config["piping"]: @@ -402,7 +400,6 @@ pp.localoption("") + " is either of: \n" + \ " " + pp.localoption("-c, --category cat") + " - only search in category " + \ pp.pkgquery("cat") + "\n" + \ - " " + pp.localoption("-f, --full-regex") + " - supplied query is a regex\n" + \ " " + pp.localoption("-e, --earlyout") + " - stop when first match is found\n" + \ " " + pp.localoption("-n, --name-only") + " - don't print the version."