Skip to content

Commit c52a8a2

Browse files
committed
fix pylint issues
1 parent 6496d76 commit c52a8a2

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

backup.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
"""Simple backup application."""
44

55
import os
6-
import time
76
import argparse
7+
import shutil
8+
import hashlib
89
from pathlib import Path
910
import tkinter as tk
1011
from tkinter import ttk
1112
from tkinter import filedialog
1213
from PIL import Image, ImageTk
1314
import yaml
14-
import shutil
15-
import hashlib
1615

1716
import tk_async_execute as tae
1817

@@ -138,7 +137,6 @@ def __init__(self, project: str):
138137

139138
# load project
140139
items = self.load_project()
141-
print(f'{items}')
142140
for item in items:
143141
name = item['name']
144142
itemtype = item['type']
@@ -270,42 +268,45 @@ def start_backup(self):
270268
path = item['values'][1]
271269
items.append({'name': name, 'type': itemtype, 'path': path})
272270
self.progressbar.start()
273-
tae.async_execute(self.do_backup(items, folder), callback=self.finish_backup, wait=False, visible=False)
271+
tae.async_execute(self.do_backup(items, folder),
272+
callback=self.finish_backup, wait=False, visible=False)
274273

274+
# pylint: disable-next=too-many-locals
275275
async def do_backup(self, items, folder):
276276
"""Performs the actual backup"""
277277
# get file list
278278
if os.listdir(folder):
279-
print(f'error: folder is not empty')
279+
print('error: folder is not empty')
280280
return
281281

282282
files = []
283283
for item in items:
284284
itemtype = item['type']
285285
if itemtype == 'Folder':
286286
path = item['path']
287-
for dir, dname, fnames in os.walk(item['path']):
288-
targetdir = dir[len(os.path.commonpath([path, dir])):]
287+
for dirname, _, fnames in os.walk(item['path']):
288+
targetdir = dirname[len(os.path.commonpath([path, dirname])):]
289289
if targetdir.startswith('/'):
290290
targetdir = targetdir[1:]
291291
targetdir = os.path.join(item['name'], targetdir)
292292
for fname in fnames:
293-
source = os.path.join(dir, fname)
293+
source = os.path.join(dirname, fname)
294294
target = os.path.join(targetdir, fname)
295295
files.append({'source': source, 'target': target})
296296
elif itemtype == 'File':
297297
files.append({'source': item['path'], 'target': item['name']})
298298

299-
with open(os.path.join(folder, 'checksums.txt'), 'w', newline='\n', encoding='utf-8') as checksum_file:
299+
with open(os.path.join(folder, 'checksums.txt'), 'w',
300+
newline='\n', encoding='utf-8') as checksum_file:
300301
for file in files:
301302
source = file['source']
302303
rel_target = file['target']
303-
target = os.path.join(folder, rel_target)
304+
target = os.path.join(folder, rel_target)
304305
os.makedirs(os.path.dirname(target), exist_ok=True)
305306
shutil.copy2(source, target)
306307
with open(target, 'rb') as f:
307308
digest = hashlib.file_digest(f, "sha256")
308-
checksum_file.write(f'SHA256 ({rel_target}) = {digest.hexdigest()}\n')
309+
checksum_file.write(f'SHA256 ({rel_target}) = {digest.hexdigest()}\n')
309310

310311
def on_closing(self):
311312
"""Saves the project when the application is closed."""

0 commit comments

Comments
 (0)