Skip to content
This repository has been archived by the owner on Mar 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #86 from Seluj78/feature/matching-files
Browse files Browse the repository at this point in the history
  • Loading branch information
Seluj78 authored Oct 14, 2020
2 parents 7487833 + 7681414 commit f95cc11
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion potodo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = """Jules Lasne"""
__email__ = "[email protected]"
__version__ = "0.16.0"
__version__ = "0.17.0"
18 changes: 17 additions & 1 deletion potodo/potodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def exec_potodo(
show_reservation_dates: bool,
no_cache: bool,
is_interactive: bool,
matching_files: bool,
) -> None:
"""
Will run everything based on the given parameters
Expand All @@ -97,6 +98,7 @@ def exec_potodo(
:param show_reservation_dates: Will show the reservation dates
:param no_cache: Disables cache (Cache is disabled when files are modified)
:param is_interactive: Switches output to an interactive CLI menu
:param matching_files: Should the file paths be printed instead of normal output
"""

cache_args = {
Expand Down Expand Up @@ -188,6 +190,7 @@ def exec_potodo(
exclude_reserved,
only_reserved,
show_reservation_dates,
matching_files,
)

# Once all files have been processed, print the dir and the files
Expand Down Expand Up @@ -225,6 +228,7 @@ def buffer_add(
exclude_reserved: bool,
only_reserved: bool,
show_reservation_dates: bool,
matching_files: bool,
) -> None:
"""Will add to the buffer the information to print about the file is
the file isn't translated entirely or above or below requested
Expand Down Expand Up @@ -274,7 +278,10 @@ def buffer_add(
filename = po_file_stats.filename
path = po_file_stats.path

if json_format:
if matching_files:
print(path)
return
elif json_format:

# the order of the keys is the display order
d = dict(
Expand Down Expand Up @@ -438,6 +445,15 @@ def main() -> None:
help="Activates the interactive menu",
)

parser.add_argument(
"-l",
"--matching-files",
action="store_true",
dest="matching_files",
help="Suppress normal output; instead print the name of each matching po file from which output would normally "
"have been printed.",
)

parser.add_argument(
"--version", action="version", version="%(prog)s " + __version__
)
Expand Down
1 change: 1 addition & 0 deletions tests/test_potodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"exclude_reserved": False,
"show_reservation_dates": False,
"no_cache": True,
"matching_files": False,
}


Expand Down
18 changes: 18 additions & 0 deletions tests/test_potodo_default_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,23 @@ def test_potodo_exclude_fuzzy(self):
not in output
)

def test_potodo_matching_files_solo(self):
output = check_output(["potodo", "--matching-files"]).decode("utf-8")
output_short = check_output(["potodo", "-l"]).decode("utf-8")
assert output == output_short
assert "excluded/file4.po" in output
assert "folder/excluded.po" in output
assert "folder/file3.po" in output
assert "file1.po" in output
assert "file2.po" in output

def test_potodo_matching_files_fuzzy(self):
output = check_output(["potodo", "--matching-files", "--only-fuzzy"]).decode(
"utf-8"
)
output_short = check_output(["potodo", "-l", "-f"]).decode("utf-8")
assert output == output_short
assert "file1.po" in output

# TODO: Test hide_reserved, offline options, only_reserved, exclude_reserved, show_reservation_dates
# TODO: Test verbose output levels

0 comments on commit f95cc11

Please sign in to comment.