mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 00:04:42 +04:00
Move PrefixedCommandRunner -> Prefix
This commit is contained in:
parent
c751f629a6
commit
7d87da8acd
23 changed files with 270 additions and 372 deletions
20
pre_commit/prefix.py
Normal file
20
pre_commit/prefix.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import os.path
|
||||
|
||||
|
||||
class Prefix(object):
|
||||
def __init__(self, prefix_dir):
|
||||
self.prefix_dir = prefix_dir.rstrip(os.sep) + os.sep
|
||||
|
||||
def path(self, *parts):
|
||||
path = os.path.join(self.prefix_dir, *parts)
|
||||
return os.path.normpath(path)
|
||||
|
||||
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)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue