edir 2.28__tar.gz → 2.29__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 --eval-annotations --no-tips -i $(PYNAME).py
11
10
 
12
11
  build:
13
12
  rm -rf dist
@@ -1,16 +1,15 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: edir
3
- Version: 2.28
3
+ Version: 2.29
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/)
@@ -293,7 +292,7 @@ where:
293
292
 
294
293
  Arch users can install [edir from the AUR](https://aur.archlinux.org/packages/edir/).
295
294
 
296
- Python 3.6 or later is required. Note [edir is on
295
+ Python 3.8 or later is required. Note [edir is on
297
296
  PyPI](https://pypi.org/project/edir/) so just ensure that
298
297
  [`pipx`](https://pypa.github.io/pipx/) is installed then type the
299
298
  following:
@@ -279,7 +279,7 @@ where:
279
279
 
280
280
  Arch users can install [edir from the AUR](https://aur.archlinux.org/packages/edir/).
281
281
 
282
- Python 3.6 or later is required. Note [edir is on
282
+ Python 3.8 or later is required. Note [edir is on
283
283
  PyPI](https://pypi.org/project/edir/) so just ensure that
284
284
  [`pipx`](https://pypa.github.io/pipx/) is installed then type the
285
285
  following:
@@ -1,16 +1,15 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: edir
3
- Version: 2.28
3
+ Version: 2.29
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/)
@@ -293,7 +292,7 @@ where:
293
292
 
294
293
  Arch users can install [edir from the AUR](https://aur.archlinux.org/packages/edir/).
295
294
 
296
- Python 3.6 or later is required. Note [edir is on
295
+ Python 3.8 or later is required. Note [edir is on
297
296
  PyPI](https://pypi.org/project/edir/) so just ensure that
298
297
  [`pipx`](https://pypa.github.io/pipx/) is installed then type the
299
298
  following:
@@ -0,0 +1 @@
1
+ platformdirs
@@ -5,7 +5,6 @@ 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
-
9
8
  import argparse
10
9
  import itertools
11
10
  import os
@@ -17,7 +16,7 @@ import sys
17
16
  import tempfile
18
17
  from collections import OrderedDict
19
18
  from pathlib import Path
20
- from typing import List, Optional, Tuple
19
+ from typing import List, Optional, Tuple, Sequence, Callable
21
20
 
22
21
  from platformdirs import user_config_path
23
22
 
@@ -94,12 +93,12 @@ def log(action: str, msg: str, error: Optional[str] = None, *,
94
93
 
95
94
  print(msg, file=out)
96
95
 
97
- def run(cmd: str) -> Tuple[str, str]:
96
+ def run(cmd: Sequence[str]) -> Tuple[str, str]:
98
97
  'Run given command and return (stdout, stderr) strings'
99
98
  stdout = ''
100
99
  stderr = ''
101
100
  try:
102
- res = subprocess.run(cmd, stdout=subprocess.PIPE, shell=True,
101
+ res = subprocess.run(cmd, stdout=subprocess.PIPE,
103
102
  stderr=subprocess.PIPE, universal_newlines=True)
104
103
  except Exception as e:
105
104
  stderr = str(e)
@@ -119,13 +118,15 @@ def remove(path: Path, git: bool = False, trash: bool = False,
119
118
  return 'Directory not empty'
120
119
 
121
120
  if git:
122
- ropt = '-r' if recurse else ''
123
- out, err = run(f'git rm -f {ropt} "{path}"')
121
+ cmd = 'git rm -f'.split()
122
+ if recurse:
123
+ cmd.append('-r')
124
+ out, err = run(cmd + [str(path)])
124
125
  return f'git error: {err}' if err else None
125
126
 
126
127
  if trash:
127
- out, err = run(f'{args.trash_program} "{path}"')
128
- return f'{args.trash_program} error: {err}' if err else None
128
+ out, err = run(args.trash_program + [str(path)])
129
+ return f'{shlex.join(args.trash_program)} error: {err}' if err else None
129
130
 
130
131
  if recurse and not path.is_symlink():
131
132
  try:
@@ -144,7 +145,7 @@ def remove(path: Path, git: bool = False, trash: bool = False,
144
145
  def rename(pathsrc: Path, pathdest: Path, is_git: bool = False) -> str:
145
146
  'Rename given pathsrc to pathdest'
146
147
  if is_git:
147
- out, err = run(f'git mv -f "{pathsrc}" "{pathdest}"')
148
+ out, err = run('git mv -f'.split() + [str(pathsrc), str(pathdest)])
148
149
  if err:
149
150
  err = f'git mv error: {err}'
150
151
  else:
@@ -213,7 +214,16 @@ class Fpath:
213
214
 
214
215
  def copy(self, pathdest: Path) -> Optional[str]:
215
216
  'Copy given pathsrc to pathdest'
216
- func = shutil.copytree if self.is_dir else shutil.copy2
217
+ if self.is_dir:
218
+ func: Callable = shutil.copytree
219
+ else:
220
+ func = shutil.copy2
221
+
222
+ # copytree() will create the parent dir[s], but copy2() will not
223
+ try:
224
+ pathdest.parent.mkdir(parents=True, exist_ok=True)
225
+ except Exception as e:
226
+ return str(e)
217
227
  try:
218
228
  func(str(self.newpath), str(pathdest)) # type:ignore
219
229
  except Exception as e:
@@ -233,8 +243,7 @@ class Fpath:
233
243
 
234
244
  self.tempdirs.add(tempdir)
235
245
  temppath = self.inc_path(tempdir / self.newpath.name)
236
- err = rename(self.path, temppath, self.is_git)
237
- if not err:
246
+ if not (err := rename(self.path, temppath, self.is_git)):
238
247
  self.temppath = temppath
239
248
 
240
249
  return err
@@ -530,11 +539,7 @@ def main() -> int:
530
539
  args = opt.parse_args(shlex.split(cnflines) + sys.argv[1:])
531
540
 
532
541
  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
-
542
+ from importlib.metadata import version
538
543
  try:
539
544
  ver = version(PROG)
540
545
  except Exception:
@@ -543,9 +548,15 @@ def main() -> int:
543
548
  print(ver)
544
549
  return 0
545
550
 
551
+ if args.trash:
552
+ if not args.trash_program:
553
+ opt.error('must specify trash program with --trash-program option')
554
+
555
+ args.trash_program = args.trash_program.split()
556
+
546
557
  # Check if we are in a git repo
547
558
  if args.git != 0:
548
- out, giterr = run('git ls-files')
559
+ out, giterr = run(('git', 'ls-files'))
549
560
  if giterr and args.git:
550
561
  print(f'Git invocation error: {giterr}', file=sys.stderr)
551
562
  if out:
@@ -604,8 +615,7 @@ def main() -> int:
604
615
  for p in paths:
605
616
  if p.newpath:
606
617
  if p.newpath != p.path:
607
- err = p.rename_temp()
608
- if err:
618
+ if err := p.rename_temp():
609
619
  log('rename',
610
620
  f'"{p.diagrepr}" to "{p.newpath}{p.appdash}"', err)
611
621
  elif not p.is_dir:
@@ -623,8 +633,7 @@ def main() -> int:
623
633
  # Pass 3. Rename all temp files and dirs to final target, and make
624
634
  # copies.
625
635
  for p in paths:
626
- err = p.restore_temp()
627
- if err is not None:
636
+ if (err := p.restore_temp()) is not None:
628
637
  log('rename', f'"{p.diagrepr}" to "{p.newpath}{p.appdash}"', err)
629
638
 
630
639
  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