Use common config instead of hardcoded config
units, hour_format and language will be automatically set for each module
This commit is contained in:
		| @@ -38,7 +38,7 @@ class Agenda(inkycal_module): | |||||||
|     # module specific parameters |     # module specific parameters | ||||||
|     self.date_format = 'ddd D MMM' |     self.date_format = 'ddd D MMM' | ||||||
|     self.time_format = "HH:mm" |     self.time_format = "HH:mm" | ||||||
|     self.language = 'en' |     self.language = self.config['language'] | ||||||
|     self.timezone = get_system_tz() |     self.timezone = get_system_tz() | ||||||
|     self.ical_urls = self.config['ical_urls'] |     self.ical_urls = self.config['ical_urls'] | ||||||
|     self.ical_files = [] |     self.ical_files = [] | ||||||
| @@ -48,16 +48,22 @@ class Agenda(inkycal_module): | |||||||
|  |  | ||||||
|   def _validate(self): |   def _validate(self): | ||||||
|     """Validate module-specific parameters""" |     """Validate module-specific parameters""" | ||||||
|  |  | ||||||
|     if not isinstance(self.date_format, str): |     if not isinstance(self.date_format, str): | ||||||
|       print('date_format has to be an arrow-compatible token') |       print('date_format has to be an arrow-compatible token') | ||||||
|  |  | ||||||
|     if not isinstance(self.time_format, str): |     if not isinstance(self.time_format, str): | ||||||
|       print('time_format has to be an arrow-compatible token') |       print('time_format has to be an arrow-compatible token') | ||||||
|  |  | ||||||
|     if not isinstance(self.language, str): |     if not isinstance(self.language, str): | ||||||
|       print('language has to be a string: "en" ') |       print('language has to be a string: "en" ') | ||||||
|  |  | ||||||
|     if not isinstance(self.timezone, str): |     if not isinstance(self.timezone, str): | ||||||
|       print('The timezone has bo be a string.') |       print('The timezone has bo be a string.') | ||||||
|  |  | ||||||
|     if not isinstance(self.ical_urls, list): |     if not isinstance(self.ical_urls, list): | ||||||
|       print('ical_urls has to be a list ["url1", "url2"] ') |       print('ical_urls has to be a list ["url1", "url2"] ') | ||||||
|  |  | ||||||
|     if not isinstance(self.ical_files, list): |     if not isinstance(self.ical_files, list): | ||||||
|       print('ical_files has to be a list ["path1", "path2"] ') |       print('ical_files has to be a list ["path1", "path2"] ') | ||||||
|  |  | ||||||
|   | |||||||
| @@ -40,7 +40,7 @@ class Calendar(inkycal_module): | |||||||
|     self.show_events = True |     self.show_events = True | ||||||
|     self.date_format = 'D MMM' |     self.date_format = 'D MMM' | ||||||
|     self.time_format = "HH:mm" |     self.time_format = "HH:mm" | ||||||
|     self.language = 'en' |     self.language = self.config['language'] | ||||||
|  |  | ||||||
|     self.timezone = get_system_tz() |     self.timezone = get_system_tz() | ||||||
|     self.ical_urls = self.config['ical_urls'] |     self.ical_urls = self.config['ical_urls'] | ||||||
| @@ -261,8 +261,8 @@ class Calendar(inkycal_module): | |||||||
|                   (event_width_l, line_height), name, font=self.font, |                   (event_width_l, line_height), name, font=self.font, | ||||||
|                   alignment = 'left') |                   alignment = 'left') | ||||||
|             else: |             else: | ||||||
|               write(im_black, (time_width, event_lines[cursor][1]), |               write(im_black, (date_width, event_lines[cursor][1]), | ||||||
|                   (event_width_s, line_height), time, font=self.font, |                   (time_width, line_height), time, font=self.font, | ||||||
|                   alignment = 'left') |                   alignment = 'left') | ||||||
|  |  | ||||||
|               write(im_black, (date_width+time_width,event_lines[cursor][1]), |               write(im_black, (date_width+time_width,event_lines[cursor][1]), | ||||||
|   | |||||||
| @@ -43,8 +43,8 @@ class Weather(inkycal_module): | |||||||
|  |  | ||||||
|     # module specific parameters |     # module specific parameters | ||||||
|     self.owm = pyowm.OWM(self.config['api_key']) |     self.owm = pyowm.OWM(self.config['api_key']) | ||||||
|     self.units = 'metric' # metric # imperial |     self.units = self.config['units'] | ||||||
|     self.hour_format = '24' # 12 #24 |     self.hour_format = self.config['hours'] | ||||||
|     self.timezone = get_system_tz() |     self.timezone = get_system_tz() | ||||||
|     self.round_temperature = True |     self.round_temperature = True | ||||||
|     self.round_windspeed = True |     self.round_windspeed = True | ||||||
| @@ -278,7 +278,7 @@ class Weather(inkycal_module): | |||||||
|           'temp':temp, |           'temp':temp, | ||||||
|           'icon':icon, |           'icon':icon, | ||||||
|           'stamp': forecast_timings[forecasts.index(forecast)].format('H.00' |           'stamp': forecast_timings[forecasts.index(forecast)].format('H.00' | ||||||
|                                     if self.hour_format == '24' else 'h a') |                                     if self.hour_format == 24 else 'h a') | ||||||
|           } |           } | ||||||
|  |  | ||||||
|     elif self.forecast_interval == 'daily': |     elif self.forecast_interval == 'daily': | ||||||
| @@ -335,10 +335,10 @@ class Weather(inkycal_module): | |||||||
|     sunrise_raw = arrow.get(weather.get_sunrise_time()).to(self.timezone) |     sunrise_raw = arrow.get(weather.get_sunrise_time()).to(self.timezone) | ||||||
|     sunset_raw = arrow.get(weather.get_sunset_time()).to(self.timezone) |     sunset_raw = arrow.get(weather.get_sunset_time()).to(self.timezone) | ||||||
|  |  | ||||||
|     if self.hour_format == '12': |     if self.hour_format ==  12: | ||||||
|       sunrise = sunrise_raw.format('h:mm a') |       sunrise = sunrise_raw.format('h:mm a') | ||||||
|       sunset = sunset_raw.format('h:mm a') |       sunset = sunset_raw.format('h:mm a') | ||||||
|     elif self.hour_format == '24': |     elif self.hour_format == 24: | ||||||
|       sunrise = sunrise_raw.format('H:mm') |       sunrise = sunrise_raw.format('H:mm') | ||||||
|       sunset = sunset_raw.format('H:mm') |       sunset = sunset_raw.format('H:mm') | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user