forked from endorphant/ttbp
feels archive copies over files
parent
95690d9983
commit
8c9fe44546
|
@ -487,7 +487,8 @@ def unpublish_feel(filename):
|
||||||
subprocess.call(["rm", live_gopher])
|
subprocess.call(["rm", live_gopher])
|
||||||
|
|
||||||
def process_backup(filename):
|
def process_backup(filename):
|
||||||
"""takes given filename and loads the archive into current main feels.
|
"""takes given filename and unpacks it into a temp directory, then returns a
|
||||||
|
list of filenames with collisions filtered out.
|
||||||
|
|
||||||
ignores any invalidly named files or files that already exist, to avoid
|
ignores any invalidly named files or files that already exist, to avoid
|
||||||
clobbering current feels. ignored files are left in the archive directory
|
clobbering current feels. ignored files are left in the archive directory
|
||||||
|
@ -509,8 +510,9 @@ def process_backup(filename):
|
||||||
|
|
||||||
for feel in backups:
|
for feel in backups:
|
||||||
if os.path.basename(feel) not in current:
|
if os.path.basename(feel) not in current:
|
||||||
imported.append(feel)
|
imported.append(os.path.join(backup_entries, feel))
|
||||||
|
|
||||||
|
imported.sort()
|
||||||
return imported
|
return imported
|
||||||
|
|
||||||
def import_feels(backups):
|
def import_feels(backups):
|
||||||
|
|
|
@ -1022,7 +1022,8 @@ def load_backup():
|
||||||
if len(backups) < 1:
|
if len(backups) < 1:
|
||||||
print(""""
|
print(""""
|
||||||
sorry, i didn't find any feels backups! if you have a backup file handy, please
|
sorry, i didn't find any feels backups! if you have a backup file handy, please
|
||||||
move it to {directory} and try running this tool again.""".format(directory=config.BACKUPS))
|
move it to {directory} and try running this tool again.\
|
||||||
|
""".format(directory=config.BACKUPS))
|
||||||
else:
|
else:
|
||||||
print("backup files found:\n")
|
print("backup files found:\n")
|
||||||
choice = menu_handler(backups, "pick a backup file to load (or 'q' to cancel): ", 15, SETTINGS.get("rainbows", False), "backup files found:")
|
choice = menu_handler(backups, "pick a backup file to load (or 'q' to cancel): ", 15, SETTINGS.get("rainbows", False), "backup files found:")
|
||||||
|
@ -1030,12 +1031,13 @@ move it to {directory} and try running this tool again.""".format(directory=conf
|
||||||
if choice is not False:
|
if choice is not False:
|
||||||
imports = core.process_backup(os.path.join(config.BACKUPS, backups[choice]))
|
imports = core.process_backup(os.path.join(config.BACKUPS, backups[choice]))
|
||||||
for feel in imports:
|
for feel in imports:
|
||||||
print("importing {feel}".format(feel="-".join(util.parse_date(feel))))
|
print("importing {entry}".format(entry="-".join(util.parse_date(feel))))
|
||||||
|
subprocess.call(["mv", feel, config.MAIN_FEELS])
|
||||||
time.sleep(.01)
|
time.sleep(.01)
|
||||||
|
|
||||||
tempdir = os.path.join(config.BACKUPS, os.path.splitext(os.path.splitext(os.path.basename(backups[choice]))[0])[0], "entries")
|
tempdir = os.path.join(config.BACKUPS, os.path.splitext(os.path.splitext(os.path.basename(backups[choice]))[0])[0], "entries")
|
||||||
|
|
||||||
if len(imports) == len(os.listdir(tempdir)):
|
if len(os.listdir(tempdir)) == 0:
|
||||||
print("congrats! your feels archive has been unloaded.")
|
print("congrats! your feels archive has been unloaded.")
|
||||||
else:
|
else:
|
||||||
print("""\
|
print("""\
|
||||||
|
|
Loading…
Reference in New Issue