forked from openlp/openlp
Fix up json
This commit is contained in:
parent
0f183af84d
commit
ba0808f551
|
@ -1,49 +1,59 @@
|
|||
{
|
||||
"background_border_color": "#000000",
|
||||
"background_color": "#000000",
|
||||
"background_direction": "vertical",
|
||||
"background_end_color": "#000000",
|
||||
"background_filename": "",
|
||||
"background_start_color": "#000000",
|
||||
"background_type": "solid",
|
||||
"display_horizontal_align": 0,
|
||||
"display_slide_transition": false,
|
||||
"display_vertical_align": 0,
|
||||
"font_footer_bold": false,
|
||||
"font_footer_color": "#FFFFFF",
|
||||
"font_footer_height": 78,
|
||||
"font_footer_italics": false,
|
||||
"font_footer_line_adjustment": 0,
|
||||
"font_footer_location": "",
|
||||
"font_footer_name": "Arial",
|
||||
"font_footer_outline": false,
|
||||
"font_footer_outline_color": "#000000",
|
||||
"font_footer_outline_size": 2,
|
||||
"font_footer_override": false,
|
||||
"font_footer_shadow": true,
|
||||
"font_footer_shadow_color": "#000000",
|
||||
"font_footer_shadow_size": 5,
|
||||
"font_footer_size": 12,
|
||||
"font_footer_width": 1004,
|
||||
"font_footer_x": 10,
|
||||
"font_footer_y": 690,
|
||||
"font_main_bold": false,
|
||||
"font_main_color": "#FFFFFF",
|
||||
"font_main_height": 690,
|
||||
"font_main_italics": false,
|
||||
"font_main_line_adjustment": 0,
|
||||
"font_main_location": "",
|
||||
"font_main_name": "Arial",
|
||||
"font_main_outline": false,
|
||||
"font_main_outline_color": "#000000",
|
||||
"font_main_outline_size": 2,
|
||||
"font_main_override": false,
|
||||
"font_main_shadow": true,
|
||||
"font_main_shadow_color": "#000000",
|
||||
"font_main_shadow_size": 5,
|
||||
"font_main_size": 40,
|
||||
"font_main_width": 1004,
|
||||
"font_main_x": 10,
|
||||
"font_main_y": 10,
|
||||
"background" : {
|
||||
"border_color": "#000000",
|
||||
"color": "#000000",
|
||||
"direction": "vertical",
|
||||
"end_color": "#000000",
|
||||
"filename": "",
|
||||
"start_color": "#000000",
|
||||
"type": "solid"
|
||||
},
|
||||
"display" :{
|
||||
"horizontal_align": 0,
|
||||
"slide_transition": false,
|
||||
"vertical_align": 0
|
||||
},
|
||||
"font": {
|
||||
"footer": {
|
||||
"bold": false,
|
||||
"color": "#FFFFFF",
|
||||
"height": 78,
|
||||
"italics": false,
|
||||
"line_adjustment": 0,
|
||||
"location": "",
|
||||
"name": "Arial",
|
||||
"outline": false,
|
||||
"outline_color": "#000000",
|
||||
"outline_size": 2,
|
||||
"override": false,
|
||||
"shadow": true,
|
||||
"shadow_color": "#000000",
|
||||
"shadow_size": 5,
|
||||
"size": 12,
|
||||
"width": 1004,
|
||||
"x": 10,
|
||||
"y": 690
|
||||
},
|
||||
"main": {
|
||||
"bold": false,
|
||||
"color": "#FFFFFF",
|
||||
"height": 690,
|
||||
"italics": false,
|
||||
"line_adjustment": 0,
|
||||
"location": "",
|
||||
"name": "Arial",
|
||||
"outline": false,
|
||||
"outline_color": "#000000",
|
||||
"outline_size": 2,
|
||||
"override": false,
|
||||
"shadow": true,
|
||||
"shadow_color": "#000000",
|
||||
"shadow_size": 5,
|
||||
"size": 40,
|
||||
"width": 1004,
|
||||
"x": 10,
|
||||
"y": 10
|
||||
}
|
||||
},
|
||||
"theme_name": ""
|
||||
}
|
||||
|
|
|
@ -169,8 +169,27 @@ class ThemeXML(object):
|
|||
json_file = os.path.join(json_dir, 'theme.json')
|
||||
jsn = get_text_file_string(json_file)
|
||||
jsn = json.loads(jsn)
|
||||
for key, value in jsn.items():
|
||||
setattr(self, key, value)
|
||||
self.expand_json(jsn)
|
||||
|
||||
def expand_json(self, var, prev=None):
|
||||
"""
|
||||
Expand the json objects and make into variables.
|
||||
|
||||
``var``
|
||||
The array list to be processed.
|
||||
|
||||
``prev``
|
||||
The preceding string to add to the key to make the variable.
|
||||
"""
|
||||
for key, value in var.items():
|
||||
if prev:
|
||||
key = prev + "_" + key
|
||||
else:
|
||||
key = key
|
||||
if isinstance(value, dict):
|
||||
self.expand_json(value, key)
|
||||
else:
|
||||
setattr(self, key, value)
|
||||
|
||||
def extend_image_filename(self, path):
|
||||
"""
|
||||
|
|
|
@ -63,3 +63,9 @@ class TestTheme(TestCase):
|
|||
# THEN: We should get some default behaviours
|
||||
self.assertTrue(default_theme.background_border_color == '#000000', 'The theme should have a black border')
|
||||
self.assertTrue(default_theme.background_type == 'solid', 'There theme should have a solid backgrounds')
|
||||
self.assertTrue(default_theme.background_type == 'solid', 'There theme should have a solid backgrounds')
|
||||
self.assertTrue(default_theme.display_vertical_align == 0,
|
||||
'There theme should have display_vertical_align of 0')
|
||||
self.assertTrue(default_theme.font_footer_name == "Arial",
|
||||
'There theme should has font_footer_name of Arial')
|
||||
self.assertTrue(default_theme.font_main_bold is False, 'There theme should has font_main_bold of false')
|
Loading…
Reference in New Issue