forked from AFPy/potodo
Added potodo ignore support
This commit is contained in:
parent
5654ce2dc4
commit
f48d185901
1
.potodoignore
Normal file
1
.potodoignore
Normal file
|
@ -0,0 +1 @@
|
|||
venv/*
|
21
potodo/ignore.py
Normal file
21
potodo/ignore.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
from pathlib import Path
|
||||
from fnmatch import fnmatch
|
||||
|
||||
|
||||
def get_ignore_content(repo_path: Path, file=".potodoignore"):
|
||||
file_path = repo_path / file
|
||||
if not file_path.exists():
|
||||
return []
|
||||
with open(file_path, "r") as handle:
|
||||
lines = handle.readlines()
|
||||
ignore_pattern_set = set(lines)
|
||||
excluded_path_list = []
|
||||
for path in repo_path.rglob('*'):
|
||||
if path.is_file() and path != file_path:
|
||||
for ignore_pattern in ignore_pattern_set:
|
||||
relative_path = path.relative_to(repo_path)
|
||||
if fnmatch(relative_path, ignore_pattern):
|
||||
# add in excludd list
|
||||
excluded_path_list.append(path)
|
||||
return excluded_path_list
|
||||
|
|
@ -22,7 +22,7 @@ from potodo.po_file import PoFileStats
|
|||
from potodo.arguments_handling import check_args
|
||||
from potodo.json import json_dateconv
|
||||
from potodo.logging import setup_logging
|
||||
|
||||
from potodo.ignore import get_ignore_content
|
||||
|
||||
def print_dir_stats(
|
||||
directory_name: str,
|
||||
|
@ -98,6 +98,9 @@ def exec_potodo(
|
|||
:param is_interactive: Switches output to an interactive CLI menu
|
||||
"""
|
||||
|
||||
ignore_file_content = get_ignore_content(repo_path=path)
|
||||
exclude.extend(ignore_file_content)
|
||||
|
||||
# Initialize the arguments
|
||||
issue_reservations = get_issue_reservations(offline, hide_reserved, path)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user