edir 2.39__tar.gz → 2.40__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.39 → edir-2.40}/PKG-INFO +3 -4
- {edir-2.39 → edir-2.40}/README.md +2 -3
- {edir-2.39 → edir-2.40}/edir.egg-info/PKG-INFO +3 -4
- {edir-2.39 → edir-2.40}/edir.egg-info/scm_file_list.json +4 -4
- edir-2.40/edir.egg-info/scm_version.json +8 -0
- {edir-2.39 → edir-2.40}/edir.py +30 -25
- {edir-2.39 → edir-2.40}/justfile +1 -1
- {edir-2.39 → edir-2.40}/pyproject.toml +3 -1
- edir-2.39/edir.egg-info/scm_version.json +0 -8
- {edir-2.39 → edir-2.40}/.gitignore +0 -0
- {edir-2.39 → edir-2.40}/edir.egg-info/SOURCES.txt +0 -0
- {edir-2.39 → edir-2.40}/edir.egg-info/dependency_links.txt +0 -0
- {edir-2.39 → edir-2.40}/edir.egg-info/entry_points.txt +0 -0
- {edir-2.39 → edir-2.40}/edir.egg-info/requires.txt +0 -0
- {edir-2.39 → edir-2.40}/edir.egg-info/top_level.txt +0 -0
- {edir-2.39 → edir-2.40}/setup.cfg +0 -0
{edir-2.39 → edir-2.40}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edir
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.40
|
|
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-Expression: GPL-3.0-or-later
|
|
@@ -345,8 +345,7 @@ You can add default options to a personal configuration file
|
|
|
345
345
|
`~/.config/edir-flags.conf`. If that file exists then each line of
|
|
346
346
|
options will be concatenated and automatically prepended to your `edir`
|
|
347
347
|
command line arguments. Comments in the file (i.e. starting with a `#`)
|
|
348
|
-
are ignored. Type `edir -h` to see all [supported
|
|
349
|
-
options](#command-line-options).
|
|
348
|
+
are ignored. Type `edir -h` to see all [supported options](#usage).
|
|
350
349
|
|
|
351
350
|
Some options, e.g. `--recurse`, which can be set as a default option, provide
|
|
352
351
|
another "on-the-fly" negation option to temporarily override and disable the
|
|
@@ -386,7 +385,7 @@ repository files only, in the current directory only:
|
|
|
386
385
|
$ fd -d1 -tf | edir -g
|
|
387
386
|
```
|
|
388
387
|
|
|
389
|
-
##
|
|
388
|
+
## Usage
|
|
390
389
|
|
|
391
390
|
Type `edir -h` to view the usage summary:
|
|
392
391
|
|
|
@@ -332,8 +332,7 @@ You can add default options to a personal configuration file
|
|
|
332
332
|
`~/.config/edir-flags.conf`. If that file exists then each line of
|
|
333
333
|
options will be concatenated and automatically prepended to your `edir`
|
|
334
334
|
command line arguments. Comments in the file (i.e. starting with a `#`)
|
|
335
|
-
are ignored. Type `edir -h` to see all [supported
|
|
336
|
-
options](#command-line-options).
|
|
335
|
+
are ignored. Type `edir -h` to see all [supported options](#usage).
|
|
337
336
|
|
|
338
337
|
Some options, e.g. `--recurse`, which can be set as a default option, provide
|
|
339
338
|
another "on-the-fly" negation option to temporarily override and disable the
|
|
@@ -373,7 +372,7 @@ repository files only, in the current directory only:
|
|
|
373
372
|
$ fd -d1 -tf | edir -g
|
|
374
373
|
```
|
|
375
374
|
|
|
376
|
-
##
|
|
375
|
+
## Usage
|
|
377
376
|
|
|
378
377
|
Type `edir -h` to view the usage summary:
|
|
379
378
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edir
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.40
|
|
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-Expression: GPL-3.0-or-later
|
|
@@ -345,8 +345,7 @@ You can add default options to a personal configuration file
|
|
|
345
345
|
`~/.config/edir-flags.conf`. If that file exists then each line of
|
|
346
346
|
options will be concatenated and automatically prepended to your `edir`
|
|
347
347
|
command line arguments. Comments in the file (i.e. starting with a `#`)
|
|
348
|
-
are ignored. Type `edir -h` to see all [supported
|
|
349
|
-
options](#command-line-options).
|
|
348
|
+
are ignored. Type `edir -h` to see all [supported options](#usage).
|
|
350
349
|
|
|
351
350
|
Some options, e.g. `--recurse`, which can be set as a default option, provide
|
|
352
351
|
another "on-the-fly" negation option to temporarily override and disable the
|
|
@@ -386,7 +385,7 @@ repository files only, in the current directory only:
|
|
|
386
385
|
$ fd -d1 -tf | edir -g
|
|
387
386
|
```
|
|
388
387
|
|
|
389
|
-
##
|
|
388
|
+
## Usage
|
|
390
389
|
|
|
391
390
|
Type `edir -h` to view the usage summary:
|
|
392
391
|
|
{edir-2.39 → edir-2.40}/edir.py
RENAMED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
1
|
"""
|
|
3
2
|
Command line utility to rename, remove, or copy files and directories directly
|
|
4
3
|
from your editor. When run, you'll see a numbered list of files in your editor.
|
|
@@ -10,17 +9,19 @@ repository, git will be used for renames and removals.
|
|
|
10
9
|
# Author: Mark Blakeney, May 2019.
|
|
11
10
|
from __future__ import annotations
|
|
12
11
|
|
|
13
|
-
import
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
if sys.version_info >= (3, 15):
|
|
15
|
+
sys.set_lazy_imports('all')
|
|
16
|
+
|
|
14
17
|
import os
|
|
15
|
-
import re
|
|
16
18
|
import shlex
|
|
17
19
|
import shutil
|
|
18
20
|
import subprocess
|
|
19
|
-
import sys
|
|
20
|
-
import tempfile
|
|
21
21
|
from collections.abc import Callable, Iterable, Sequence
|
|
22
|
+
from os.path import lexists
|
|
22
23
|
from pathlib import Path
|
|
23
|
-
from typing import NoReturn
|
|
24
|
+
from typing import ClassVar, NoReturn
|
|
24
25
|
|
|
25
26
|
import argparse_from_file as argparse
|
|
26
27
|
|
|
@@ -144,9 +145,7 @@ def run(cmd: Sequence[str]) -> tuple[str, str]:
|
|
|
144
145
|
stdout = ''
|
|
145
146
|
stderr = ''
|
|
146
147
|
try:
|
|
147
|
-
res = subprocess.run(
|
|
148
|
-
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True
|
|
149
|
-
)
|
|
148
|
+
res = subprocess.run(cmd, capture_output=True, text=True)
|
|
150
149
|
except Exception as e:
|
|
151
150
|
stderr = str(e)
|
|
152
151
|
else:
|
|
@@ -253,6 +252,7 @@ class CopyNameTemplate:
|
|
|
253
252
|
|
|
254
253
|
def __init__(self, template: str) -> None:
|
|
255
254
|
"Create a template for copy file/path names from given name"
|
|
255
|
+
import re
|
|
256
256
|
|
|
257
257
|
def _exit(msg: str) -> NoReturn:
|
|
258
258
|
sys.exit(f'ERROR: --copy-name-template "{template}" {msg}')
|
|
@@ -285,8 +285,8 @@ class CopyNameTemplate:
|
|
|
285
285
|
class Fpath:
|
|
286
286
|
"Class to manage each instance of a file/dir"
|
|
287
287
|
|
|
288
|
-
paths = []
|
|
289
|
-
tempdirs = set()
|
|
288
|
+
paths: ClassVar = []
|
|
289
|
+
tempdirs: ClassVar = set()
|
|
290
290
|
natsort_key: Callable
|
|
291
291
|
|
|
292
292
|
def __init__(self, path: Path) -> None:
|
|
@@ -314,6 +314,8 @@ class Fpath:
|
|
|
314
314
|
@staticmethod
|
|
315
315
|
def inc_path(path: Path, check_list: list[Path] | None = None) -> Path:
|
|
316
316
|
"Find next unique file name"
|
|
317
|
+
import itertools
|
|
318
|
+
|
|
317
319
|
# Iterate forever, there can only be a finite number of existing
|
|
318
320
|
# paths
|
|
319
321
|
if check_list is None:
|
|
@@ -321,7 +323,7 @@ class Fpath:
|
|
|
321
323
|
|
|
322
324
|
name = path.name
|
|
323
325
|
for c in itertools.count():
|
|
324
|
-
if not
|
|
326
|
+
if not lexists(path) and path not in check_list:
|
|
325
327
|
break
|
|
326
328
|
|
|
327
329
|
path = path.with_name(args._copy_name(name, c))
|
|
@@ -445,7 +447,7 @@ class Fpath:
|
|
|
445
447
|
try:
|
|
446
448
|
nsval = getattr(ns, opt)
|
|
447
449
|
except AttributeError as e:
|
|
448
|
-
sys.exit(f'ERROR: invalid natsort option: {
|
|
450
|
+
sys.exit(f'ERROR: invalid natsort option: {e}')
|
|
449
451
|
|
|
450
452
|
if nsval and isinstance(nsval, int):
|
|
451
453
|
optval |= nsval
|
|
@@ -469,9 +471,8 @@ class Fpath:
|
|
|
469
471
|
if args.files:
|
|
470
472
|
if path.is_dir():
|
|
471
473
|
return
|
|
472
|
-
elif args.dirs:
|
|
473
|
-
|
|
474
|
-
return
|
|
474
|
+
elif args.dirs and not path.is_dir():
|
|
475
|
+
return
|
|
475
476
|
|
|
476
477
|
# Filter out links if asked
|
|
477
478
|
if args.nolinks and path.is_symlink():
|
|
@@ -484,7 +485,7 @@ class Fpath:
|
|
|
484
485
|
"Add file[s]/dir[s] to the list of paths"
|
|
485
486
|
path = Path(name)
|
|
486
487
|
|
|
487
|
-
if not path
|
|
488
|
+
if not lexists(path):
|
|
488
489
|
sys.exit(f'ERROR: {name} does not exist')
|
|
489
490
|
|
|
490
491
|
if not args.no_relative:
|
|
@@ -556,6 +557,8 @@ class Fpath:
|
|
|
556
557
|
@classmethod
|
|
557
558
|
def get_path_changes(cls) -> list:
|
|
558
559
|
"Get a list of change paths from the user"
|
|
560
|
+
import tempfile
|
|
561
|
+
|
|
559
562
|
prompt = (
|
|
560
563
|
create_prompt('proceed/yes edit restart quit[default]')
|
|
561
564
|
if args.interactive
|
|
@@ -929,20 +932,22 @@ def main() -> int:
|
|
|
929
932
|
# files.
|
|
930
933
|
for p in paths:
|
|
931
934
|
if p.newpath:
|
|
932
|
-
if p.changed():
|
|
933
|
-
|
|
934
|
-
log('rename', f'"{p.diagrepr}" to "{p.newpath}{p.appdash}"', err)
|
|
935
|
+
if p.changed() and (err := p.rename_temp()):
|
|
936
|
+
log('rename', f'"{p.diagrepr}" to "{p.newpath}{p.appdash}"', err)
|
|
935
937
|
elif not p.is_dir:
|
|
936
938
|
err = remove(p.path, p.is_git, args.trash)
|
|
937
939
|
log('remove', f'"{p.diagrepr}"', err)
|
|
938
940
|
|
|
939
941
|
# Pass 2: Delete all removed dirs, if empty or recursive delete.
|
|
940
942
|
for p in paths:
|
|
941
|
-
if
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
943
|
+
if (
|
|
944
|
+
p.is_dir
|
|
945
|
+
and not p.newpath
|
|
946
|
+
and remove(p.path, p.is_git, args.trash, args.recurse) is None
|
|
947
|
+
):
|
|
948
|
+
# Have removed, so flag as finished for final dirs pass below
|
|
949
|
+
p.is_dir = False
|
|
950
|
+
log('remove', f'"{p.diagrepr}"{p.note}')
|
|
946
951
|
|
|
947
952
|
# Pass 3. Rename all temp files and dirs to final target, and make
|
|
948
953
|
# copies.
|
{edir-2.39 → edir-2.40}/justfile
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|