mkstemp nesting cleanup
This commit is contained in:
parent
95742a7e15
commit
4a77a03f45
1 changed files with 20 additions and 18 deletions
14
skratch.py
14
skratch.py
|
|
@ -12,9 +12,11 @@ def make_dir(d):
|
|||
|
||||
def delete_all(d):
|
||||
files = list_all(d)
|
||||
if files:
|
||||
if not files:
|
||||
return
|
||||
x = input("Delete the above files? y/N ")
|
||||
if x.lower() == 'y':
|
||||
if x.lower() != 'y':
|
||||
return
|
||||
for file in files:
|
||||
f = os.path.join(d,file)
|
||||
os.remove(f)
|
||||
|
|
@ -43,7 +45,9 @@ def get_editor(use_v):
|
|||
return e
|
||||
|
||||
def mkstemp(fp):
|
||||
if fp[-6:] == "XXXXXX":
|
||||
if fp[-6:] != "XXXXXX":
|
||||
print(f'Error: mkstemp got filepath: {fp}')
|
||||
return None
|
||||
for x in range(0,1000):
|
||||
r = ''.join(random.choices(string.ascii_letters, k=6))
|
||||
fp = fp[:-6] + r
|
||||
|
|
@ -51,9 +55,7 @@ def mkstemp(fp):
|
|||
return fp
|
||||
print("Error: Could not create new file, try running skratch -c and try again")
|
||||
return None
|
||||
else:
|
||||
print(f'Error: mkstemp got filepath: {fp}')
|
||||
return None
|
||||
|
||||
|
||||
def run(editor, sk_path, filename=None):
|
||||
if not filename:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue