edir 2.28__tar.gz → 2.30__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.
@@ -6,8 +6,7 @@ check:
6
6
  flake8 $(PYNAME).py
7
7
  mypy $(PYNAME).py
8
8
  pyright $(PYNAME).py
9
- vermin -vv --exclude importlib.metadata --eval-annotations \
10
- --no-tips -i $(PYNAME).py
9
+ vermin -vv --no-tips -i $(PYNAME).py
11
10
 
12
11
  build:
13
12
  rm -rf dist
@@ -1,31 +1,30 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: edir
3
- Version: 2.28
3
+ Version: 2.30
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
6
  License: GPLv3
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
10
- Requires-Python: >=3.6
10
+ Requires-Python: >=3.8
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: platformdirs
13
- Requires-Dist: importlib-metadata; python_version < "3.8"
14
13
 
15
14
  ## EDIR - Rename, Remove, and Copy Files and Directories Using Your Editor
16
15
  [![PyPi](https://img.shields.io/pypi/v/edir)](https://pypi.org/project/edir/)
17
16
  [![AUR](https://img.shields.io/aur/version/edir)](https://aur.archlinux.org/packages/edir/)
18
17
 
19
- [edir](http://github.com/bulletmark/edir) is a command line utility to
20
- rename, remove, and copy filenames and directories using your text
21
- editor. Run it in the current directory and `edir` will open your editor
22
- on a list of files and directories in that directory. Each item in the
23
- directory will appear on its own numbered line. These numbers are how
24
- `edir` keeps track of what items are changed. Delete lines to remove
25
- files/directories, edit lines to rename files/directories, or duplicate
26
- line numbers to copy files/directories. You can also switch pairs of
27
- numbers to swap files or directories. If run from within a
28
- [Git](https://git-scm.com/) repository, `edir` will [use
18
+ [edir][edir] is a command line utility to rename, remove, and copy
19
+ filenames and directories using your text editor. Run it in the current
20
+ directory and `edir` will open your editor on a list of files and
21
+ directories in that directory. Each item in the directory will appear on
22
+ its own numbered line. These numbers are how `edir` keeps track of what
23
+ items are changed. Delete lines to remove files/directories, edit lines
24
+ to rename files/directories, or duplicate line numbers to copy
25
+ files/directories. You can also switch pairs of numbers to swap files or
26
+ directories. If run from within a [Git](https://git-scm.com/)
27
+ repository, `edir` will [use
29
28
  Git](#renames-and-deletes-in-a-git-repository) to rename or remove
30
29
  tracked files/directories. You can use a [trash program](#using-trash)
31
30
  to remove files.
@@ -35,10 +34,10 @@ https://github.com/bulletmark/edir.
35
34
 
36
35
  ## Advantages Compared to Vidir
37
36
 
38
- [edir](http://github.com/bulletmark/edir) unashamedly mimics the
39
- functionality of the [vidir](https://linux.die.net/man/1/vidir) utility
40
- from [moreutils](https://joeyh.name/code/moreutils/) but aims to improve it in
41
- the following ways:
37
+ [edir][edir] unashamedly mimics the functionality of the
38
+ [vidir](https://linux.die.net/man/1/vidir) utility from
39
+ [moreutils](https://joeyh.name/code/moreutils/) but aims to improve it
40
+ in the following ways:
42
41
 
43
42
  1. `edir` automatically uses `git mv` instead of `mv` and `git rm`
44
43
  instead of `rm` for tracked files when invoked within a
@@ -73,11 +72,12 @@ the following ways:
73
72
  directory `c` to `e`.
74
73
 
75
74
  Note also, that both `edir` and `vidir` show the leading `./` on each
76
- entry so that any leading spaces are clearly seen, and can be edited.
75
+ entry so that any leading spaces on the filename are clearly seen,
76
+ and can be edited.
77
77
 
78
78
  3. `edir` adds the ability to copy files or directories one or more
79
- times when you duplicate a numbered line. `vidir` does not have copy
80
- functionality.
79
+ times when you duplicate a numbered line (after the original).
80
+ `vidir` does not have copy functionality.
81
81
 
82
82
  4. `edir` allows you to remove a file/directory by deleting the line, as
83
83
  `vidir` does, but you can also remove it by pre-pending a `#` to
@@ -125,9 +125,11 @@ the following ways:
125
125
 
126
126
  13. `edir` adds a `-L/--nolinks` option to ignore symbolic links.
127
127
 
128
- 14. `edir` adds a `-d/--dirnames` option to edit specified directory
129
- names directly, not their contents. I.e. this is like `ls -d mydir`
130
- compared to `ls mydir`.
128
+ 14. `edir` adds a `-d/--depth` option to edit to the specified directory
129
+ depth. The default is 1 so `edir a` (if a is a directory) will edit
130
+ names to `a/*`, `edir -d2 a` will edit names to `a/*/*`, etc. `edir
131
+ -d0 a` will just edit the `a` name directly. Can specify `-1` to
132
+ edit to all depths (or use a large positive number).
131
133
 
132
134
  15. `edir` adds a [`-t/--trash` option](#using-trash) to remove to your
133
135
  [Trash](https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html).
@@ -291,12 +293,13 @@ where:
291
293
 
292
294
  ## Installation or Upgrade
293
295
 
294
- Arch users can install [edir from the AUR](https://aur.archlinux.org/packages/edir/).
296
+ Python 3.8 or later is required. Arch Linux users can install [`edir`
297
+ from the AUR](https://aur.archlinux.org/packages/edir) and skip this
298
+ section.
295
299
 
296
- Python 3.6 or later is required. Note [edir is on
297
- PyPI](https://pypi.org/project/edir/) so just ensure that
298
- [`pipx`](https://pypa.github.io/pipx/) is installed then type the
299
- following:
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:
300
303
 
301
304
  ```
302
305
  $ pipx install edir
@@ -371,8 +374,9 @@ Type `edir -h` to view the usage summary:
371
374
 
372
375
  ```
373
376
  usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
374
- [-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d] [-F | -D]
375
- [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z] [--suffix SUFFIX] [-V]
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]
376
380
  [args ...]
377
381
 
378
382
  Program to rename, remove, or copy files and directories using your editor.
@@ -402,8 +406,8 @@ options:
402
406
  -c, --no-color do not color rename/remove/copy messages
403
407
  -C, --no-invert-color
404
408
  do not invert the color to highlight error messages
405
- -d, --dirnames edit given directory names directly, not their
406
- contents
409
+ -d DEPTH, --depth DEPTH
410
+ edit paths to specified depth, default=1
407
411
  -F, --files only show/edit files
408
412
  -D, --dirs only show/edit directories
409
413
  -L, --nolinks ignore all symlinks
@@ -427,7 +431,7 @@ shortforms) allow you to temporarily override your defaults.
427
431
  ## Embed in Ranger File Manager
428
432
 
429
433
  In many ways `edir` (and `vidir`) is better than the
430
- [ranger](https://ranger.github.io/)
434
+ [ranger](https://ranger.github.io/) terminal file manager
431
435
  [bulkrename](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
432
436
  command which does not handle name swaps and clashes etc. To add `edir`
433
437
  as a command within [ranger](https://ranger.github.io/), add or create
@@ -450,17 +454,25 @@ class edir(Command):
450
454
  return self._tab_directory_content()
451
455
  ```
452
456
 
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`.
459
+
453
460
  ## License
454
461
 
455
462
  Copyright (C) 2019 Mark Blakeney. This program is distributed under the
456
- terms of the GNU General Public License.
457
- This program is free software: you can redistribute it and/or modify it
458
- under the terms of the GNU General Public License as published by the
459
- Free Software Foundation, either version 3 of the License, or any later
460
- version.
461
- This program is distributed in the hope that it will be useful, but
462
- WITHOUT ANY WARRANTY; without even the implied warranty of
463
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
464
- Public License at <http://www.gnu.org/licenses/> for more details.
463
+ terms of the GNU General Public License. This program is free software:
464
+ you can redistribute it and/or modify it under the terms of the GNU
465
+ General Public License as published by the Free Software Foundation,
466
+ either version 3 of the License, or any later version. This program is
467
+ distributed in the hope that it will be useful, but WITHOUT ANY
468
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
469
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at
470
+ <http://www.gnu.org/licenses/> for more details.
471
+
472
+ [edir]: https://github.com/bulletmark/edir
473
+ [edirpy]: https://pypi.org/project/edir
474
+ [pipx]: https://github.com/pypa/pipx
475
+ [pipxu]: https://github.com/bulletmark/pipxu
476
+ [uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
465
477
 
466
478
  <!-- vim: se ai syn=markdown: -->
@@ -2,16 +2,16 @@
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](http://github.com/bulletmark/edir) is a command line utility to
6
- rename, remove, and copy filenames and directories using your text
7
- editor. Run it in the current directory and `edir` will open your editor
8
- on a list of files and directories in that directory. Each item in the
9
- directory will appear on its own numbered line. These numbers are how
10
- `edir` keeps track of what items are changed. Delete lines to remove
11
- files/directories, edit lines to rename files/directories, or duplicate
12
- line numbers to copy files/directories. You can also switch pairs of
13
- numbers to swap files or directories. If run from within a
14
- [Git](https://git-scm.com/) repository, `edir` will [use
5
+ [edir][edir] is a command line utility to rename, remove, and copy
6
+ filenames and directories using your text editor. Run it in the current
7
+ directory and `edir` will open your editor on a list of files and
8
+ directories in that directory. Each item in the directory will appear on
9
+ its own numbered line. These numbers are how `edir` keeps track of what
10
+ items are changed. Delete lines to remove files/directories, edit lines
11
+ to rename files/directories, or duplicate line numbers to copy
12
+ files/directories. You can also switch pairs of numbers to swap files or
13
+ directories. If run from within a [Git](https://git-scm.com/)
14
+ repository, `edir` will [use
15
15
  Git](#renames-and-deletes-in-a-git-repository) to rename or remove
16
16
  tracked files/directories. You can use a [trash program](#using-trash)
17
17
  to remove files.
@@ -21,10 +21,10 @@ https://github.com/bulletmark/edir.
21
21
 
22
22
  ## Advantages Compared to Vidir
23
23
 
24
- [edir](http://github.com/bulletmark/edir) unashamedly mimics the
25
- functionality of the [vidir](https://linux.die.net/man/1/vidir) utility
26
- from [moreutils](https://joeyh.name/code/moreutils/) but aims to improve it in
27
- the following ways:
24
+ [edir][edir] unashamedly mimics the functionality of the
25
+ [vidir](https://linux.die.net/man/1/vidir) utility from
26
+ [moreutils](https://joeyh.name/code/moreutils/) but aims to improve it
27
+ in the following ways:
28
28
 
29
29
  1. `edir` automatically uses `git mv` instead of `mv` and `git rm`
30
30
  instead of `rm` for tracked files when invoked within a
@@ -59,11 +59,12 @@ the following ways:
59
59
  directory `c` to `e`.
60
60
 
61
61
  Note also, that both `edir` and `vidir` show the leading `./` on each
62
- entry so that any leading spaces are clearly seen, and can be edited.
62
+ entry so that any leading spaces on the filename are clearly seen,
63
+ and can be edited.
63
64
 
64
65
  3. `edir` adds the ability to copy files or directories one or more
65
- times when you duplicate a numbered line. `vidir` does not have copy
66
- functionality.
66
+ times when you duplicate a numbered line (after the original).
67
+ `vidir` does not have copy functionality.
67
68
 
68
69
  4. `edir` allows you to remove a file/directory by deleting the line, as
69
70
  `vidir` does, but you can also remove it by pre-pending a `#` to
@@ -111,9 +112,11 @@ the following ways:
111
112
 
112
113
  13. `edir` adds a `-L/--nolinks` option to ignore symbolic links.
113
114
 
114
- 14. `edir` adds a `-d/--dirnames` option to edit specified directory
115
- names directly, not their contents. I.e. this is like `ls -d mydir`
116
- compared to `ls mydir`.
115
+ 14. `edir` adds a `-d/--depth` option to edit to the specified directory
116
+ depth. The default is 1 so `edir a` (if a is a directory) will edit
117
+ names to `a/*`, `edir -d2 a` will edit names to `a/*/*`, etc. `edir
118
+ -d0 a` will just edit the `a` name directly. Can specify `-1` to
119
+ edit to all depths (or use a large positive number).
117
120
 
118
121
  15. `edir` adds a [`-t/--trash` option](#using-trash) to remove to your
119
122
  [Trash](https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html).
@@ -277,12 +280,13 @@ where:
277
280
 
278
281
  ## Installation or Upgrade
279
282
 
280
- Arch users can install [edir from the AUR](https://aur.archlinux.org/packages/edir/).
283
+ Python 3.8 or later is required. Arch Linux users can install [`edir`
284
+ from the AUR](https://aur.archlinux.org/packages/edir) and skip this
285
+ section.
281
286
 
282
- Python 3.6 or later is required. Note [edir is on
283
- PyPI](https://pypi.org/project/edir/) so just ensure that
284
- [`pipx`](https://pypa.github.io/pipx/) is installed then type the
285
- following:
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:
286
290
 
287
291
  ```
288
292
  $ pipx install edir
@@ -357,8 +361,9 @@ Type `edir -h` to view the usage summary:
357
361
 
358
362
  ```
359
363
  usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
360
- [-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d] [-F | -D]
361
- [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z] [--suffix SUFFIX] [-V]
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]
362
367
  [args ...]
363
368
 
364
369
  Program to rename, remove, or copy files and directories using your editor.
@@ -388,8 +393,8 @@ options:
388
393
  -c, --no-color do not color rename/remove/copy messages
389
394
  -C, --no-invert-color
390
395
  do not invert the color to highlight error messages
391
- -d, --dirnames edit given directory names directly, not their
392
- contents
396
+ -d DEPTH, --depth DEPTH
397
+ edit paths to specified depth, default=1
393
398
  -F, --files only show/edit files
394
399
  -D, --dirs only show/edit directories
395
400
  -L, --nolinks ignore all symlinks
@@ -413,7 +418,7 @@ shortforms) allow you to temporarily override your defaults.
413
418
  ## Embed in Ranger File Manager
414
419
 
415
420
  In many ways `edir` (and `vidir`) is better than the
416
- [ranger](https://ranger.github.io/)
421
+ [ranger](https://ranger.github.io/) terminal file manager
417
422
  [bulkrename](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
418
423
  command which does not handle name swaps and clashes etc. To add `edir`
419
424
  as a command within [ranger](https://ranger.github.io/), add or create
@@ -436,17 +441,25 @@ class edir(Command):
436
441
  return self._tab_directory_content()
437
442
  ```
438
443
 
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`.
446
+
439
447
  ## License
440
448
 
441
449
  Copyright (C) 2019 Mark Blakeney. This program is distributed under the
442
- terms of the GNU General Public License.
443
- This program is free software: you can redistribute it and/or modify it
444
- under the terms of the GNU General Public License as published by the
445
- Free Software Foundation, either version 3 of the License, or any later
446
- version.
447
- This program is distributed in the hope that it will be useful, but
448
- WITHOUT ANY WARRANTY; without even the implied warranty of
449
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
450
- Public License at <http://www.gnu.org/licenses/> for more details.
450
+ terms of the GNU General Public License. This program is free software:
451
+ you can redistribute it and/or modify it under the terms of the GNU
452
+ General Public License as published by the Free Software Foundation,
453
+ either version 3 of the License, or any later version. This program is
454
+ distributed in the hope that it will be useful, but WITHOUT ANY
455
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
456
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at
457
+ <http://www.gnu.org/licenses/> for more details.
458
+
459
+ [edir]: https://github.com/bulletmark/edir
460
+ [edirpy]: https://pypi.org/project/edir
461
+ [pipx]: https://github.com/pypa/pipx
462
+ [pipxu]: https://github.com/bulletmark/pipxu
463
+ [uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
451
464
 
452
465
  <!-- vim: se ai syn=markdown: -->
@@ -1,31 +1,30 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: edir
3
- Version: 2.28
3
+ Version: 2.30
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
6
  License: GPLv3
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
10
- Requires-Python: >=3.6
10
+ Requires-Python: >=3.8
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: platformdirs
13
- Requires-Dist: importlib-metadata; python_version < "3.8"
14
13
 
15
14
  ## EDIR - Rename, Remove, and Copy Files and Directories Using Your Editor
16
15
  [![PyPi](https://img.shields.io/pypi/v/edir)](https://pypi.org/project/edir/)
17
16
  [![AUR](https://img.shields.io/aur/version/edir)](https://aur.archlinux.org/packages/edir/)
18
17
 
19
- [edir](http://github.com/bulletmark/edir) is a command line utility to
20
- rename, remove, and copy filenames and directories using your text
21
- editor. Run it in the current directory and `edir` will open your editor
22
- on a list of files and directories in that directory. Each item in the
23
- directory will appear on its own numbered line. These numbers are how
24
- `edir` keeps track of what items are changed. Delete lines to remove
25
- files/directories, edit lines to rename files/directories, or duplicate
26
- line numbers to copy files/directories. You can also switch pairs of
27
- numbers to swap files or directories. If run from within a
28
- [Git](https://git-scm.com/) repository, `edir` will [use
18
+ [edir][edir] is a command line utility to rename, remove, and copy
19
+ filenames and directories using your text editor. Run it in the current
20
+ directory and `edir` will open your editor on a list of files and
21
+ directories in that directory. Each item in the directory will appear on
22
+ its own numbered line. These numbers are how `edir` keeps track of what
23
+ items are changed. Delete lines to remove files/directories, edit lines
24
+ to rename files/directories, or duplicate line numbers to copy
25
+ files/directories. You can also switch pairs of numbers to swap files or
26
+ directories. If run from within a [Git](https://git-scm.com/)
27
+ repository, `edir` will [use
29
28
  Git](#renames-and-deletes-in-a-git-repository) to rename or remove
30
29
  tracked files/directories. You can use a [trash program](#using-trash)
31
30
  to remove files.
@@ -35,10 +34,10 @@ https://github.com/bulletmark/edir.
35
34
 
36
35
  ## Advantages Compared to Vidir
37
36
 
38
- [edir](http://github.com/bulletmark/edir) unashamedly mimics the
39
- functionality of the [vidir](https://linux.die.net/man/1/vidir) utility
40
- from [moreutils](https://joeyh.name/code/moreutils/) but aims to improve it in
41
- the following ways:
37
+ [edir][edir] unashamedly mimics the functionality of the
38
+ [vidir](https://linux.die.net/man/1/vidir) utility from
39
+ [moreutils](https://joeyh.name/code/moreutils/) but aims to improve it
40
+ in the following ways:
42
41
 
43
42
  1. `edir` automatically uses `git mv` instead of `mv` and `git rm`
44
43
  instead of `rm` for tracked files when invoked within a
@@ -73,11 +72,12 @@ the following ways:
73
72
  directory `c` to `e`.
74
73
 
75
74
  Note also, that both `edir` and `vidir` show the leading `./` on each
76
- entry so that any leading spaces are clearly seen, and can be edited.
75
+ entry so that any leading spaces on the filename are clearly seen,
76
+ and can be edited.
77
77
 
78
78
  3. `edir` adds the ability to copy files or directories one or more
79
- times when you duplicate a numbered line. `vidir` does not have copy
80
- functionality.
79
+ times when you duplicate a numbered line (after the original).
80
+ `vidir` does not have copy functionality.
81
81
 
82
82
  4. `edir` allows you to remove a file/directory by deleting the line, as
83
83
  `vidir` does, but you can also remove it by pre-pending a `#` to
@@ -125,9 +125,11 @@ the following ways:
125
125
 
126
126
  13. `edir` adds a `-L/--nolinks` option to ignore symbolic links.
127
127
 
128
- 14. `edir` adds a `-d/--dirnames` option to edit specified directory
129
- names directly, not their contents. I.e. this is like `ls -d mydir`
130
- compared to `ls mydir`.
128
+ 14. `edir` adds a `-d/--depth` option to edit to the specified directory
129
+ depth. The default is 1 so `edir a` (if a is a directory) will edit
130
+ names to `a/*`, `edir -d2 a` will edit names to `a/*/*`, etc. `edir
131
+ -d0 a` will just edit the `a` name directly. Can specify `-1` to
132
+ edit to all depths (or use a large positive number).
131
133
 
132
134
  15. `edir` adds a [`-t/--trash` option](#using-trash) to remove to your
133
135
  [Trash](https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html).
@@ -291,12 +293,13 @@ where:
291
293
 
292
294
  ## Installation or Upgrade
293
295
 
294
- Arch users can install [edir from the AUR](https://aur.archlinux.org/packages/edir/).
296
+ Python 3.8 or later is required. Arch Linux users can install [`edir`
297
+ from the AUR](https://aur.archlinux.org/packages/edir) and skip this
298
+ section.
295
299
 
296
- Python 3.6 or later is required. Note [edir is on
297
- PyPI](https://pypi.org/project/edir/) so just ensure that
298
- [`pipx`](https://pypa.github.io/pipx/) is installed then type the
299
- following:
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:
300
303
 
301
304
  ```
302
305
  $ pipx install edir
@@ -371,8 +374,9 @@ Type `edir -h` to view the usage summary:
371
374
 
372
375
  ```
373
376
  usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
374
- [-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d] [-F | -D]
375
- [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z] [--suffix SUFFIX] [-V]
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]
376
380
  [args ...]
377
381
 
378
382
  Program to rename, remove, or copy files and directories using your editor.
@@ -402,8 +406,8 @@ options:
402
406
  -c, --no-color do not color rename/remove/copy messages
403
407
  -C, --no-invert-color
404
408
  do not invert the color to highlight error messages
405
- -d, --dirnames edit given directory names directly, not their
406
- contents
409
+ -d DEPTH, --depth DEPTH
410
+ edit paths to specified depth, default=1
407
411
  -F, --files only show/edit files
408
412
  -D, --dirs only show/edit directories
409
413
  -L, --nolinks ignore all symlinks
@@ -427,7 +431,7 @@ shortforms) allow you to temporarily override your defaults.
427
431
  ## Embed in Ranger File Manager
428
432
 
429
433
  In many ways `edir` (and `vidir`) is better than the
430
- [ranger](https://ranger.github.io/)
434
+ [ranger](https://ranger.github.io/) terminal file manager
431
435
  [bulkrename](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
432
436
  command which does not handle name swaps and clashes etc. To add `edir`
433
437
  as a command within [ranger](https://ranger.github.io/), add or create
@@ -450,17 +454,25 @@ class edir(Command):
450
454
  return self._tab_directory_content()
451
455
  ```
452
456
 
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`.
459
+
453
460
  ## License
454
461
 
455
462
  Copyright (C) 2019 Mark Blakeney. This program is distributed under the
456
- terms of the GNU General Public License.
457
- This program is free software: you can redistribute it and/or modify it
458
- under the terms of the GNU General Public License as published by the
459
- Free Software Foundation, either version 3 of the License, or any later
460
- version.
461
- This program is distributed in the hope that it will be useful, but
462
- WITHOUT ANY WARRANTY; without even the implied warranty of
463
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
464
- Public License at <http://www.gnu.org/licenses/> for more details.
463
+ terms of the GNU General Public License. This program is free software:
464
+ you can redistribute it and/or modify it under the terms of the GNU
465
+ General Public License as published by the Free Software Foundation,
466
+ either version 3 of the License, or any later version. This program is
467
+ distributed in the hope that it will be useful, but WITHOUT ANY
468
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
469
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at
470
+ <http://www.gnu.org/licenses/> for more details.
471
+
472
+ [edir]: https://github.com/bulletmark/edir
473
+ [edirpy]: https://pypi.org/project/edir
474
+ [pipx]: https://github.com/pypa/pipx
475
+ [pipxu]: https://github.com/bulletmark/pipxu
476
+ [uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
465
477
 
466
478
  <!-- vim: se ai syn=markdown: -->
@@ -0,0 +1 @@
1
+ platformdirs
@@ -5,6 +5,7 @@ editor. Will use git to action the rename and remove if run within a git
5
5
  repository.
6
6
  '''
7
7
  # Author: Mark Blakeney, May 2019.
8
+ from __future__ import annotations
8
9
 
9
10
  import argparse
10
11
  import itertools
@@ -17,7 +18,7 @@ import sys
17
18
  import tempfile
18
19
  from collections import OrderedDict
19
20
  from pathlib import Path
20
- from typing import List, Optional, Tuple
21
+ from typing import Callable, Sequence, Iterable
21
22
 
22
23
  from platformdirs import user_config_path
23
24
 
@@ -72,7 +73,7 @@ def editfile(filename: Path) -> None:
72
73
  if res.returncode != 0:
73
74
  sys.exit(f'ERROR: {editor} returned error {res.returncode}')
74
75
 
75
- def log(action: str, msg: str, error: Optional[str] = None, *,
76
+ def log(action: str, msg: str, error: str | None = None, *,
76
77
  prompt: bool = False) -> None:
77
78
  'Output message with appropriate color'
78
79
  counts[bool(error)] += 1
@@ -94,12 +95,12 @@ def log(action: str, msg: str, error: Optional[str] = None, *,
94
95
 
95
96
  print(msg, file=out)
96
97
 
97
- def run(cmd: str) -> Tuple[str, str]:
98
+ def run(cmd: Sequence[str]) -> tuple[str, str]:
98
99
  'Run given command and return (stdout, stderr) strings'
99
100
  stdout = ''
100
101
  stderr = ''
101
102
  try:
102
- res = subprocess.run(cmd, stdout=subprocess.PIPE, shell=True,
103
+ res = subprocess.run(cmd, stdout=subprocess.PIPE,
103
104
  stderr=subprocess.PIPE, universal_newlines=True)
104
105
  except Exception as e:
105
106
  stderr = str(e)
@@ -112,20 +113,22 @@ def run(cmd: str) -> Tuple[str, str]:
112
113
  return stdout, stderr
113
114
 
114
115
  def remove(path: Path, git: bool = False, trash: bool = False,
115
- recurse: bool = False) -> Optional[str]:
116
+ recurse: bool = False) -> str | None:
116
117
  'Delete given file/directory'
117
118
  if not recurse and not path.is_symlink() and path.is_dir() and \
118
119
  any(path.iterdir()):
119
120
  return 'Directory not empty'
120
121
 
121
122
  if git:
122
- ropt = '-r' if recurse else ''
123
- out, err = run(f'git rm -f {ropt} "{path}"')
123
+ cmd = 'git rm -f'.split()
124
+ if recurse:
125
+ cmd.append('-r')
126
+ out, err = run(cmd + [str(path)])
124
127
  return f'git error: {err}' if err else None
125
128
 
126
129
  if trash:
127
- out, err = run(f'{args.trash_program} "{path}"')
128
- return f'{args.trash_program} error: {err}' if err else None
130
+ out, err = run(args.trash_program + [str(path)])
131
+ return f'{shlex.join(args.trash_program)} error: {err}' if err else None
129
132
 
130
133
  if recurse and not path.is_symlink():
131
134
  try:
@@ -144,7 +147,7 @@ def remove(path: Path, git: bool = False, trash: bool = False,
144
147
  def rename(pathsrc: Path, pathdest: Path, is_git: bool = False) -> str:
145
148
  'Rename given pathsrc to pathdest'
146
149
  if is_git:
147
- out, err = run(f'git mv -f "{pathsrc}" "{pathdest}"')
150
+ out, err = run('git mv -f'.split() + [str(pathsrc), str(pathdest)])
148
151
  if err:
149
152
  err = f'git mv error: {err}'
150
153
  else:
@@ -171,6 +174,19 @@ def create_prompt(options: str) -> str:
171
174
  words.append('/'.join(subwords))
172
175
  return ', '.join(words) + ': [' + '|'.join(letters) + ']? '
173
176
 
177
+ def find_in_dir(path: Path, depth: int, allfiles: bool) -> Iterable[Path]:
178
+ 'Find files/dirs in given path'
179
+ if depth == 0:
180
+ yield path
181
+ return
182
+
183
+ for p in sorted(path.iterdir()):
184
+ if allfiles or not p.name.startswith('.'):
185
+ if not p.is_dir() or depth == 1:
186
+ yield p
187
+ else:
188
+ yield from find_in_dir(p, depth - 1, allfiles)
189
+
174
190
  class Fpath:
175
191
  'Class to manage each instance of a file/dir'
176
192
  paths = []
@@ -182,7 +198,7 @@ class Fpath:
182
198
  self.newpath = None
183
199
  self.temppath = None
184
200
  self.note = ''
185
- self.copies: List[Path] = []
201
+ self.copies: list[Path] = []
186
202
  try:
187
203
  self.is_dir = path.is_dir() and not path.is_symlink()
188
204
  except Exception as e:
@@ -211,15 +227,24 @@ class Fpath:
211
227
 
212
228
  return path
213
229
 
214
- def copy(self, pathdest: Path) -> Optional[str]:
230
+ def copy(self, pathdest: Path) -> str | None:
215
231
  'Copy given pathsrc to pathdest'
216
- func = shutil.copytree if self.is_dir else shutil.copy2
232
+ if self.is_dir:
233
+ func: Callable = shutil.copytree
234
+ else:
235
+ func = shutil.copy2
236
+
237
+ # copytree() will create the parent dir[s], but copy2() will not
238
+ try:
239
+ pathdest.parent.mkdir(parents=True, exist_ok=True)
240
+ except Exception as e:
241
+ return str(e)
217
242
  try:
218
243
  func(str(self.newpath), str(pathdest)) # type:ignore
219
244
  except Exception as e:
220
245
  return str(e)
221
246
 
222
- def rename_temp(self) -> Optional[str]:
247
+ def rename_temp(self) -> str | None:
223
248
  'Move this path to a temp place in advance of final move'
224
249
  if not self.newpath:
225
250
  return None
@@ -233,13 +258,12 @@ class Fpath:
233
258
 
234
259
  self.tempdirs.add(tempdir)
235
260
  temppath = self.inc_path(tempdir / self.newpath.name)
236
- err = rename(self.path, temppath, self.is_git)
237
- if not err:
261
+ if not (err := rename(self.path, temppath, self.is_git)):
238
262
  self.temppath = temppath
239
263
 
240
264
  return err
241
265
 
242
- def restore_temp(self) -> Optional[str]:
266
+ def restore_temp(self) -> str | None:
243
267
  'Restore temp path to final destination'
244
268
  if not self.temppath or not self.newpath:
245
269
  return None
@@ -314,16 +338,15 @@ class Fpath:
314
338
  cls.paths.append(cls(path))
315
339
 
316
340
  @classmethod
317
- def add(cls, name: str, expand: bool) -> None:
341
+ def add(cls, name: str, depth: int) -> None:
318
342
  'Add file[s]/dir[s] to the list of paths'
319
343
  path = Path(name)
320
344
  if not path.exists():
321
345
  sys.exit(f'ERROR: {name} does not exist')
322
346
 
323
- if expand and path.is_dir():
324
- for child in sorted(path.iterdir()):
325
- if args.all or not child.name.startswith('.'):
326
- cls.append(child)
347
+ if path.is_dir():
348
+ for child in find_in_dir(path, depth, args.all):
349
+ cls.append(child)
327
350
  else:
328
351
  cls.append(path)
329
352
 
@@ -381,7 +404,7 @@ class Fpath:
381
404
  path.newpath = newpath
382
405
 
383
406
  @classmethod
384
- def get_path_changes(cls) -> List:
407
+ def get_path_changes(cls) -> list:
385
408
  'Get a list of change paths from the user'
386
409
  prompt = create_prompt('proceed/yes edit restart quit[default]') \
387
410
  if args.interactive else None
@@ -442,7 +465,7 @@ def main() -> int:
442
465
  'Main code'
443
466
  global args
444
467
  # Process command line options
445
- opt = argparse.ArgumentParser(description=__doc__.strip(),
468
+ opt = argparse.ArgumentParser(description=__doc__,
446
469
  epilog='Note you can set default starting options in '
447
470
  f'{CNFFILE}. The negation options (i.e. the --no-* options '
448
471
  'and their shortforms) allow you to temporarily override your '
@@ -482,8 +505,8 @@ def main() -> int:
482
505
  help='do not color rename/remove/copy messages')
483
506
  opt.add_argument('-C', '--no-invert-color', action='store_true',
484
507
  help='do not invert the color to highlight error messages')
485
- opt.add_argument('-d', '--dirnames', action='store_true',
486
- help='edit given directory names directly, not their contents')
508
+ opt.add_argument('-d', '--depth', type=int, default=1,
509
+ help='edit paths to specified depth, default=%(default)d')
487
510
  grp = opt.add_mutually_exclusive_group()
488
511
  grp.add_argument('-F', '--files', action='store_true',
489
512
  help='only show/edit files')
@@ -530,11 +553,7 @@ def main() -> int:
530
553
  args = opt.parse_args(shlex.split(cnflines) + sys.argv[1:])
531
554
 
532
555
  if args.version:
533
- if sys.version_info >= (3, 8):
534
- from importlib.metadata import version
535
- else:
536
- from importlib_metadata import version
537
-
556
+ from importlib.metadata import version
538
557
  try:
539
558
  ver = version(PROG)
540
559
  except Exception:
@@ -543,9 +562,15 @@ def main() -> int:
543
562
  print(ver)
544
563
  return 0
545
564
 
565
+ if args.trash:
566
+ if not args.trash_program:
567
+ opt.error('must specify trash program with --trash-program option')
568
+
569
+ args.trash_program = args.trash_program.split()
570
+
546
571
  # Check if we are in a git repo
547
572
  if args.git != 0:
548
- out, giterr = run('git ls-files')
573
+ out, giterr = run(('git', 'ls-files'))
549
574
  if giterr and args.git:
550
575
  print(f'Git invocation error: {giterr}', file=sys.stderr)
551
576
  if out:
@@ -566,11 +591,9 @@ def main() -> int:
566
591
  for name in OrderedDict.fromkeys(filelist):
567
592
  if name == '-':
568
593
  for line in sys.stdin:
569
- name = line.rstrip('\n\r')
570
- if name != '.':
571
- Fpath.add(line.rstrip('\n\r'), False)
594
+ Fpath.add(line.rstrip('\n\r'), 0)
572
595
  else:
573
- Fpath.add(name, not args.dirnames)
596
+ Fpath.add(name, args.depth)
574
597
 
575
598
  # Sanity check that we have something to edit
576
599
  if not Fpath.paths:
@@ -587,8 +610,8 @@ def main() -> int:
587
610
  Fpath.paths.sort(key=Fpath.sort_size, reverse=args.sort_reverse)
588
611
 
589
612
  if args.group_dirs is not None and args.group_dirs >= 0:
590
- ldirs: List[Fpath] = []
591
- lfiles: List[Fpath] = []
613
+ ldirs: list[Fpath] = []
614
+ lfiles: list[Fpath] = []
592
615
  for path in Fpath.paths:
593
616
  (ldirs if path.is_dir else lfiles).append(path)
594
617
  Fpath.paths = ldirs + lfiles if args.group_dirs else lfiles + ldirs
@@ -597,15 +620,14 @@ def main() -> int:
597
620
  if not paths:
598
621
  return 0
599
622
 
600
- err: Optional[str]
623
+ err: str | None
601
624
 
602
625
  # Pass 1: Rename all moved files & dirs to temps, delete all removed
603
626
  # files.
604
627
  for p in paths:
605
628
  if p.newpath:
606
629
  if p.newpath != p.path:
607
- err = p.rename_temp()
608
- if err:
630
+ if err := p.rename_temp():
609
631
  log('rename',
610
632
  f'"{p.diagrepr}" to "{p.newpath}{p.appdash}"', err)
611
633
  elif not p.is_dir:
@@ -623,8 +645,7 @@ def main() -> int:
623
645
  # Pass 3. Rename all temp files and dirs to final target, and make
624
646
  # copies.
625
647
  for p in paths:
626
- err = p.restore_temp()
627
- if err is not None:
648
+ if (err := p.restore_temp()) is not None:
628
649
  log('rename', f'"{p.diagrepr}" to "{p.newpath}{p.appdash}"', err)
629
650
 
630
651
  for c in p.copies:
@@ -6,7 +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
- requires-python = ">=3.6"
9
+ requires-python = ">=3.8"
10
10
  keywords = ["vidir", "git", "trash", "trash-put", "thrash-d"]
11
11
  classifiers = [
12
12
  "Programming Language :: Python :: 3",
@@ -14,7 +14,6 @@ classifiers = [
14
14
  dynamic = ["version"]
15
15
  dependencies = [
16
16
  "platformdirs",
17
- "importlib-metadata; python_version < '3.8'",
18
17
  ]
19
18
 
20
19
  [[project.authors]]
@@ -1,4 +0,0 @@
1
- platformdirs
2
-
3
- [:python_version < "3.8"]
4
- importlib-metadata
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes