Code-styling following PEP8.

This commit is contained in:
2020-12-26 21:09:58 +01:00
parent 628088918b
commit 3f777b7e55
2 changed files with 178 additions and 57 deletions

View File

@@ -16,7 +16,8 @@ class Radiation:
Arguments:
timestamp: Date/time string from CSV as string
radiation: Radiation from CSV in CP/M as float
local_timezone: timezone for timezone-unaware CSV / Photo, if GPX is timezone aware
local_timezone: timezone for timezone-unaware CSV / Photo, if GPX is
timezone aware
si_factor: CP/M to (µS/h) conversion factor - specific to GMC-tube
Returns:
@@ -24,7 +25,13 @@ class Radiation:
radiation: radiation in µS/h as str (for Exif comment, UTF-8)
'''
def __init__(self, timestamp, radiation, local_timezone, si_factor):
def __init__(
self,
timestamp,
radiation,
local_timezone,
si_factor
):
self.timestamp = self._time_conversion(timestamp, local_timezone)
self.radiation = self._radiation_conversion(radiation, si_factor)
@@ -48,7 +55,8 @@ class Photo:
Arguments:
photo: source photo ()
local_timezone: timezone for timezone-unaware CSV / Photo, if GPX is timezone aware
local_timezone: timezone for timezone-unaware CSV / Photo, if GPX is
timezone aware
dest_dir: destination directory where the photo is going to be copied to.
dry_run: whether to actually write (True / False)
@@ -64,7 +72,10 @@ class Photo:
self.get_photo_basename = self._copy_photo(photo, dest_dir, dry_run)[0]
def __repr__(self):
return 'Photo: %s Creation Date: %s' % (str(self.get_photo_basename), str(self.get_date))
return 'Photo: %s Creation Date: %s' % (
str(self.get_photo_basename),
str(self.get_date)
)
def _copy_photo(self, photo, dest_dir, dry_run):
# Determine where to work on photo and copy it there if needed.
@@ -96,8 +107,8 @@ class Photo:
class Match:
'''
Receives lists of time / radiation and GPS data and compares it to timestamp.
Then returns relevant values matching to time - or None
Receives lists of time / radiation and GPS data and compares it to
timestamp.Then returns relevant values matching to time - or None
Arguments:
photo_time: timestamp of photo
@@ -110,12 +121,30 @@ class Match:
'''
def __init__(self, photo_time, radiation_list, position_list):
self.radiation_value = self._find_radiation_match(photo_time, radiation_list)[1]
self.radiation_delta = self._find_radiation_match(photo_time, radiation_list)[0]
self.position_delta = self._find_position_match(photo_time, position_list)[0]
self.position_latitude = self._find_position_match(photo_time, position_list)[1][1]
self.position_longitude = self._find_position_match(photo_time, position_list)[1][2]
self.position_altitude = self._find_position_match(photo_time, position_list)[1][3]
self.radiation_value = self._find_radiation_match(
photo_time,
radiation_list
)[1]
self.radiation_delta = self._find_radiation_match(
photo_time,
radiation_list
)[0]
self.position_delta = self._find_position_match(
photo_time,
position_list
)[0]
self.position_latitude = self._find_position_match(
photo_time,
position_list
)[1][1]
self.position_longitude = self._find_position_match(
photo_time,
position_list
)[1][2]
self.position_altitude = self._find_position_match(
photo_time,
position_list
)[1][3]
def __repr__(self):
if self.radiation_value:
@@ -186,9 +215,21 @@ class Exif:
Exif-Comment: that has been written (incl. radiation)
'''
def __init__(self, photo, dry_run, radiation, latitude, longitude, elevation):
self.write_exif = self._write_exif(photo, dry_run, radiation, latitude,
longitude, elevation)
def __init__(
self, photo,
dry_run,
radiation,
latitude,
longitude,
elevation
):
self.write_exif = self._write_exif(
photo,
dry_run,
radiation,
latitude,
longitude, elevation
)
def __repr__(self):
return 'Position: %s, %s: %s ' % self.write_exif
@@ -207,7 +248,15 @@ class Exif:
second = round((t1 - minute) * 60, 5)
return (deg, minute, second, loc_value)
def _write_exif(self, photo, dry_run, radiation, latitude, longitude, elevation):
def _write_exif(
self,
photo,
dry_run,
radiation,
latitude,
longitude,
elevation
):
metadata = pyexiv2.ImageMetadata(photo)
metadata.read()
@@ -217,12 +266,16 @@ class Exif:
longitude_degree = self._to_degree(longitude, ["W", "E"])
# convert decimal coordinates into fractions required for pyexiv2
exiv2_latitude = (Fraction(latitude_degree[0] * 60 + latitude_degree[1], 60),
Fraction(int(round(latitude_degree[2] * 100, 0)), 6000),
Fraction(0, 1))
exiv2_longitude = (Fraction(longitude_degree[0] * 60 + longitude_degree[1], 60),
Fraction(int(round(longitude_degree[2] * 100, 0)), 6000),
Fraction(0, 1))
exiv2_latitude = (
Fraction(latitude_degree[0] * 60 + latitude_degree[1], 60),
Fraction(int(round(latitude_degree[2] * 100, 0)), 6000),
Fraction(0, 1)
)
exiv2_longitude = (
Fraction(longitude_degree[0] * 60 + longitude_degree[1], 60),
Fraction(int(round(longitude_degree[2] * 100, 0)), 6000),
Fraction(0, 1)
)
# Exif tags to write
metadata['Exif.GPSInfo.GPSLatitude'] = exiv2_latitude
@@ -259,7 +312,8 @@ class Exif:
class Output:
'''
Receives values to be printed, formats them and returns a string for printing.
Receives values to be printed, formats them and returns a string for
printing.
Arguments:
radiation: radiation as float
@@ -272,7 +326,12 @@ class Output:
'''
def __init__(self, radiation, latitude, longitude, altitude):
self.get_string = self._get_string(radiation, latitude, longitude, altitude)
self.get_string = self._get_string(
radiation,
latitude,
longitude,
altitude
)
def __repr__(self):
return self.get_string