Simplify prefix a bit

This commit is contained in:
Anthony Sottile 2018-01-13 15:53:22 -08:00
parent 06ee69b3cc
commit 8fb644e7c0
3 changed files with 15 additions and 34 deletions

View file

@ -12,5 +12,5 @@ install_environment = helpers.no_install
def run_hook(prefix, hook, file_args):
cmd = helpers.to_cmd(hook)
cmd = (prefix.prefix_dir + cmd[0],) + cmd[1:]
cmd = (prefix.path(cmd[0]),) + cmd[1:]
return xargs(cmd, file_args)

View file

@ -5,16 +5,14 @@ import os.path
class Prefix(object):
def __init__(self, prefix_dir):
self.prefix_dir = prefix_dir.rstrip(os.sep) + os.sep
self.prefix_dir = prefix_dir
def path(self, *parts):
path = os.path.join(self.prefix_dir, *parts)
return os.path.normpath(path)
return os.path.normpath(os.path.join(self.prefix_dir, *parts))
def exists(self, *parts):
return os.path.exists(self.path(*parts))
def star(self, end):
return tuple(
path for path in os.listdir(self.prefix_dir) if path.endswith(end)
)
paths = os.listdir(self.prefix_dir)
return tuple(path for path in paths if path.endswith(end))