Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Jul 28, 2023
1 parent 232efa4 commit 290fbe5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions file_operation/delete_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
def backup_file(file_path):
"""备份文件"""
backup_dir = os.path.dirname(file_path)
backup_name = os.path.basename(file_path) + '_' + datetime.datetime.now().strftime('%Y%m%d%H%M%S')
backup_name = (
f'{os.path.basename(file_path)}_'
+ datetime.datetime.now().strftime('%Y%m%d%H%M%S')
)
backup_path = os.path.join(backup_dir, backup_name)
shutil.copy2(file_path, backup_path)
print(f"备份文件 {file_path}{backup_path}")
Expand Down Expand Up @@ -41,7 +44,7 @@ def main():
if backup:
rollback = input("是否回滚文件(y/n):").lower() == 'y'
if rollback:
backup_list = glob.glob(os.path.join(path, pattern + '_*'))
backup_list = glob.glob(os.path.join(path, f'{pattern}_*'))
if not backup_list:
print("没有找到备份文件")
return
Expand Down

0 comments on commit 290fbe5

Please sign in to comment.