cleanup of list_all and delete_all
This commit is contained in:
parent
5673fe0337
commit
8f7d484559
1 changed files with 7 additions and 6 deletions
13
skratch.py
13
skratch.py
|
|
@ -11,10 +11,8 @@ def make_dir(d):
|
||||||
os.mkdir(d)
|
os.mkdir(d)
|
||||||
|
|
||||||
def delete_all(d):
|
def delete_all(d):
|
||||||
if not os.path.exists(d):
|
fc = list_all(d)
|
||||||
print("Skratch path doesn't exist")
|
if fc:
|
||||||
else:
|
|
||||||
list_all(d)
|
|
||||||
x = input("Delete the above files? y/N ")
|
x = input("Delete the above files? y/N ")
|
||||||
if x.lower() == 'y':
|
if x.lower() == 'y':
|
||||||
for file in os.listdir(d):
|
for file in os.listdir(d):
|
||||||
|
|
@ -26,11 +24,14 @@ def delete_all(d):
|
||||||
def list_all(d):
|
def list_all(d):
|
||||||
if not os.path.exists(d):
|
if not os.path.exists(d):
|
||||||
print("Skratch path doesn't exist")
|
print("Skratch path doesn't exist")
|
||||||
elif os.listdir(d) == []:
|
return 0
|
||||||
|
files = os.listdir(d)
|
||||||
|
if files == []:
|
||||||
print("No skratch files exist")
|
print("No skratch files exist")
|
||||||
else:
|
else:
|
||||||
for file in os.listdir(d):
|
for file in files:
|
||||||
print(file)
|
print(file)
|
||||||
|
return len(files)
|
||||||
|
|
||||||
def get_editor(use_v):
|
def get_editor(use_v):
|
||||||
v = os.getenv("VISUAL")
|
v = os.getenv("VISUAL")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue