Skip to content

Commit

Permalink
Merge pull request #15 from jumploop/sourcery/dev
Browse files Browse the repository at this point in the history
Dev (Sourcery refactored)
  • Loading branch information
jumploop committed Oct 14, 2023
2 parents b929bf7 + 290fbe5 commit 1cc2020
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 1cc2020

Please sign in to comment.