readability improvements
switched from string formatting to f-strings removed some non-required validation Standardised some logging outputs better formatting of config inside tests
This commit is contained in:
@@ -90,7 +90,7 @@ class Weather(inkycal_module):
|
||||
# Check if all required parameters are present
|
||||
for param in self.requires:
|
||||
if not param in config:
|
||||
raise Exception('config is missing {}'.format(param))
|
||||
raise Exception(f'config is missing {param}')
|
||||
|
||||
# required parameters
|
||||
self.api_key = config['api_key']
|
||||
@@ -146,7 +146,7 @@ class Weather(inkycal_module):
|
||||
im_width = int(self.width - (2 * self.padding_left))
|
||||
im_height = int(self.height - (2 * self.padding_top))
|
||||
im_size = im_width, im_height
|
||||
logger.info('image size: {} x {} px'.format(im_width, im_height))
|
||||
logger.info(f'Image size: {im_size}')
|
||||
|
||||
# Create an image for black pixels and one for coloured pixels
|
||||
im_black = Image.new('RGB', size = im_size, color = 'white')
|
||||
@@ -391,7 +391,7 @@ class Weather(inkycal_module):
|
||||
daily_temp = [round(_.temperature(unit=temp_unit)['temp'],
|
||||
ndigits=dec_temp) for _ in forecasts]
|
||||
# Calculate min. and max. temp for this day
|
||||
temp_range = '{}°/{}°'.format(max(daily_temp), min(daily_temp))
|
||||
temp_range = f'{max(daily_temp)}°/{min(daily_temp)}°'
|
||||
|
||||
|
||||
# Get all weather icon codes for this day
|
||||
@@ -510,4 +510,4 @@ class Weather(inkycal_module):
|
||||
return im_black, im_colour
|
||||
|
||||
if __name__ == '__main__':
|
||||
print('running {0} in standalone mode'.format(filename))
|
||||
print(f'running {filename} in standalone mode')
|
||||
|
Reference in New Issue
Block a user