From b174bf9968e8ffd69ea850a0bc5566571a48be80 Mon Sep 17 00:00:00 2001 From: Vladimir Chebotarev Date: Sun, 28 Aug 2022 11:08:21 +0300 Subject: [PATCH] Few renames. --- gitignorefile/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gitignorefile/__init__.py b/gitignorefile/__init__.py index f5f237a..d6eb352 100644 --- a/gitignorefile/__init__.py +++ b/gitignorefile/__init__.py @@ -19,7 +19,7 @@ def parse(path, base_path=None): # We have negation rules. We can't use a simple "any" to evaluate them. # Later rules override earlier rules. - return lambda file_path, is_dir=None: _handle_negation(file_path, rules, base_path=base_path, is_dir=is_dir) + return lambda file_path, is_dir=None: _match_rules(file_path, rules, base_path=base_path, is_dir=is_dir) def ignore(): @@ -89,7 +89,7 @@ def __call__(self, path, is_dir=None): ) # This parent comes either from first or second loop. -def _handle_negation(file_path, rules, base_path=None, is_dir=None): +def _match_rules(path, rules, base_path=None, is_dir=None): """ Because Git allows for nested `.gitignore` files, a `base_path` value is required for correct behavior. @@ -97,12 +97,12 @@ def _handle_negation(file_path, rules, base_path=None, is_dir=None): return_immediately = not any((r.negation for r in rules)) if is_dir is None: - is_dir = os.path.isdir(file_path) + is_dir = os.path.isdir(path) if base_path is not None: - rel_path = os.path.relpath(file_path, base_path) + rel_path = os.path.relpath(path, base_path) else: - rel_path = file_path + rel_path = path if rel_path.startswith(f".{os.sep}"): rel_path = rel_path[2:]