1
0
mirror of https://github.com/sashacmc/photo-importer.git synced 2026-06-09 16:43:31 +02:00

Update python files formatting

This commit is contained in:
sashacmc
2026-06-03 20:12:11 +02:00
parent 037803c25e
commit 0bf0ce5c1c
7 changed files with 9 additions and 26 deletions
+1 -1
View File
@@ -21,4 +21,4 @@ jobs:
pip install .
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py') --disable missing-function-docstring,missing-module-docstring,missing-class-docstring,broad-exception-caught,too-many-positional-arguments
pylint $(git ls-files '*.py') --max-line-length=140 --disable missing-function-docstring,missing-module-docstring,missing-class-docstring,broad-exception-caught,R0917
+2 -6
View File
@@ -159,9 +159,7 @@ class FileProp:
def __time_by_attr(self, fullname):
try:
return datetime.datetime.fromtimestamp(
time.mktime(time.localtime(os.stat(fullname)[stat.ST_MTIME]))
)
return datetime.datetime.fromtimestamp(time.mktime(time.localtime(os.stat(fullname)[stat.ST_MTIME])))
except (FileNotFoundError, KeyError) as ex:
logging.warning('time by attr (%s) exception: %s', fullname, ex)
return None
@@ -200,9 +198,7 @@ class FileProp:
ftime += datetime.timedelta(seconds=int(time_shift))
if ftime:
out_name = ftime.strftime(
self.__config['main']['out_time_format']
) + self.__calc_orig_name(fname)
out_name = ftime.strftime(self.__config['main']['out_time_format']) + self.__calc_orig_name(fname)
else:
out_name = None
+1 -3
View File
@@ -24,9 +24,7 @@ class Importer(threading.Thread):
self.__log = log.MemLogger(input_path)
def run(self):
logging.info(
'Start: %s -> %s (dryrun: %s)', self.__input_path, self.__output_path, self.__dryrun
)
logging.info('Start: %s -> %s (dryrun: %s)', self.__input_path, self.__output_path, self.__dryrun)
filenames, dirs = self.__scan_files(self.__input_path)
+1 -5
View File
@@ -105,11 +105,7 @@ class Rotator:
os.close(handle)
try:
cmd = (
['jpegtran', '-copy', 'all', '-outfile', tmpfile]
+ orientation_cmd.split()
+ [filename]
)
cmd = ['jpegtran', '-copy', 'all', '-outfile', tmpfile] + orientation_cmd.split() + [filename]
logging.debug('rotate: %s', cmd)
with subprocess.Popen(
+1 -4
View File
@@ -90,10 +90,7 @@ def main():
status = imp.status()
logging.info('status: %s', str(status))
if (
status.get('move', {}).get('errors', 0) != 0
or status.get('rotate', {}).get('errors', 0) != 0
):
if status.get('move', {}).get('errors', 0) != 0 or status.get('rotate', {}).get('errors', 0) != 0:
print('Some errors found. Please check log file.')
+2 -4
View File
@@ -56,10 +56,7 @@ class PhotoImporterHandler(http.server.BaseHTTPRequestHandler):
self.wfile.write(bytearray(explain, 'utf-8'))
def __get_mounted_list(self):
return {
os.path.basename(dp.device): (dp.device, dp.mountpoint)
for dp in psutil.disk_partitions()
}
return {os.path.basename(dp.device): (dp.device, dp.mountpoint) for dp in psutil.disk_partitions()}
def __bytes_to_gbytes(self, b):
return round(b / 1024.0 / 1024.0 / 1024.0, 2)
@@ -396,6 +393,7 @@ class PhotoImporterHandler(http.server.BaseHTTPRequestHandler):
class PhotoImporterServer(socketserver.ThreadingMixIn, http.server.HTTPServer):
daemon_threads = True
def __init__(self, cfg):
self.__cfg = cfg
self.__importers = {}
+1 -3
View File
@@ -195,9 +195,7 @@ def test_mount_cmd_error_500(http_server, monkeypatch):
def test_import_start_over_http(http_server, tmp_path):
indir = tmp_path / 'imp_in'
indir.mkdir()
status, _, body = _request(
http_server, 'POST', f'/import?a=start&p={indir}&o={tmp_path / "imp_out"}'
)
status, _, body = _request(http_server, 'POST', f'/import?a=start&p={indir}&o={tmp_path / "imp_out"}')
assert status == 200
assert json.loads(body) is True