Revert "Improved some code logic to better support new web-ui"
This reverts commit 5327d12f0e.
			
			
This commit is contained in:
		| @@ -66,18 +66,13 @@ class Agenda(inkycal_module): | |||||||
|     self.date_format = config['date_format'] |     self.date_format = config['date_format'] | ||||||
|     self.time_format = config['time_format'] |     self.time_format = config['time_format'] | ||||||
|     self.language = config['language'] |     self.language = config['language'] | ||||||
|  |     self.ical_urls = config['ical_urls'].split(',') | ||||||
|  |  | ||||||
|     # Check if ical_files is an empty string |     # Check if ical_files is an empty string | ||||||
|     if config['ical_urls']: |     if config['ical_files'] != "": | ||||||
|       self.ical_urls = config['ical_urls'].split(',') |  | ||||||
|     else: |  | ||||||
|       self.ical_urls = config['ical_urls'] |  | ||||||
|  |  | ||||||
|     # Check if ical_files is an empty string |  | ||||||
|     if config['ical_files']: |  | ||||||
|       self.ical_files = config['ical_files'].split(',') |       self.ical_files = config['ical_files'].split(',') | ||||||
|     else: |     else: | ||||||
|       self.ical_files = config['ical_files'] |       self.ical_files = [] | ||||||
|  |  | ||||||
|     # Additional config |     # Additional config | ||||||
|     self.timezone = get_system_tz() |     self.timezone = get_system_tz() | ||||||
|   | |||||||
| @@ -65,20 +65,20 @@ class Calendar(inkycal_module): | |||||||
|  |  | ||||||
|     # optional parameters |     # optional parameters | ||||||
|     self.weekstart = config['week_starts_on'] |     self.weekstart = config['week_starts_on'] | ||||||
|     self.show_events = config['show_events'] |     self.show_events = bool(config['show_events']) | ||||||
|     self.date_format = config["date_format"] |     self.date_format = config["date_format"] | ||||||
|     self.time_format = config['time_format'] |     self.time_format = config['time_format'] | ||||||
|     self.language = config['language'] |     self.language = config['language'] | ||||||
|  |  | ||||||
|     if config['ical_urls']: |     if config['ical_urls'] != "": | ||||||
|       self.ical_urls = config['ical_urls'].split(',') |       self.ical_urls = config['ical_urls'].split(',') | ||||||
|     else: |     else: | ||||||
|       self.ical_urls = config['ical_urls'] |       self.ical_urls = [] | ||||||
|  |  | ||||||
|     if config['ical_files']: |     if config['ical_files'] != "": | ||||||
|       self.ical_files = config['ical_files'].split(',') |       self.ical_files = config['ical_files'].split(',') | ||||||
|     else: |     else: | ||||||
|       self.ical_files = config['ical_files'] |       self.ical_files = [] | ||||||
|  |  | ||||||
|     # additional configuration |     # additional configuration | ||||||
|     self.timezone = get_system_tz() |     self.timezone = get_system_tz() | ||||||
| @@ -117,7 +117,7 @@ class Calendar(inkycal_module): | |||||||
|       logger.debug(f'events-section size: {im_width} x {events_height} px') |       logger.debug(f'events-section size: {im_width} x {events_height} px') | ||||||
|     else: |     else: | ||||||
|       logger.debug("Not allocating space for events") |       logger.debug("Not allocating space for events") | ||||||
|       calendar_height = im_height - month_name_height - weekdays_height |       calendar_height = im_height - month_name_height - weekday_height | ||||||
|       logger.debug(f'calendar-section size: {im_width} x {calendar_height} px') |       logger.debug(f'calendar-section size: {im_width} x {calendar_height} px') | ||||||
|  |  | ||||||
|     # Create a 7x6 grid and calculate icon sizes |     # Create a 7x6 grid and calculate icon sizes | ||||||
|   | |||||||
| @@ -60,7 +60,7 @@ class Feeds(inkycal_module): | |||||||
|     self.feed_urls = self.config["feed_urls"].split(",") |     self.feed_urls = self.config["feed_urls"].split(",") | ||||||
|  |  | ||||||
|     # optional parameters |     # optional parameters | ||||||
|     self.shuffle_feeds = self.config["shuffle_feeds"] |     self.shuffle_feeds = bool(self.config["shuffle_feeds"]) | ||||||
|  |  | ||||||
|     # give an OK message |     # give an OK message | ||||||
|     print('{0} loaded'.format(filename)) |     print('{0} loaded'.format(filename)) | ||||||
|   | |||||||
| @@ -1,47 +1,30 @@ | |||||||
| import unittest | import unittest | ||||||
| from inkycal.modules import Feeds as Module | from inkycal.modules import Feeds as Module | ||||||
|  |  | ||||||
| tests = [ | test = { | ||||||
| { |  | ||||||
|   "position": 1, |   "position": 1, | ||||||
|   "name": "Feeds", |   "name": "Feeds", | ||||||
|   "config": { |   "config": { | ||||||
|     "size": [400,100], |     "size": [400,100], | ||||||
|     "feed_urls": "http://feeds.bbci.co.uk/news/world/rss.xml#", |     "feed_urls": "http://feeds.bbci.co.uk/news/world/rss.xml#", | ||||||
|     "shuffle_feeds": True, |     "shuffle_feeds": "True", | ||||||
|     "padding_x": 10, |     "padding_x": 10, | ||||||
|     "padding_y": 10, |     "padding_y": 10, | ||||||
|     "fontsize": 12, |     "fontsize": 12, | ||||||
|     "language": "en" |     "language": "en" | ||||||
|     } |     } | ||||||
| }, | } | ||||||
| { |  | ||||||
|   "position": 1, | module = Module(test) | ||||||
|   "name": "Feeds", |  | ||||||
|   "config": { |  | ||||||
|     "size": [400,100], |  | ||||||
|     "feed_urls": "http://feeds.bbci.co.uk/news/world/rss.xml#", |  | ||||||
|     "shuffle_feeds": False, |  | ||||||
|     "padding_x": 10, |  | ||||||
|     "padding_y": 10, |  | ||||||
|     "fontsize": 12, |  | ||||||
|     "language": "en" |  | ||||||
|     } |  | ||||||
| }, |  | ||||||
| ] |  | ||||||
|    |    | ||||||
| class module_test(unittest.TestCase): | class module_test(unittest.TestCase): | ||||||
|   def test_get_config(self): |   def test_get_config(self): | ||||||
|     print('getting data for web-ui...', end = "") |     print('getting data for web-ui') | ||||||
|     Module.get_config() |     module.get_config() | ||||||
|     print('OK') |  | ||||||
|      |      | ||||||
|   def test_generate_image(self): |   def test_generate_image(self): | ||||||
|     for test in tests: |     print('testing image generation') | ||||||
|       print(f'test {tests.index(test)+1} generating image..') |     module.generate_image() | ||||||
|       module = Module(test) |  | ||||||
|       module.generate_image() |  | ||||||
|       print('OK') |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|   unittest.main() |   unittest.main() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user