Skip to content

Commit

Permalink
hide submit button
Browse files Browse the repository at this point in the history
  • Loading branch information
e3rd committed Oct 24, 2024
1 parent 3dd66bb commit e8401bf
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 42 deletions.
42 changes: 8 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,53 +21,27 @@ pip install touch-timestamp

## Methods to set the date

When invoked with file paths, the program sets their modification times
When invoked with file paths, you choose whether to set their modification times
* to the specified time
* to the date from the Exif through [jhead](https://github.com/Matthias-Wandel/jhead)
* to a name auto-detected from the file name, ex: `IMG_20240101_010053.jpg``2024-01-01 01:00:53`
* to a relative time
* to the specific time, set for a file, then shifts all the other relative to this

![Gui window](asset/mininterface-gui-full.avif "Graphical interface")

## Fetch the time from the file name

Should you end up with files that keep the date in the file name, use the `--from-name` parameter.
## Full help

```bash
$ touch-timestamp 20240828_160619.heic --from-name True
Changed 2001-01-01T12:00:00 → 2024-08-28T16:06:19: 20240828_160619.heic
```
Everything can be achieved via CLI flag. See the `--help`.

## Full help
Let's take fetching the time from the file name as an example.

Use the `--help` to see full options.
Should you end up with files that keep the date in the file name, use the `--from-name` parameter. In the help, you see that True trigger an automatic detection of the time and date format.

```bash
$ touch-timestamp --help
usage: Touch [-h] [--eel | --no-eel] [--from-name {True,False}|STR]
[[PATH [PATH ...]]]

╭─ positional arguments ─────────────────────────────────────────────────────╮
│ [[PATH [PATH ...]]] │
│ Files the modification date is to be changed. (default: ) │
╰────────────────────────────────────────────────────────────────────────────╯
╭─ options ──────────────────────────────────────────────────────────────────╮
│ -h, --help │
│ show this help message and exit
│ --eel, --no-eel │
│ Prefer Eel GUI. (Set the date as in a chromium browser.) │
│ Does not allow setting from EXIF and relative set. (default: False) │
│ --from-name {True,False}|STR │
│ Fetch the modification time from the file names stem. Set the format │
│ as for `datetime.strptime` like '%Y%m%d_%H%M%S'. │
│ If set to True, the format will be auto-detected. │
│ If a file name does not match the format or the format cannot be │
│ auto-detected, the file remains unchanged. │
│ │
│ │
│ Ex: `--from-name True 20240827_154252.heic` → modification time = │
│ 27.8.2024 15:42 (default: False) │
╰────────────────────────────────────────────────────────────────────────────╯
$ touch-timestamp 20240828_160619.heic --from-name True
Changed 2001-01-01T12:00:00 → 2024-08-28T16:06:19: 20240828_160619.heic
```


Expand Down
Binary file modified asset/mininterface-gui-full.avif
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "touch-timestamp"
version = "0.3.7"
version = "0.3.8"
description = "Change file timestamps with a dialog window."
authors = ["Edvard Rejthar <edvard.rejthar@nic.cz>"]
license = "GPL-3.0-or-later"
Expand Down
4 changes: 2 additions & 2 deletions touch_timestamp/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def from_name(self):
for p in e.files:
if e.from_name is True: # auto detection
try:
# 20240828_160619.heic -> "20240828 160619" -> "28.8."
# IMG_20240101_010053.jpg -> "1.1."
# 20240828_160619.heic -> "20240828 160619" -> "2024-08-28 16:06:19"
# IMG_20240101_010053.jpg -> "2024-01-01 01:00:53"
dt = dateutil.parser.parse(p.stem.replace("IMG_", "").replace("_", " "))
except ValueError:
print(f"Cannot auto detect the date format: {p}")
Expand Down
7 changes: 2 additions & 5 deletions touch_timestamp/touch_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
from .env import Env
from .utils import get_date

# TODO update docs, add tests
# NOTE add tests for CLI flags


def main():
# NOTE TUI is not great due to the Mininterface sections mostly ignored
# It does not end after a button is clicked.
m = run(Env, prog="Touch")

if m.env.files is MISSING or not len(m.env.files):
Expand Down Expand Up @@ -61,8 +59,7 @@ def main():
"Set": controller.referenced_shift
}

# TODO hide submit button, so that enter submits current button
m.form(form, title)
m.form(form, title, submit=False)


if __name__ == "__main__":
Expand Down

0 comments on commit e8401bf

Please sign in to comment.