edir 2.30__tar.gz → 2.31__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
edir-2.31/Makefile ADDED
@@ -0,0 +1,24 @@
1
+ NAME = $(shell basename $(CURDIR))
2
+ PYFILES = $(NAME).py
3
+
4
+ check::
5
+ ruff check $(PYFILES)
6
+ mypy $(PYFILES)
7
+ pyright $(PYFILES)
8
+ vermin -vv --no-tips -i $(PYFILES)
9
+
10
+ build::
11
+ rm -rf dist
12
+ uv build
13
+
14
+ upload:: build
15
+ uv-publish
16
+
17
+ doc::
18
+ update-readme-usage
19
+
20
+ format::
21
+ ruff check --select I --fix $(PYFILES) && ruff format $(PYFILES)
22
+
23
+ clean::
24
+ @rm -vrf *.egg-info .venv/ build/ dist/ __pycache__/
@@ -1,9 +1,9 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: edir
3
- Version: 2.30
3
+ Version: 2.31
4
4
  Summary: Utility to rename, remove, and copy files/dirs using your editor
5
5
  Author-email: Mark Blakeney <mark.blakeney@bullet-systems.net>
6
- License: GPLv3
6
+ License-Expression: GPL-3.0-or-later
7
7
  Project-URL: Homepage, https://github.com/bulletmark/edir
8
8
  Keywords: vidir,git,trash,trash-put,thrash-d
9
9
  Classifier: Programming Language :: Python :: 3
@@ -15,7 +15,7 @@ Requires-Dist: platformdirs
15
15
  [![PyPi](https://img.shields.io/pypi/v/edir)](https://pypi.org/project/edir/)
16
16
  [![AUR](https://img.shields.io/aur/version/edir)](https://aur.archlinux.org/packages/edir/)
17
17
 
18
- [edir][edir] is a command line utility to rename, remove, and copy
18
+ [`edir`][edir] is a command line utility to rename, remove, and copy
19
19
  filenames and directories using your text editor. Run it in the current
20
20
  directory and `edir` will open your editor on a list of files and
21
21
  directories in that directory. Each item in the directory will appear on
@@ -34,7 +34,7 @@ https://github.com/bulletmark/edir.
34
34
 
35
35
  ## Advantages Compared to Vidir
36
36
 
37
- [edir][edir] unashamedly mimics the functionality of the
37
+ [`edir`][edir] unashamedly mimics the functionality of the
38
38
  [vidir](https://linux.die.net/man/1/vidir) utility from
39
39
  [moreutils](https://joeyh.name/code/moreutils/) but aims to improve it
40
40
  in the following ways:
@@ -132,7 +132,7 @@ in the following ways:
132
132
  edit to all depths (or use a large positive number).
133
133
 
134
134
  15. `edir` adds a [`-t/--trash` option](#using-trash) to remove to your
135
- [Trash](https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html).
135
+ [Trash][trash].
136
136
  By default this option invokes
137
137
  [`trash-put`](https://www.mankier.com/1/trash-put) from the
138
138
  [trash-cli](https://github.com/andreafrancia/trash-cli) package to
@@ -247,14 +247,12 @@ default option off temporarily and re-enable git functionality.
247
247
 
248
248
  ## Using Trash
249
249
 
250
- Given how easy `edir` facilitates deleting files, some users may prefer
251
- to remove them to system
252
- [Trash](https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html)
253
- from where they can be later listed and/or recovered. Specifying
254
- `-t/--trash` does this by executing the
250
+ Given how easy `edir` facilitates deleting files, some users may prefer to
251
+ remove them to system [Trash][trash] from where they can be later listed and/or
252
+ recovered. Specifying `-t/--trash` does this by executing the
255
253
  [`trash-put`](https://www.mankier.com/1/trash-put) command, from the
256
- [`trash-cli`](https://github.com/andreafrancia/trash-cli) package, to
257
- remove files rather than removing them natively.
254
+ [`trash-cli`](https://github.com/andreafrancia/trash-cli) package, to remove
255
+ files rather than removing them natively.
258
256
 
259
257
  You may want to set `-t/--trash` as a default option. If you do so then
260
258
  you can use `-T` on the command line to turn that default option off
@@ -272,7 +270,7 @@ want to set this as a [default option](#command-default-options).
272
270
  Many users would like to see a preview of changes after they finish
273
271
  editing but before they are actioned by `edir`, i.e. to confirm exactly
274
272
  which files/dirs will be deleted, renamed, or copied. Add the
275
- `-i/--interactive` option and edir will present a list of changes and
273
+ `-i/--interactive` option and `edir` will present a list of changes and
276
274
  prompt you to continue, or allow you to re-edit the path list etc.
277
275
  Consider setting `--interactive` as a [default
278
276
  option](#command-default-options) so you are always prompted.
@@ -297,18 +295,24 @@ Python 3.8 or later is required. Arch Linux users can install [`edir`
297
295
  from the AUR](https://aur.archlinux.org/packages/edir) and skip this
298
296
  section.
299
297
 
300
- The easiest way to install `edir` is to use [`pipx`][pipx] (or
301
- [`pipxu`][pipxu], or [`uv tool`][uvtool]) which installs [`edir` from
302
- PyPi][edirpy]. To install:
298
+ Note [`edir` is on PyPI](https://pypi.org/project/edir/) so the easiest
299
+ way to install it is to use [`uv tool`][uvtool] (or [`pipx`][pipx] or
300
+ [`pipxu`][pipxu]).
303
301
 
304
- ```
305
- $ pipx install edir
302
+ ```sh
303
+ $ uv tool install edir
306
304
  ```
307
305
 
308
306
  To upgrade:
309
307
 
308
+ ```sh
309
+ $ uv tool upgrade edir
310
310
  ```
311
- $ pipx upgrade edir
311
+
312
+ To uninstall:
313
+
314
+ ```sh
315
+ $ uv tool uninstall edir
312
316
  ```
313
317
 
314
318
  [Git](https://git-scm.com/) must be installed if you want to use the git
@@ -374,9 +378,9 @@ Type `edir -h` to view the usage summary:
374
378
 
375
379
  ```
376
380
  usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
377
- [-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH]
378
- [-F | -D] [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z]
379
- [--suffix SUFFIX] [-V]
381
+ [-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
382
+ -D] [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z] [--suffix SUFFIX]
383
+ [-V]
380
384
  [args ...]
381
385
 
382
386
  Program to rename, remove, or copy files and directories using your editor.
@@ -406,8 +410,7 @@ options:
406
410
  -c, --no-color do not color rename/remove/copy messages
407
411
  -C, --no-invert-color
408
412
  do not invert the color to highlight error messages
409
- -d DEPTH, --depth DEPTH
410
- edit paths to specified depth, default=1
413
+ -d, --depth DEPTH edit paths to specified depth, default=1
411
414
  -F, --files only show/edit files
412
415
  -D, --dirs only show/edit directories
413
416
  -L, --nolinks ignore all symlinks
@@ -424,19 +427,19 @@ options:
424
427
  -V, --version show edir version
425
428
 
426
429
  Note you can set default starting options in $HOME/.config/edir-
427
- flags.conf. The negation options (i.e. the --no-* options and their
428
- shortforms) allow you to temporarily override your defaults.
430
+ flags.conf. The negation options (i.e. the --no-* options) allow you to
431
+ temporarily override your defaults.
429
432
  ```
430
433
 
431
434
  ## Embed in Ranger File Manager
432
435
 
433
- In many ways `edir` (and `vidir`) is better than the
434
- [ranger](https://ranger.github.io/) terminal file manager
435
- [bulkrename](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
436
- command which does not handle name swaps and clashes etc. To add `edir`
437
- as a command within [ranger](https://ranger.github.io/), add or create
438
- the following in `~/.config/ranger/commands.py`. Then run it from within
439
- [ranger](https://ranger.github.io/) by typing `:edir`.
436
+ In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
437
+ terminal file manager
438
+ [`bulkrename`](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
439
+ command which does not handle name swaps and clashes etc. To add `edir` as a
440
+ command within [`ranger`][ranger], add or create the following in
441
+ `~/.config/ranger/commands.py`. Then run it from within [`ranger`][ranger] by
442
+ typing `:edir`.
440
443
 
441
444
  ```python
442
445
  from ranger.api.commands import Command
@@ -454,8 +457,10 @@ class edir(Command):
454
457
  return self._tab_directory_content()
455
458
  ```
456
459
 
457
- Note if you use [yazi](https://yazi-rs.github.io/) for your file manager
458
- you don't need any special configuration in `yazi`. Just type `:edir`.
460
+ ## Use with Yazi File Manager
461
+
462
+ If you use [`yazi`][yazi] for your file manager then you don't need any special
463
+ configuration. Just type `:edir` from within [`yazi`][yazi].
459
464
 
460
465
  ## License
461
466
 
@@ -474,5 +479,8 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at
474
479
  [pipx]: https://github.com/pypa/pipx
475
480
  [pipxu]: https://github.com/bulletmark/pipxu
476
481
  [uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
482
+ [ranger]: https://ranger.github.io/
483
+ [yazi]: https://yazi-rs.github.io/
484
+ [trash]: https://specifications.freedesktop.org/trash-spec/1.0/
477
485
 
478
486
  <!-- vim: se ai syn=markdown: -->
@@ -2,7 +2,7 @@
2
2
  [![PyPi](https://img.shields.io/pypi/v/edir)](https://pypi.org/project/edir/)
3
3
  [![AUR](https://img.shields.io/aur/version/edir)](https://aur.archlinux.org/packages/edir/)
4
4
 
5
- [edir][edir] is a command line utility to rename, remove, and copy
5
+ [`edir`][edir] is a command line utility to rename, remove, and copy
6
6
  filenames and directories using your text editor. Run it in the current
7
7
  directory and `edir` will open your editor on a list of files and
8
8
  directories in that directory. Each item in the directory will appear on
@@ -21,7 +21,7 @@ https://github.com/bulletmark/edir.
21
21
 
22
22
  ## Advantages Compared to Vidir
23
23
 
24
- [edir][edir] unashamedly mimics the functionality of the
24
+ [`edir`][edir] unashamedly mimics the functionality of the
25
25
  [vidir](https://linux.die.net/man/1/vidir) utility from
26
26
  [moreutils](https://joeyh.name/code/moreutils/) but aims to improve it
27
27
  in the following ways:
@@ -119,7 +119,7 @@ in the following ways:
119
119
  edit to all depths (or use a large positive number).
120
120
 
121
121
  15. `edir` adds a [`-t/--trash` option](#using-trash) to remove to your
122
- [Trash](https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html).
122
+ [Trash][trash].
123
123
  By default this option invokes
124
124
  [`trash-put`](https://www.mankier.com/1/trash-put) from the
125
125
  [trash-cli](https://github.com/andreafrancia/trash-cli) package to
@@ -234,14 +234,12 @@ default option off temporarily and re-enable git functionality.
234
234
 
235
235
  ## Using Trash
236
236
 
237
- Given how easy `edir` facilitates deleting files, some users may prefer
238
- to remove them to system
239
- [Trash](https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html)
240
- from where they can be later listed and/or recovered. Specifying
241
- `-t/--trash` does this by executing the
237
+ Given how easy `edir` facilitates deleting files, some users may prefer to
238
+ remove them to system [Trash][trash] from where they can be later listed and/or
239
+ recovered. Specifying `-t/--trash` does this by executing the
242
240
  [`trash-put`](https://www.mankier.com/1/trash-put) command, from the
243
- [`trash-cli`](https://github.com/andreafrancia/trash-cli) package, to
244
- remove files rather than removing them natively.
241
+ [`trash-cli`](https://github.com/andreafrancia/trash-cli) package, to remove
242
+ files rather than removing them natively.
245
243
 
246
244
  You may want to set `-t/--trash` as a default option. If you do so then
247
245
  you can use `-T` on the command line to turn that default option off
@@ -259,7 +257,7 @@ want to set this as a [default option](#command-default-options).
259
257
  Many users would like to see a preview of changes after they finish
260
258
  editing but before they are actioned by `edir`, i.e. to confirm exactly
261
259
  which files/dirs will be deleted, renamed, or copied. Add the
262
- `-i/--interactive` option and edir will present a list of changes and
260
+ `-i/--interactive` option and `edir` will present a list of changes and
263
261
  prompt you to continue, or allow you to re-edit the path list etc.
264
262
  Consider setting `--interactive` as a [default
265
263
  option](#command-default-options) so you are always prompted.
@@ -284,18 +282,24 @@ Python 3.8 or later is required. Arch Linux users can install [`edir`
284
282
  from the AUR](https://aur.archlinux.org/packages/edir) and skip this
285
283
  section.
286
284
 
287
- The easiest way to install `edir` is to use [`pipx`][pipx] (or
288
- [`pipxu`][pipxu], or [`uv tool`][uvtool]) which installs [`edir` from
289
- PyPi][edirpy]. To install:
285
+ Note [`edir` is on PyPI](https://pypi.org/project/edir/) so the easiest
286
+ way to install it is to use [`uv tool`][uvtool] (or [`pipx`][pipx] or
287
+ [`pipxu`][pipxu]).
290
288
 
291
- ```
292
- $ pipx install edir
289
+ ```sh
290
+ $ uv tool install edir
293
291
  ```
294
292
 
295
293
  To upgrade:
296
294
 
295
+ ```sh
296
+ $ uv tool upgrade edir
297
297
  ```
298
- $ pipx upgrade edir
298
+
299
+ To uninstall:
300
+
301
+ ```sh
302
+ $ uv tool uninstall edir
299
303
  ```
300
304
 
301
305
  [Git](https://git-scm.com/) must be installed if you want to use the git
@@ -361,9 +365,9 @@ Type `edir -h` to view the usage summary:
361
365
 
362
366
  ```
363
367
  usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
364
- [-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH]
365
- [-F | -D] [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z]
366
- [--suffix SUFFIX] [-V]
368
+ [-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
369
+ -D] [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z] [--suffix SUFFIX]
370
+ [-V]
367
371
  [args ...]
368
372
 
369
373
  Program to rename, remove, or copy files and directories using your editor.
@@ -393,8 +397,7 @@ options:
393
397
  -c, --no-color do not color rename/remove/copy messages
394
398
  -C, --no-invert-color
395
399
  do not invert the color to highlight error messages
396
- -d DEPTH, --depth DEPTH
397
- edit paths to specified depth, default=1
400
+ -d, --depth DEPTH edit paths to specified depth, default=1
398
401
  -F, --files only show/edit files
399
402
  -D, --dirs only show/edit directories
400
403
  -L, --nolinks ignore all symlinks
@@ -411,19 +414,19 @@ options:
411
414
  -V, --version show edir version
412
415
 
413
416
  Note you can set default starting options in $HOME/.config/edir-
414
- flags.conf. The negation options (i.e. the --no-* options and their
415
- shortforms) allow you to temporarily override your defaults.
417
+ flags.conf. The negation options (i.e. the --no-* options) allow you to
418
+ temporarily override your defaults.
416
419
  ```
417
420
 
418
421
  ## Embed in Ranger File Manager
419
422
 
420
- In many ways `edir` (and `vidir`) is better than the
421
- [ranger](https://ranger.github.io/) terminal file manager
422
- [bulkrename](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
423
- command which does not handle name swaps and clashes etc. To add `edir`
424
- as a command within [ranger](https://ranger.github.io/), add or create
425
- the following in `~/.config/ranger/commands.py`. Then run it from within
426
- [ranger](https://ranger.github.io/) by typing `:edir`.
423
+ In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
424
+ terminal file manager
425
+ [`bulkrename`](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
426
+ command which does not handle name swaps and clashes etc. To add `edir` as a
427
+ command within [`ranger`][ranger], add or create the following in
428
+ `~/.config/ranger/commands.py`. Then run it from within [`ranger`][ranger] by
429
+ typing `:edir`.
427
430
 
428
431
  ```python
429
432
  from ranger.api.commands import Command
@@ -441,8 +444,10 @@ class edir(Command):
441
444
  return self._tab_directory_content()
442
445
  ```
443
446
 
444
- Note if you use [yazi](https://yazi-rs.github.io/) for your file manager
445
- you don't need any special configuration in `yazi`. Just type `:edir`.
447
+ ## Use with Yazi File Manager
448
+
449
+ If you use [`yazi`][yazi] for your file manager then you don't need any special
450
+ configuration. Just type `:edir` from within [`yazi`][yazi].
446
451
 
447
452
  ## License
448
453
 
@@ -461,5 +466,8 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at
461
466
  [pipx]: https://github.com/pypa/pipx
462
467
  [pipxu]: https://github.com/bulletmark/pipxu
463
468
  [uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
469
+ [ranger]: https://ranger.github.io/
470
+ [yazi]: https://yazi-rs.github.io/
471
+ [trash]: https://specifications.freedesktop.org/trash-spec/1.0/
464
472
 
465
473
  <!-- vim: se ai syn=markdown: -->
@@ -1,9 +1,9 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: edir
3
- Version: 2.30
3
+ Version: 2.31
4
4
  Summary: Utility to rename, remove, and copy files/dirs using your editor
5
5
  Author-email: Mark Blakeney <mark.blakeney@bullet-systems.net>
6
- License: GPLv3
6
+ License-Expression: GPL-3.0-or-later
7
7
  Project-URL: Homepage, https://github.com/bulletmark/edir
8
8
  Keywords: vidir,git,trash,trash-put,thrash-d
9
9
  Classifier: Programming Language :: Python :: 3
@@ -15,7 +15,7 @@ Requires-Dist: platformdirs
15
15
  [![PyPi](https://img.shields.io/pypi/v/edir)](https://pypi.org/project/edir/)
16
16
  [![AUR](https://img.shields.io/aur/version/edir)](https://aur.archlinux.org/packages/edir/)
17
17
 
18
- [edir][edir] is a command line utility to rename, remove, and copy
18
+ [`edir`][edir] is a command line utility to rename, remove, and copy
19
19
  filenames and directories using your text editor. Run it in the current
20
20
  directory and `edir` will open your editor on a list of files and
21
21
  directories in that directory. Each item in the directory will appear on
@@ -34,7 +34,7 @@ https://github.com/bulletmark/edir.
34
34
 
35
35
  ## Advantages Compared to Vidir
36
36
 
37
- [edir][edir] unashamedly mimics the functionality of the
37
+ [`edir`][edir] unashamedly mimics the functionality of the
38
38
  [vidir](https://linux.die.net/man/1/vidir) utility from
39
39
  [moreutils](https://joeyh.name/code/moreutils/) but aims to improve it
40
40
  in the following ways:
@@ -132,7 +132,7 @@ in the following ways:
132
132
  edit to all depths (or use a large positive number).
133
133
 
134
134
  15. `edir` adds a [`-t/--trash` option](#using-trash) to remove to your
135
- [Trash](https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html).
135
+ [Trash][trash].
136
136
  By default this option invokes
137
137
  [`trash-put`](https://www.mankier.com/1/trash-put) from the
138
138
  [trash-cli](https://github.com/andreafrancia/trash-cli) package to
@@ -247,14 +247,12 @@ default option off temporarily and re-enable git functionality.
247
247
 
248
248
  ## Using Trash
249
249
 
250
- Given how easy `edir` facilitates deleting files, some users may prefer
251
- to remove them to system
252
- [Trash](https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html)
253
- from where they can be later listed and/or recovered. Specifying
254
- `-t/--trash` does this by executing the
250
+ Given how easy `edir` facilitates deleting files, some users may prefer to
251
+ remove them to system [Trash][trash] from where they can be later listed and/or
252
+ recovered. Specifying `-t/--trash` does this by executing the
255
253
  [`trash-put`](https://www.mankier.com/1/trash-put) command, from the
256
- [`trash-cli`](https://github.com/andreafrancia/trash-cli) package, to
257
- remove files rather than removing them natively.
254
+ [`trash-cli`](https://github.com/andreafrancia/trash-cli) package, to remove
255
+ files rather than removing them natively.
258
256
 
259
257
  You may want to set `-t/--trash` as a default option. If you do so then
260
258
  you can use `-T` on the command line to turn that default option off
@@ -272,7 +270,7 @@ want to set this as a [default option](#command-default-options).
272
270
  Many users would like to see a preview of changes after they finish
273
271
  editing but before they are actioned by `edir`, i.e. to confirm exactly
274
272
  which files/dirs will be deleted, renamed, or copied. Add the
275
- `-i/--interactive` option and edir will present a list of changes and
273
+ `-i/--interactive` option and `edir` will present a list of changes and
276
274
  prompt you to continue, or allow you to re-edit the path list etc.
277
275
  Consider setting `--interactive` as a [default
278
276
  option](#command-default-options) so you are always prompted.
@@ -297,18 +295,24 @@ Python 3.8 or later is required. Arch Linux users can install [`edir`
297
295
  from the AUR](https://aur.archlinux.org/packages/edir) and skip this
298
296
  section.
299
297
 
300
- The easiest way to install `edir` is to use [`pipx`][pipx] (or
301
- [`pipxu`][pipxu], or [`uv tool`][uvtool]) which installs [`edir` from
302
- PyPi][edirpy]. To install:
298
+ Note [`edir` is on PyPI](https://pypi.org/project/edir/) so the easiest
299
+ way to install it is to use [`uv tool`][uvtool] (or [`pipx`][pipx] or
300
+ [`pipxu`][pipxu]).
303
301
 
304
- ```
305
- $ pipx install edir
302
+ ```sh
303
+ $ uv tool install edir
306
304
  ```
307
305
 
308
306
  To upgrade:
309
307
 
308
+ ```sh
309
+ $ uv tool upgrade edir
310
310
  ```
311
- $ pipx upgrade edir
311
+
312
+ To uninstall:
313
+
314
+ ```sh
315
+ $ uv tool uninstall edir
312
316
  ```
313
317
 
314
318
  [Git](https://git-scm.com/) must be installed if you want to use the git
@@ -374,9 +378,9 @@ Type `edir -h` to view the usage summary:
374
378
 
375
379
  ```
376
380
  usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
377
- [-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH]
378
- [-F | -D] [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z]
379
- [--suffix SUFFIX] [-V]
381
+ [-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
382
+ -D] [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z] [--suffix SUFFIX]
383
+ [-V]
380
384
  [args ...]
381
385
 
382
386
  Program to rename, remove, or copy files and directories using your editor.
@@ -406,8 +410,7 @@ options:
406
410
  -c, --no-color do not color rename/remove/copy messages
407
411
  -C, --no-invert-color
408
412
  do not invert the color to highlight error messages
409
- -d DEPTH, --depth DEPTH
410
- edit paths to specified depth, default=1
413
+ -d, --depth DEPTH edit paths to specified depth, default=1
411
414
  -F, --files only show/edit files
412
415
  -D, --dirs only show/edit directories
413
416
  -L, --nolinks ignore all symlinks
@@ -424,19 +427,19 @@ options:
424
427
  -V, --version show edir version
425
428
 
426
429
  Note you can set default starting options in $HOME/.config/edir-
427
- flags.conf. The negation options (i.e. the --no-* options and their
428
- shortforms) allow you to temporarily override your defaults.
430
+ flags.conf. The negation options (i.e. the --no-* options) allow you to
431
+ temporarily override your defaults.
429
432
  ```
430
433
 
431
434
  ## Embed in Ranger File Manager
432
435
 
433
- In many ways `edir` (and `vidir`) is better than the
434
- [ranger](https://ranger.github.io/) terminal file manager
435
- [bulkrename](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
436
- command which does not handle name swaps and clashes etc. To add `edir`
437
- as a command within [ranger](https://ranger.github.io/), add or create
438
- the following in `~/.config/ranger/commands.py`. Then run it from within
439
- [ranger](https://ranger.github.io/) by typing `:edir`.
436
+ In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
437
+ terminal file manager
438
+ [`bulkrename`](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
439
+ command which does not handle name swaps and clashes etc. To add `edir` as a
440
+ command within [`ranger`][ranger], add or create the following in
441
+ `~/.config/ranger/commands.py`. Then run it from within [`ranger`][ranger] by
442
+ typing `:edir`.
440
443
 
441
444
  ```python
442
445
  from ranger.api.commands import Command
@@ -454,8 +457,10 @@ class edir(Command):
454
457
  return self._tab_directory_content()
455
458
  ```
456
459
 
457
- Note if you use [yazi](https://yazi-rs.github.io/) for your file manager
458
- you don't need any special configuration in `yazi`. Just type `:edir`.
460
+ ## Use with Yazi File Manager
461
+
462
+ If you use [`yazi`][yazi] for your file manager then you don't need any special
463
+ configuration. Just type `:edir` from within [`yazi`][yazi].
459
464
 
460
465
  ## License
461
466
 
@@ -474,5 +479,8 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at
474
479
  [pipx]: https://github.com/pypa/pipx
475
480
  [pipxu]: https://github.com/bulletmark/pipxu
476
481
  [uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
482
+ [ranger]: https://ranger.github.io/
483
+ [yazi]: https://yazi-rs.github.io/
484
+ [trash]: https://specifications.freedesktop.org/trash-spec/1.0/
477
485
 
478
486
  <!-- vim: se ai syn=markdown: -->
@@ -1,4 +1,3 @@
1
- .flake8
2
1
  .gitignore
3
2
  Makefile
4
3
  README.md
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env python3
2
- '''
2
+ """
3
3
  Program to rename, remove, or copy files and directories using your
4
4
  editor. Will use git to action the rename and remove if run within a git
5
5
  repository.
6
- '''
6
+ """
7
+
7
8
  # Author: Mark Blakeney, May 2019.
8
9
  from __future__ import annotations
9
10
 
@@ -18,7 +19,7 @@ import sys
18
19
  import tempfile
19
20
  from collections import OrderedDict
20
21
  from pathlib import Path
21
- from typing import Callable, Sequence, Iterable
22
+ from typing import Callable, Iterable, Sequence
22
23
 
23
24
  from platformdirs import user_config_path
24
25
 
@@ -35,12 +36,18 @@ TEMPDIR = '.tmp-' + PROG
35
36
  # Define action verbs and ANSI escape sequences for action colors
36
37
  # Refer https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
37
38
  ACTIONS = {
38
- 'remove': (('\033[31m', '\033[30;41m'), # Red
39
- ('Removing', 'Remove', 'Removed')),
40
- 'copy': (('\033[32m', '\033[30;42m'), # Green
41
- ('Copying', 'Copy', 'Copied')),
42
- 'rename': (('\033[33m', '\033[30;43m'), # Yellow
43
- ('Renaming', 'Rename', 'Renamed')),
39
+ 'remove': (
40
+ ('\033[31m', '\033[30;41m'), # Red
41
+ ('Removing', 'Remove', 'Removed'),
42
+ ),
43
+ 'copy': (
44
+ ('\033[32m', '\033[30;42m'), # Green
45
+ ('Copying', 'Copy', 'Copied'),
46
+ ),
47
+ 'rename': (
48
+ ('\033[33m', '\033[30;43m'), # Yellow
49
+ ('Renaming', 'Rename', 'Renamed'),
50
+ ),
44
51
  }
45
52
 
46
53
  COLOR_reset = '\033[39;49m'
@@ -51,13 +58,16 @@ counts = [0, 0]
51
58
 
52
59
  EDITORS = {'Windows': 'notepad', 'Darwin': 'open -e', 'default': 'vim'}
53
60
 
61
+
54
62
  def get_default_editor() -> str:
55
- 'Return default editor for this system'
63
+ "Return default editor for this system"
56
64
  from platform import system
65
+
57
66
  return EDITORS.get(system(), EDITORS['default'])
58
67
 
68
+
59
69
  def editfile(filename: Path) -> None:
60
- 'Run the editor command'
70
+ "Run the editor command"
61
71
  # Use explicit user defined editor or choose system default
62
72
  editor = os.getenv(EDITOR) or os.getenv('EDITOR') or get_default_editor()
63
73
  editcmd = shlex.split(editor) + [str(filename)]
@@ -73,9 +83,11 @@ def editfile(filename: Path) -> None:
73
83
  if res.returncode != 0:
74
84
  sys.exit(f'ERROR: {editor} returned error {res.returncode}')
75
85
 
76
- def log(action: str, msg: str, error: str | None = None, *,
77
- prompt: bool = False) -> None:
78
- 'Output message with appropriate color'
86
+
87
+ def log(
88
+ action: str, msg: str, error: str | None = None, *, prompt: bool = False
89
+ ) -> None:
90
+ "Output message with appropriate color"
79
91
  counts[bool(error)] += 1
80
92
 
81
93
  colors, tense = ACTIONS[action]
@@ -90,18 +102,19 @@ def log(action: str, msg: str, error: str | None = None, *,
90
102
  msg = f'{tense[0] if prompt else tense[2]} {msg}'
91
103
 
92
104
  if not args.no_color:
93
- msg = colors[bool(error and not args.no_invert_color)] \
94
- + msg + COLOR_reset
105
+ msg = colors[bool(error and not args.no_invert_color)] + msg + COLOR_reset
95
106
 
96
107
  print(msg, file=out)
97
108
 
109
+
98
110
  def run(cmd: Sequence[str]) -> tuple[str, str]:
99
- 'Run given command and return (stdout, stderr) strings'
111
+ "Run given command and return (stdout, stderr) strings"
100
112
  stdout = ''
101
113
  stderr = ''
102
114
  try:
103
- res = subprocess.run(cmd, stdout=subprocess.PIPE,
104
- stderr=subprocess.PIPE, universal_newlines=True)
115
+ res = subprocess.run(
116
+ cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True
117
+ )
105
118
  except Exception as e:
106
119
  stderr = str(e)
107
120
  else:
@@ -112,11 +125,12 @@ def run(cmd: Sequence[str]) -> tuple[str, str]:
112
125
 
113
126
  return stdout, stderr
114
127
 
115
- def remove(path: Path, git: bool = False, trash: bool = False,
116
- recurse: bool = False) -> str | None:
117
- 'Delete given file/directory'
118
- if not recurse and not path.is_symlink() and path.is_dir() and \
119
- any(path.iterdir()):
128
+
129
+ def remove(
130
+ path: Path, git: bool = False, trash: bool = False, recurse: bool = False
131
+ ) -> str | None:
132
+ "Delete given file/directory"
133
+ if not recurse and not path.is_symlink() and path.is_dir() and any(path.iterdir()):
120
134
  return 'Directory not empty'
121
135
 
122
136
  if git:
@@ -144,8 +158,9 @@ def remove(path: Path, git: bool = False, trash: bool = False,
144
158
  except Exception as e:
145
159
  return str(e)
146
160
 
161
+
147
162
  def rename(pathsrc: Path, pathdest: Path, is_git: bool = False) -> str:
148
- 'Rename given pathsrc to pathdest'
163
+ "Rename given pathsrc to pathdest"
149
164
  if is_git:
150
165
  out, err = run('git mv -f'.split() + [str(pathsrc), str(pathdest)])
151
166
  if err:
@@ -162,8 +177,9 @@ def rename(pathsrc: Path, pathdest: Path, is_git: bool = False) -> str:
162
177
 
163
178
  return err
164
179
 
180
+
165
181
  def create_prompt(options: str) -> str:
166
- 'Create a string of options + keys for user to choose from'
182
+ "Create a string of options + keys for user to choose from"
167
183
  letters = []
168
184
  words = []
169
185
  for arg in options.split():
@@ -174,8 +190,9 @@ def create_prompt(options: str) -> str:
174
190
  words.append('/'.join(subwords))
175
191
  return ', '.join(words) + ': [' + '|'.join(letters) + ']? '
176
192
 
193
+
177
194
  def find_in_dir(path: Path, depth: int, allfiles: bool) -> Iterable[Path]:
178
- 'Find files/dirs in given path'
195
+ "Find files/dirs in given path"
179
196
  if depth == 0:
180
197
  yield path
181
198
  return
@@ -187,13 +204,15 @@ def find_in_dir(path: Path, depth: int, allfiles: bool) -> Iterable[Path]:
187
204
  else:
188
205
  yield from find_in_dir(p, depth - 1, allfiles)
189
206
 
207
+
190
208
  class Fpath:
191
- 'Class to manage each instance of a file/dir'
209
+ "Class to manage each instance of a file/dir"
210
+
192
211
  paths = []
193
212
  tempdirs = set()
194
213
 
195
214
  def __init__(self, path: Path):
196
- 'Class constructor'
215
+ "Class constructor"
197
216
  self.path = path
198
217
  self.newpath = None
199
218
  self.temppath = None
@@ -208,15 +227,16 @@ class Fpath:
208
227
  self.diagrepr = str(self.path)
209
228
  self.is_git = self.diagrepr in gitfiles
210
229
 
211
- self.linerepr = self.diagrepr if self.path.is_absolute() \
212
- else f'.{SEP}{self.diagrepr}'
230
+ self.linerepr = (
231
+ self.diagrepr if self.path.is_absolute() else f'.{SEP}{self.diagrepr}'
232
+ )
213
233
  if self.is_dir and not self.diagrepr.endswith(SEP):
214
234
  self.linerepr += SEP
215
235
  self.diagrepr += SEP
216
236
 
217
237
  @staticmethod
218
238
  def inc_path(path: Path) -> Path:
219
- 'Find next unique file name'
239
+ "Find next unique file name"
220
240
  # Iterate forever, there can only be a finite number of existing
221
241
  # paths
222
242
  name = path.name
@@ -228,7 +248,7 @@ class Fpath:
228
248
  return path
229
249
 
230
250
  def copy(self, pathdest: Path) -> str | None:
231
- 'Copy given pathsrc to pathdest'
251
+ "Copy given pathsrc to pathdest"
232
252
  if self.is_dir:
233
253
  func: Callable = shutil.copytree
234
254
  else:
@@ -245,7 +265,7 @@ class Fpath:
245
265
  return str(e)
246
266
 
247
267
  def rename_temp(self) -> str | None:
248
- 'Move this path to a temp place in advance of final move'
268
+ "Move this path to a temp place in advance of final move"
249
269
  if not self.newpath:
250
270
  return None
251
271
  tempdir = self.newpath.parent / TEMPDIR
@@ -264,18 +284,18 @@ class Fpath:
264
284
  return err
265
285
 
266
286
  def restore_temp(self) -> str | None:
267
- 'Restore temp path to final destination'
287
+ "Restore temp path to final destination"
268
288
  if not self.temppath or not self.newpath:
269
289
  return None
270
290
  self.newpath = self.inc_path(self.newpath)
271
291
  return rename(self.temppath, self.newpath, self.is_git)
272
292
 
273
293
  def sort_name(self) -> str:
274
- 'Return name for sort'
294
+ "Return name for sort"
275
295
  return str(self.path)
276
296
 
277
297
  def sort_time(self) -> float:
278
- 'Return time for sort'
298
+ "Return time for sort"
279
299
  try:
280
300
  ret = self.path.lstat().st_mtime
281
301
  except Exception:
@@ -284,7 +304,7 @@ class Fpath:
284
304
  return ret
285
305
 
286
306
  def sort_size(self) -> int:
287
- 'Return size for sort'
307
+ "Return size for sort"
288
308
  try:
289
309
  ret = self.path.lstat().st_size
290
310
  except Exception:
@@ -293,7 +313,7 @@ class Fpath:
293
313
  return ret
294
314
 
295
315
  def is_recursive(self) -> bool:
296
- 'Return True if directory and we can view it and contains children'
316
+ "Return True if directory and we can view it and contains children"
297
317
  if not self.is_dir:
298
318
  return False
299
319
  try:
@@ -302,19 +322,25 @@ class Fpath:
302
322
  return False
303
323
 
304
324
  def log_pending_changes(self) -> None:
305
- 'Log all pending changes for this path'
325
+ "Log all pending changes for this path"
306
326
  if not self.newpath:
307
327
  log('remove', f'"{self.diagrepr}"{self.note}', prompt=True)
308
328
  elif self.newpath != self.path:
309
- log('rename', f'"{self.diagrepr}" to '
310
- f'"{self.newpath}{self.appdash}"', prompt=True)
329
+ log(
330
+ 'rename',
331
+ f'"{self.diagrepr}" to "{self.newpath}{self.appdash}"',
332
+ prompt=True,
333
+ )
311
334
  for c in self.copies:
312
- log('copy', f'"{self.diagrepr}" to '
313
- f'"{c}{self.appdash}"{self.note}', prompt=True)
335
+ log(
336
+ 'copy',
337
+ f'"{self.diagrepr}" to "{c}{self.appdash}"{self.note}',
338
+ prompt=True,
339
+ )
314
340
 
315
341
  @classmethod
316
342
  def remove_temps(cls) -> None:
317
- 'Remove all the temp dirs we created in rename_temp() above'
343
+ "Remove all the temp dirs we created in rename_temp() above"
318
344
  for p in cls.tempdirs:
319
345
  remove(p, git=False, trash=False, recurse=True)
320
346
 
@@ -322,7 +348,7 @@ class Fpath:
322
348
 
323
349
  @classmethod
324
350
  def append(cls, path: Path) -> None:
325
- 'Add a single file/dir to the list of paths'
351
+ "Add a single file/dir to the list of paths"
326
352
  # Filter out files/dirs if asked
327
353
  if args.files:
328
354
  if path.is_dir():
@@ -339,7 +365,7 @@ class Fpath:
339
365
 
340
366
  @classmethod
341
367
  def add(cls, name: str, depth: int) -> None:
342
- 'Add file[s]/dir[s] to the list of paths'
368
+ "Add file[s]/dir[s] to the list of paths"
343
369
  path = Path(name)
344
370
  if not path.exists():
345
371
  sys.exit(f'ERROR: {name} does not exist')
@@ -352,16 +378,17 @@ class Fpath:
352
378
 
353
379
  @classmethod
354
380
  def writefile(cls, fpath: Path) -> None:
355
- 'Write the file for user to edit'
381
+ "Write the file for user to edit"
356
382
  with fpath.open('w') as fp:
357
383
  # Ensure consistent width for line numbers
358
384
  num_width = len(str(len(cls.paths)))
359
- fp.writelines(f'{i:0{num_width}} {p.linerepr}\n'
360
- for i, p in enumerate(cls.paths, 1))
385
+ fp.writelines(
386
+ f'{i:0{num_width}} {p.linerepr}\n' for i, p in enumerate(cls.paths, 1)
387
+ )
361
388
 
362
389
  @classmethod
363
390
  def readfile(cls, fpath: Path) -> None:
364
- 'Read the list of files/dirs as edited by user'
391
+ "Read the list of files/dirs as edited by user"
365
392
  # Reset all the read path changes to null state
366
393
  for p in cls.paths:
367
394
  p.newpath = None
@@ -383,12 +410,12 @@ class Fpath:
383
410
  try:
384
411
  num = int(n)
385
412
  except Exception:
386
- sys.exit(f'ERROR: line {count} number {n} invalid:'
387
- f'\n{rawline}')
413
+ sys.exit(f'ERROR: line {count} number {n} invalid:\n{rawline}')
388
414
 
389
415
  if num <= 0 or num > len(cls.paths):
390
- sys.exit(f'ERROR: line {count} number {num} '
391
- f'out of range:\n{rawline}')
416
+ sys.exit(
417
+ f'ERROR: line {count} number {num} out of range:\n{rawline}'
418
+ )
392
419
 
393
420
  path = cls.paths[num - 1]
394
421
 
@@ -405,9 +432,12 @@ class Fpath:
405
432
 
406
433
  @classmethod
407
434
  def get_path_changes(cls) -> list:
408
- 'Get a list of change paths from the user'
409
- prompt = create_prompt('proceed/yes edit restart quit[default]') \
410
- if args.interactive else None
435
+ "Get a list of change paths from the user"
436
+ prompt = (
437
+ create_prompt('proceed/yes edit restart quit[default]')
438
+ if args.interactive
439
+ else None
440
+ )
411
441
 
412
442
  with tempfile.TemporaryDirectory() as fdir:
413
443
  # Create a temp file for the user to edit then read the lines back
@@ -425,8 +455,7 @@ class Fpath:
425
455
  cls.readfile(fpath)
426
456
 
427
457
  # Reduce paths to those that were removed or changed by the user
428
- paths = [p for p in cls.paths
429
- if p.path != p.newpath or p.copies]
458
+ paths = [p for p in cls.paths if p.path != p.newpath or p.copies]
430
459
 
431
460
  if not paths:
432
461
  return []
@@ -461,85 +490,185 @@ class Fpath:
461
490
  else:
462
491
  print(f'Invalid answer "{ans}".')
463
492
 
493
+
464
494
  def main() -> int:
465
- 'Main code'
495
+ "Main code"
466
496
  global args
467
497
  # Process command line options
468
- opt = argparse.ArgumentParser(description=__doc__,
469
- epilog='Note you can set default starting options in '
470
- f'{CNFFILE}. The negation options (i.e. the --no-* options '
471
- 'and their shortforms) allow you to temporarily override your '
472
- 'defaults.')
473
- opt.add_argument('-i', '--interactive', action='store_true',
474
- help='prompt with summary of changes and allow re-edit before '
475
- 'proceeding')
476
- opt.add_argument('-I', '--no-interactive', dest='interactive',
477
- action='store_false',
478
- help='negate the -i/--interactive option')
479
- opt.add_argument('-a', '--all', action='store_true',
480
- help='include all (including hidden) files')
481
- opt.add_argument('-A', '--no-all', dest='all', action='store_false',
482
- help='negate the -a/--all option')
483
- opt.add_argument('-r', '--recurse', action='store_true',
484
- help='recursively remove any files and directories in '
485
- 'removed directories')
486
- opt.add_argument('-R', '--no-recurse', dest='recurse', action='store_false',
487
- help='negate the -r/--recurse option')
488
- opt.add_argument('-q', '--quiet', action='store_true',
489
- help='do not print successful rename/remove/copy actions')
490
- opt.add_argument('-Q', '--no-quiet', dest='quiet', action='store_false',
491
- help='negate the -q/--quiet option')
492
- opt.add_argument('-G', '--no-git', dest='git',
493
- action='store_const', const=0,
494
- help='do not use git if invoked within a git repository')
495
- opt.add_argument('-g', '--git', dest='git',
496
- action='store_const', const=1,
497
- help='negate the --no-git option and DO use automatic git')
498
- opt.add_argument('-t', '--trash', action='store_true',
499
- help='use trash program to do deletions')
500
- opt.add_argument('-T', '--no-trash', dest='trash', action='store_false',
501
- help='negate the -t/--trash option')
502
- opt.add_argument('--trash-program', default='trash-put',
503
- help='trash program to use, default="%(default)s"')
504
- opt.add_argument('-c', '--no-color', action='store_true',
505
- help='do not color rename/remove/copy messages')
506
- opt.add_argument('-C', '--no-invert-color', action='store_true',
507
- help='do not invert the color to highlight error messages')
508
- opt.add_argument('-d', '--depth', type=int, default=1,
509
- help='edit paths to specified depth, default=%(default)d')
498
+ opt = argparse.ArgumentParser(
499
+ description=__doc__,
500
+ epilog='Note you can set default starting options in '
501
+ f'{CNFFILE}. The negation options (i.e. the --no-* options) '
502
+ 'allow you to temporarily override your defaults.',
503
+ )
504
+ opt.add_argument(
505
+ '-i',
506
+ '--interactive',
507
+ action='store_true',
508
+ help='prompt with summary of changes and allow re-edit before proceeding',
509
+ )
510
+ opt.add_argument(
511
+ '-I',
512
+ '--no-interactive',
513
+ dest='interactive',
514
+ action='store_false',
515
+ help='negate the -i/--interactive option',
516
+ )
517
+ opt.add_argument(
518
+ '-a', '--all', action='store_true', help='include all (including hidden) files'
519
+ )
520
+ opt.add_argument(
521
+ '-A',
522
+ '--no-all',
523
+ dest='all',
524
+ action='store_false',
525
+ help='negate the -a/--all option',
526
+ )
527
+ opt.add_argument(
528
+ '-r',
529
+ '--recurse',
530
+ action='store_true',
531
+ help='recursively remove any files and directories in removed directories',
532
+ )
533
+ opt.add_argument(
534
+ '-R',
535
+ '--no-recurse',
536
+ dest='recurse',
537
+ action='store_false',
538
+ help='negate the -r/--recurse option',
539
+ )
540
+ opt.add_argument(
541
+ '-q',
542
+ '--quiet',
543
+ action='store_true',
544
+ help='do not print successful rename/remove/copy actions',
545
+ )
546
+ opt.add_argument(
547
+ '-Q',
548
+ '--no-quiet',
549
+ dest='quiet',
550
+ action='store_false',
551
+ help='negate the -q/--quiet option',
552
+ )
553
+ opt.add_argument(
554
+ '-G',
555
+ '--no-git',
556
+ dest='git',
557
+ action='store_const',
558
+ const=0,
559
+ help='do not use git if invoked within a git repository',
560
+ )
561
+ opt.add_argument(
562
+ '-g',
563
+ '--git',
564
+ dest='git',
565
+ action='store_const',
566
+ const=1,
567
+ help='negate the --no-git option and DO use automatic git',
568
+ )
569
+ opt.add_argument(
570
+ '-t', '--trash', action='store_true', help='use trash program to do deletions'
571
+ )
572
+ opt.add_argument(
573
+ '-T',
574
+ '--no-trash',
575
+ dest='trash',
576
+ action='store_false',
577
+ help='negate the -t/--trash option',
578
+ )
579
+ opt.add_argument(
580
+ '--trash-program',
581
+ default='trash-put',
582
+ help='trash program to use, default="%(default)s"',
583
+ )
584
+ opt.add_argument(
585
+ '-c',
586
+ '--no-color',
587
+ action='store_true',
588
+ help='do not color rename/remove/copy messages',
589
+ )
590
+ opt.add_argument(
591
+ '-C',
592
+ '--no-invert-color',
593
+ action='store_true',
594
+ help='do not invert the color to highlight error messages',
595
+ )
596
+ opt.add_argument(
597
+ '-d',
598
+ '--depth',
599
+ type=int,
600
+ default=1,
601
+ help='edit paths to specified depth, default=%(default)d',
602
+ )
510
603
  grp = opt.add_mutually_exclusive_group()
511
- grp.add_argument('-F', '--files', action='store_true',
512
- help='only show/edit files')
513
- grp.add_argument('-D', '--dirs', action='store_true',
514
- help='only show/edit directories')
515
- opt.add_argument('-L', '--nolinks', action='store_true',
516
- help='ignore all symlinks')
517
- opt.add_argument('-N', '--sort-name', dest='sort',
518
- action='store_const', const=1,
519
- help='sort paths in file by name, alphabetically')
520
- opt.add_argument('-M', '--sort-time', dest='sort',
521
- action='store_const', const=2,
522
- help='sort paths in file by time, oldest first')
523
- opt.add_argument('-S', '--sort-size', dest='sort',
524
- action='store_const', const=3,
525
- help='sort paths in file by size, smallest first')
526
- opt.add_argument('-E', '--sort-reverse', action='store_true',
527
- help='sort paths (by name/time/size) in reverse')
528
- opt.add_argument('-X', '--group-dirs-first', dest='group_dirs',
529
- action='store_const', const=1,
530
- help='group directories first (including when sorted)')
531
- opt.add_argument('-Y', '--group-dirs-last', dest='group_dirs',
532
- action='store_const', const=0,
533
- help='group directories last (including when sorted)')
534
- opt.add_argument('-Z', '--no-group-dirs', dest='group_dirs',
535
- action='store_const', const=-1,
536
- help='negate the options to group directories')
537
- opt.add_argument('--suffix', default=SUFFIX,
538
- help='specify suffix for temp editor file, default="%(default)s"')
539
- opt.add_argument('-V', '--version', action='store_true',
540
- help=f'show {PROG} version')
541
- opt.add_argument('args', nargs='*',
542
- help='file|dir, or "-" for stdin')
604
+ grp.add_argument('-F', '--files', action='store_true', help='only show/edit files')
605
+ grp.add_argument(
606
+ '-D', '--dirs', action='store_true', help='only show/edit directories'
607
+ )
608
+ opt.add_argument('-L', '--nolinks', action='store_true', help='ignore all symlinks')
609
+ opt.add_argument(
610
+ '-N',
611
+ '--sort-name',
612
+ dest='sort',
613
+ action='store_const',
614
+ const=1,
615
+ help='sort paths in file by name, alphabetically',
616
+ )
617
+ opt.add_argument(
618
+ '-M',
619
+ '--sort-time',
620
+ dest='sort',
621
+ action='store_const',
622
+ const=2,
623
+ help='sort paths in file by time, oldest first',
624
+ )
625
+ opt.add_argument(
626
+ '-S',
627
+ '--sort-size',
628
+ dest='sort',
629
+ action='store_const',
630
+ const=3,
631
+ help='sort paths in file by size, smallest first',
632
+ )
633
+ opt.add_argument(
634
+ '-E',
635
+ '--sort-reverse',
636
+ action='store_true',
637
+ help='sort paths (by name/time/size) in reverse',
638
+ )
639
+ opt.add_argument(
640
+ '-X',
641
+ '--group-dirs-first',
642
+ dest='group_dirs',
643
+ action='store_const',
644
+ const=1,
645
+ help='group directories first (including when sorted)',
646
+ )
647
+ opt.add_argument(
648
+ '-Y',
649
+ '--group-dirs-last',
650
+ dest='group_dirs',
651
+ action='store_const',
652
+ const=0,
653
+ help='group directories last (including when sorted)',
654
+ )
655
+ opt.add_argument(
656
+ '-Z',
657
+ '--no-group-dirs',
658
+ dest='group_dirs',
659
+ action='store_const',
660
+ const=-1,
661
+ help='negate the options to group directories',
662
+ )
663
+ opt.add_argument(
664
+ '--suffix',
665
+ default=SUFFIX,
666
+ help='specify suffix for temp editor file, default="%(default)s"',
667
+ )
668
+ opt.add_argument(
669
+ '-V', '--version', action='store_true', help=f'show {PROG} version'
670
+ )
671
+ opt.add_argument('args', nargs='*', help='file|dir, or "-" for stdin')
543
672
 
544
673
  # Merge in default args from user config file. Then parse the
545
674
  # command line.
@@ -554,6 +683,7 @@ def main() -> int:
554
683
 
555
684
  if args.version:
556
685
  from importlib.metadata import version
686
+
557
687
  try:
558
688
  ver = version(PROG)
559
689
  except Exception:
@@ -597,8 +727,13 @@ def main() -> int:
597
727
 
598
728
  # Sanity check that we have something to edit
599
729
  if not Fpath.paths:
600
- desc = 'files' if args.files else \
601
- 'directories' if args.dirs else 'files or directories'
730
+ desc = (
731
+ 'files'
732
+ if args.files
733
+ else 'directories'
734
+ if args.dirs
735
+ else 'files or directories'
736
+ )
602
737
  print(f'No {desc}.')
603
738
  return 0
604
739
 
@@ -628,8 +763,7 @@ def main() -> int:
628
763
  if p.newpath:
629
764
  if p.newpath != p.path:
630
765
  if err := p.rename_temp():
631
- log('rename',
632
- f'"{p.diagrepr}" to "{p.newpath}{p.appdash}"', err)
766
+ log('rename', f'"{p.diagrepr}" to "{p.newpath}{p.appdash}"', err)
633
767
  elif not p.is_dir:
634
768
  err = remove(p.path, p.is_git, args.trash)
635
769
  log('remove', f'"{p.diagrepr}"', err)
@@ -664,5 +798,6 @@ def main() -> int:
664
798
  # Return status code 0 = all good, 1 = some bad, 2 = all bad.
665
799
  return (1 if counts[0] > 0 else 2) if counts[1] > 0 else 0
666
800
 
801
+
667
802
  if __name__ == '__main__':
668
803
  sys.exit(main())
@@ -6,6 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
  name = "edir"
7
7
  description = "Utility to rename, remove, and copy files/dirs using your editor"
8
8
  readme = "README.md"
9
+ license = "GPL-3.0-or-later"
9
10
  requires-python = ">=3.8"
10
11
  keywords = ["vidir", "git", "trash", "trash-put", "thrash-d"]
11
12
  classifiers = [
@@ -26,9 +27,6 @@ Homepage = "https://github.com/bulletmark/edir"
26
27
  [project.scripts]
27
28
  edir = "edir:main"
28
29
 
29
- [project.license]
30
- text = "GPLv3"
31
-
32
30
  [tool.setuptools_scm]
33
31
  version_scheme = "post-release"
34
32
 
@@ -38,10 +36,13 @@ warn_no_return = false
38
36
  allow_untyped_globals = true
39
37
  allow_redefinition = true
40
38
 
39
+ [tool.ruff.format]
40
+ quote-style = "single"
41
+ skip-magic-trailing-comma = true
42
+
41
43
  [tool.edit-lint]
42
44
  linters = [
43
- "ruff",
44
- "flake8",
45
+ "ruff check",
45
46
  "mypy",
46
47
  "pyright",
47
48
  ]
edir-2.30/.flake8 DELETED
@@ -1,3 +0,0 @@
1
- [flake8]
2
- ignore = E126,E127,E128,E302,E305,W503,C901
3
- max-line-length = 80
edir-2.30/Makefile DELETED
@@ -1,22 +0,0 @@
1
- NAME = $(shell basename $(CURDIR))
2
- PYNAME = $(subst -,_,$(NAME))
3
-
4
- check:
5
- ruff check $(PYNAME).py
6
- flake8 $(PYNAME).py
7
- mypy $(PYNAME).py
8
- pyright $(PYNAME).py
9
- vermin -vv --no-tips -i $(PYNAME).py
10
-
11
- build:
12
- rm -rf dist
13
- python3 -m build
14
-
15
- upload: build
16
- twine3 upload dist/*
17
-
18
- doc:
19
- update-readme-usage
20
-
21
- clean:
22
- @rm -vrf *.egg-info .venv/ build/ dist/ __pycache__/
File without changes
File without changes
File without changes
File without changes
File without changes