Skip to content

Commit

Permalink
media magic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
e3rd committed Jan 8, 2025
1 parent 7ee56cf commit 32b10b9
Show file tree
Hide file tree
Showing 25 changed files with 235 additions and 383 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
- name: Install dependencies
run: pip install -e .
- name: Run tests
run: python3 tests.py
run: python3 -m unittest discover tests
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<p align="center">
<img src="./asset/logo.jpg" />
</p>
<p align="center">Deduplicator that covers your back.</p>

[![Build Status](https://github.com/CZ-NIC/deduplidog/actions/workflows/run-unittest.yml/badge.svg)](https://github.com/CZ-NIC/deduplidog/actions)

Yet another file deduplicator.

- [About](#about)
* [What are the use cases?](#what-are-the-use-cases)
Expand Down Expand Up @@ -133,7 +137,7 @@ You face a directory that might contain some images twice. Let's analyze. We tur
```
$ deduplidog --work-dir ~/shuffled/ --media-magic --ignore-name --skip-bigger --log-level=20
Only files with media suffixes are taken into consideration. Nor the size nor the date is compared. Nor the name!
Duplicates from the work dir at 'shuffled' (only if smaller than the pair file) would be (if execute were True) left intact (because no action is selected).
Duplicates from the work dir at 'shuffled' (only if smaller than the pair file) would be (if execute were True) left intact (because no action is selected, nothing will happen).
Number of originals: 9
Caching image hashes: 100%|███████████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:00<00:00, 16.63it/s]
Expand Down
Binary file added asset/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions deduplidog/__main__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import sys

from mininterface import run
from mininterface import Cancelled, run

from .deduplidog import Deduplidog


def main():
# NOTE: I'd like to have the default in case work dir is not specified args=("--work-dir", str(Path.cwd()))
# Currently, args overthrows CLI arguments.
with run(Deduplidog, interface=None) as m:
# with run(Deduplidog, interface="tui") as m:
# m = run(Deduplidog, interface="gui")
# if 1:
# m.facet._layout # TODO
try:
while True:
print("")
Expand All @@ -23,6 +21,8 @@ def main():
# deduplidog.perform()
# else:
m.env.start(m)
except Cancelled:
continue
except Exception as e:
print("-"*100)
print(e)
Expand Down
15 changes: 0 additions & 15 deletions deduplidog/cli.py

This file was deleted.

5 changes: 3 additions & 2 deletions deduplidog/deduplidog.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class Deduplidog:
media: OmitArgPrefixes[Media]
helper: OmitArgPrefixes[Helper]

work_dir: Path
work_dir: Path = Path.cwd()
"""Folder of the files suspectible to be duplicates."""

original_dir: Path | None = None
Expand Down Expand Up @@ -255,6 +255,7 @@ def start(self, interface=None):
self.reset()
self.check()
self.perform()
return self

def perform(self):
# build file list of the originals
Expand Down Expand Up @@ -406,7 +407,7 @@ def check(self):
def _get_action(self, passive=False):
action = self.action.rename, self.action.replace_with_original, self.action.delete, self.action.replace_with_symlink
if not sum(action):
return f"{'left' if passive else 'leave'} intact (because no action is selected)"
return f"{'left' if passive else 'leave'} intact (because no action is selected, nothing will happen)"
elif sum(action) > 1:
raise AssertionError("Choose only one execute action (like only rename).")
elif self.action.rename:
Expand Down
10 changes: 0 additions & 10 deletions deduplidog/form.tcss

This file was deleted.

65 changes: 0 additions & 65 deletions deduplidog/tui.py

This file was deleted.

184 changes: 0 additions & 184 deletions tests.py

This file was deleted.

Loading

0 comments on commit 32b10b9

Please sign in to comment.