Skip to content

Commit

Permalink
Merge pull request #28 from LuqueDaniel/rework-verbose
Browse files Browse the repository at this point in the history
Improves the cli messages
  • Loading branch information
LuqueDaniel authored Jul 27, 2021
2 parents 140250b + 22128ec commit 00caa50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions lnmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPLv3 (http://www.gnu.org/licenses/agpl-3.0-standalone.html)
"""lnmc
Allows to create symbolic link in batches from a YAML file and consolidate
Allows to create symbolic links in batches from a YAML file and consolidate
them in aspecific directory.
"""

Expand Down Expand Up @@ -50,19 +50,18 @@ def _symlink_create(self, src: pathlib.Path, dst: pathlib.Path) -> None:
"""
if dst.exists():
if dst.is_symlink():
cli.secho(f"Symbolic link already exists: {dst}", fg="cyan")
cli.secho(f"Symlink already exists: {dst}", fg="cyan")
else:
cli.secho(
f"The file or directory: {dst} already exists.",
f"File or directory: {dst} already exists.",
bold=True,
fg="red",
)
if not self.rewrite:
return
self._remove_item(dst)
elif self._is_broken_symlink(dst):
if self.verbose:
cli.secho(f"Symbolic link is broken: {dst} Unlinking", fg="yellow")
cli.secho(f"Symlink is broken: {dst}. Unlinking", fg="yellow")
self._remove_item(dst)

if self.verbose:
Expand Down Expand Up @@ -150,7 +149,7 @@ def yaml_read(yaml_file: str) -> dict:
def lnmc(
yaml_file: str, src: str, dst: str, copy: bool, rewrite: bool, verbose: bool
) -> None:
"""Allows to create symbolic link in batches from a YAML file and
"""Allows to create symbolic links in batches from a YAML file and
consolidate them in a specific directory.
The files, directories and sub-directories that are going to be targeted to
Expand Down
6 changes: 3 additions & 3 deletions tests/lnmc_symlink_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_symlink_create(files_setup, filesystem_actions, rewrite, capsys):
captured = capsys.readouterr()
if captured.out == f"Creating symlink: {dst}\n":
assert True
elif captured.out.startswith(f"Symbolic link already exists: {dst}"):
elif captured.out.startswith(f"Symlink already exists: {dst}"):
assert True
else:
assert False
Expand All @@ -35,7 +35,7 @@ def test_symlink_create_file_exists(files_setup, filesystem_actions, capsys):

captured = capsys.readouterr() # capture std/stderr
dst.unlink()
assert captured.out.startswith(f"The file or directory: {dst} already exists.")
assert captured.out.startswith(f"File or directory: {dst} already exists.")


@pytest.mark.parametrize(
Expand All @@ -50,4 +50,4 @@ def test_symlink_broken(files_setup, filesystem_actions, capsys, rewrite, file_)
filesystem_actions._symlink_create(src, dst)

captured = capsys.readouterr()
assert captured.out.startswith(f"Symbolic link is broken: {dst} Unlinking\n")
assert captured.out.startswith(f"Symlink is broken: {dst}. Unlinking\n")

0 comments on commit 00caa50

Please sign in to comment.