more verbose
This commit is contained in:
parent
fb8d21505d
commit
07ad688af6
7 changed files with 100 additions and 15 deletions
27
.context.yaml
Normal file
27
.context.yaml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
items:
|
||||
COMMANDS.md:
|
||||
contexts: []
|
||||
projects: []
|
||||
tags:
|
||||
- super
|
||||
- great
|
||||
README.md:
|
||||
contexts: []
|
||||
projects: []
|
||||
tags:
|
||||
- fool
|
||||
- writeme
|
||||
TODO.md:
|
||||
contexts:
|
||||
- bbb
|
||||
- python
|
||||
note: Chawera
|
||||
projects:
|
||||
- fool
|
||||
- proooo
|
||||
- bokertov
|
||||
tags:
|
||||
- ttt
|
||||
- rusty
|
||||
- frrr
|
||||
- xxx
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,2 +1,2 @@
|
|||
__pycache__/
|
||||
.context.yaml
|
||||
#.context.yaml
|
||||
|
|
@ -145,31 +145,64 @@ def main():
|
|||
|
||||
elif args.command in ['copy', 'cp']:
|
||||
if args.file and args.context:
|
||||
orvani.move(args.file, args.context[0], True, args.no_file_operation)
|
||||
fb = orvani.move(args.file, args.context[0], True, args.no_file_operation)
|
||||
if fb[0] == 0:
|
||||
console.print(f':dancers: File [strong]{fb[1]}[/strong] with entry {nice_context(fb[3])}successfully copied to [strong]{fb[2]}[/strong]')
|
||||
elif fb[0] == 1:
|
||||
if fb[3] == False and fb[4] == True:
|
||||
console.print(f":thinking_face: Source file [strong]{fb[1]}[/strong] doesn't exist.")
|
||||
elif fb[3] == True and fb[4] == False:
|
||||
console.print(f":thinking_face: Destination [strong]{fb[2]}[/strong] doesn't exist.")
|
||||
elif fb[3] == False and fb[4] == False:
|
||||
console.print(f":thinking_face: Source file [strong]{fb[1]}[/strong] and destination [strong]{fb[2]}[/strong] don't exist.")
|
||||
|
||||
elif args.command in ['move', 'mv']:
|
||||
if args.file and args.context:
|
||||
orvani.move(args.file, args.context[0], False, args.no_file_operation)
|
||||
fb = orvani.move(args.file, args.context[0], False, args.no_file_operation)
|
||||
if fb[0] == 0:
|
||||
console.print(f':dancers: File [strong]{fb[1]}[/strong] with entry {nice_context(fb[3])}successfully moved to [strong]{fb[2]}[/strong]')
|
||||
elif fb[0] == 1:
|
||||
if fb[3] == False and fb[4] == True:
|
||||
console.print(f":thinking_face: Source file [strong]{fb[1]}[/strong] doesn't exist.")
|
||||
elif fb[3] == True and fb[4] == False:
|
||||
console.print(f":thinking_face: Destination [strong]{fb[2]}[/strong] doesn't exist.")
|
||||
elif fb[3] == False and fb[4] == False:
|
||||
console.print(f":thinking_face: Source file [strong]{fb[1]}[/strong] and destination [strong]{fb[2]}[/strong] don't exist.")
|
||||
|
||||
elif args.command in ['del', 'rm']:
|
||||
if args.file:
|
||||
orvani.delete(args.file, args.no_file_operation)
|
||||
fb = orvani.delete(args.file, args.no_file_operation)
|
||||
if fb[0] == 0:
|
||||
status = f':wastebasket: Entry for [strong]{fb[1]}[/strong] successfully removed.'
|
||||
if fb[3]:
|
||||
status += f'\n:wastebasket: File [strong]{fb[1]}[/strong] successfully deleted.'
|
||||
if not fb[2] == None:
|
||||
status += f'\n:wastebasket: File [strong]{fb[2]}[/strong] automatically deleted.'
|
||||
console.print(status)
|
||||
elif fb[0] == 1:
|
||||
console.print(f":thinking_face: File [strong]{fb[1]}[/strong] doesn't exist.")
|
||||
elif fb[0] == 2:
|
||||
console.print(f":thinking_face: No entry for [strong]{fb[1]}[/strong] found.")
|
||||
|
||||
|
||||
elif args.command in ['purge']:
|
||||
def purge(path):
|
||||
target = Path(path)
|
||||
if target.is_file():
|
||||
target = Path(target.parent)
|
||||
if target.is_dir():
|
||||
context_file = target / CONTEXT_FILE
|
||||
cache_file = target / CACHE_FILE
|
||||
context_file.unlink(missing_ok=True)
|
||||
cache_file.unlink(missing_ok=True)
|
||||
if not args.file:
|
||||
args.file = '.'
|
||||
target = Path(args.file)
|
||||
context_file = target / CONTEXT_FILE
|
||||
cache_file = target / CACHE_FILE
|
||||
context_file.unlink(missing_ok=True)
|
||||
cache_file.unlink(missing_ok=True)
|
||||
purge(args.file)
|
||||
if args.not_recursive:
|
||||
for (root,dirs,files) in os.walk(args.file):
|
||||
if dirs:
|
||||
for dir in dirs:
|
||||
rpath = os.path.join(root, dir)
|
||||
Path(CONTEXT_FILE).unlink(missing_ok=True)
|
||||
Path(CACHE_FILE).unlink(missing_ok=True)
|
||||
purge(dir)
|
||||
|
||||
elif args.command in ['clean']:
|
||||
if not args.file:
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ class OrvaniTag:
|
|||
if target.name in self.DB:
|
||||
del self.DB[target.name]
|
||||
else:
|
||||
return [2, target.name]
|
||||
return [2, file]
|
||||
saved = self.__save()
|
||||
if not self.DB:
|
||||
Path(self.FILE).unlink(missing_ok=True)
|
||||
|
|
@ -271,10 +271,11 @@ class OrvaniTag:
|
|||
if retain:
|
||||
shutil.copy2(source, dest)
|
||||
else:
|
||||
shutil.move(source, dest, copy_function=shutil.copy2)
|
||||
shutil.copy2(source, dest)
|
||||
os.remove(source)
|
||||
return [0, source, dest, sourcedata]
|
||||
else:
|
||||
return [1, os.path.isfile(source), os.path.isdir(os.path.dirname(dest))]
|
||||
return [1, source, dest, os.path.isfile(source), os.path.isdir(os.path.dirname(dest))]
|
||||
|
||||
|
||||
def clean(self, path: str='.', recursive=True):
|
||||
|
|
|
|||
9
orvani/plugins/.context.yaml
Normal file
9
orvani/plugins/.context.yaml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
items:
|
||||
hashdoubleslash.py:
|
||||
contexts:
|
||||
- python
|
||||
note: It even works in Python code
|
||||
projects:
|
||||
- orvani
|
||||
tags:
|
||||
- example
|
||||
6
test/folder with spaces/.context.yaml
Normal file
6
test/folder with spaces/.context.yaml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
items:
|
||||
file with spaces.txt:
|
||||
contexts: []
|
||||
projects: []
|
||||
tags:
|
||||
- spaces
|
||||
9
test/sub/.context.yaml
Normal file
9
test/sub/.context.yaml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
items:
|
||||
statement_14793553_USD_2022-11-01_2023-01-31.pdf:
|
||||
contexts: []
|
||||
projects: []
|
||||
tags:
|
||||
- yay
|
||||
- frrrrrrrr
|
||||
frrr.txt:
|
||||
frrr
|
||||
Loading…
Add table
Add a link
Reference in a new issue