mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Simplify prefix a bit
This commit is contained in:
parent
06ee69b3cc
commit
8fb644e7c0
3 changed files with 15 additions and 34 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue