Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if os.path.exists(home_filepath):
if self.verbose:
print(
"Reverting {}\n at {} ...".format(
mackup_filepath, home_filepath
)
)
else:
print("Reverting {} ...".format(filename))
if self.dry_run:
continue
# If there is, delete it as we are gonna copy the Dropbox
# one there
utils.delete(home_filepath)
# Copy the Dropbox file to the home folder
utils.copy(mackup_filepath, home_filepath)
elif self.verbose:
print("Doing nothing, {} does not exist".format(mackup_filepath))
file_type = "link"
else:
raise ValueError("Unsupported file: {}".format(mackup_filepath))
# Ask the user if he really want to replace it
if utils.confirm(
"A {} named {} already exists in the"
" backup.\nAre you sure that you want to"
" replace it ?".format(file_type, mackup_filepath)
):
# Delete the file in Mackup
utils.delete(mackup_filepath)
# Copy the file
utils.copy(home_filepath, mackup_filepath)
# Delete the file in the home
utils.delete(home_filepath)
# Link the backuped file to its original place
utils.link(mackup_filepath, home_filepath)
else:
# Copy the file
utils.copy(home_filepath, mackup_filepath)
# Delete the file in the home
utils.delete(home_filepath)
# Link the backuped file to its original place
utils.link(mackup_filepath, home_filepath)
elif self.verbose:
if os.path.exists(home_filepath):
print(
"Doing nothing\n {}\n "
"is already backed up to\n {}".format(
home_filepath, mackup_filepath
)
file_type = "file"
elif os.path.isdir(mackup_filepath):
file_type = "folder"
elif os.path.islink(mackup_filepath):
file_type = "link"
else:
raise ValueError("Unsupported file: {}".format(mackup_filepath))
# Ask the user if he really want to replace it
if utils.confirm(
"A {} named {} already exists in the"
" backup.\nAre you sure that you want to"
" replace it ?".format(file_type, mackup_filepath)
):
# Delete the file in Mackup
utils.delete(mackup_filepath)
# Copy the file
utils.copy(home_filepath, mackup_filepath)
# Delete the file in the home
utils.delete(home_filepath)
# Link the backuped file to its original place
utils.link(mackup_filepath, home_filepath)
else:
# Copy the file
utils.copy(home_filepath, mackup_filepath)
# Delete the file in the home
utils.delete(home_filepath)
# Link the backuped file to its original place
utils.link(mackup_filepath, home_filepath)
elif self.verbose:
if os.path.exists(home_filepath):
print(
# Name it right
if os.path.isfile(home_filepath):
file_type = "file"
elif os.path.isdir(home_filepath):
file_type = "folder"
elif os.path.islink(home_filepath):
file_type = "link"
else:
raise ValueError("Unsupported file: {}".format(mackup_filepath))
if utils.confirm(
"You already have a {} named {} in your"
" home.\nDo you want to replace it with"
" your backup ?".format(file_type, filename)
):
utils.delete(home_filepath)
utils.link(mackup_filepath, home_filepath)
else:
utils.link(mackup_filepath, home_filepath)
elif self.verbose:
if os.path.exists(home_filepath):
print(
"Doing nothing\n {}\n already linked by\n {}".format(
mackup_filepath, home_filepath
)
)
elif os.path.islink(home_filepath):
print(
"Doing nothing\n {}\n "
"is a broken link, you might want to fix it.".format(
home_filepath
)
" backup.\nAre you sure that you want to"
" replace it ?".format(file_type, mackup_filepath)
):
# Delete the file in Mackup
utils.delete(mackup_filepath)
# Copy the file
utils.copy(home_filepath, mackup_filepath)
# Delete the file in the home
utils.delete(home_filepath)
# Link the backuped file to its original place
utils.link(mackup_filepath, home_filepath)
else:
# Copy the file
utils.copy(home_filepath, mackup_filepath)
# Delete the file in the home
utils.delete(home_filepath)
# Link the backuped file to its original place
utils.link(mackup_filepath, home_filepath)
elif self.verbose:
if os.path.exists(home_filepath):
print(
"Doing nothing\n {}\n "
"is already backed up to\n {}".format(
home_filepath, mackup_filepath
)
)
elif os.path.islink(home_filepath):
print(
"Doing nothing\n {}\n "
"is a broken link, you might want to fix it.".format(
home_filepath
)