Snake case

merge-requests/30/head
Bob Mottram 2021-12-26 14:37:28 +00:00
parent 9502b08961
commit 3e69d8f5ea
2 changed files with 40 additions and 40 deletions

View File

@ -164,90 +164,90 @@ def _copyThemeHelpFiles(base_dir: str, theme_name: str,
def _setThemeInConfig(base_dir: str, name: str) -> bool: def _setThemeInConfig(base_dir: str, name: str) -> bool:
"""Sets the theme with the given name within config.json """Sets the theme with the given name within config.json
""" """
configFilename = base_dir + '/config.json' config_filename = base_dir + '/config.json'
if not os.path.isfile(configFilename): if not os.path.isfile(config_filename):
return False return False
configJson = loadJson(configFilename, 0) configJson = loadJson(config_filename, 0)
if not configJson: if not configJson:
return False return False
configJson['theme'] = name configJson['theme'] = name
return saveJson(configJson, configFilename) return saveJson(configJson, config_filename)
def _setNewswirePublishAsIcon(base_dir: str, useIcon: bool) -> bool: def _setNewswirePublishAsIcon(base_dir: str, useIcon: bool) -> bool:
"""Shows the newswire publish action as an icon or a button """Shows the newswire publish action as an icon or a button
""" """
configFilename = base_dir + '/config.json' config_filename = base_dir + '/config.json'
if not os.path.isfile(configFilename): if not os.path.isfile(config_filename):
return False return False
configJson = loadJson(configFilename, 0) configJson = loadJson(config_filename, 0)
if not configJson: if not configJson:
return False return False
configJson['show_publish_as_icon'] = useIcon configJson['show_publish_as_icon'] = useIcon
return saveJson(configJson, configFilename) return saveJson(configJson, config_filename)
def _setIconsAsButtons(base_dir: str, useButtons: bool) -> bool: def _setIconsAsButtons(base_dir: str, useButtons: bool) -> bool:
"""Whether to show icons in the header (inbox, outbox, etc) """Whether to show icons in the header (inbox, outbox, etc)
as buttons as buttons
""" """
configFilename = base_dir + '/config.json' config_filename = base_dir + '/config.json'
if not os.path.isfile(configFilename): if not os.path.isfile(config_filename):
return False return False
configJson = loadJson(configFilename, 0) configJson = loadJson(config_filename, 0)
if not configJson: if not configJson:
return False return False
configJson['icons_as_buttons'] = useButtons configJson['icons_as_buttons'] = useButtons
return saveJson(configJson, configFilename) return saveJson(configJson, config_filename)
def _setRssIconAtTop(base_dir: str, atTop: bool) -> bool: def _setRssIconAtTop(base_dir: str, atTop: bool) -> bool:
"""Whether to show RSS icon at the top of the timeline """Whether to show RSS icon at the top of the timeline
""" """
configFilename = base_dir + '/config.json' config_filename = base_dir + '/config.json'
if not os.path.isfile(configFilename): if not os.path.isfile(config_filename):
return False return False
configJson = loadJson(configFilename, 0) configJson = loadJson(config_filename, 0)
if not configJson: if not configJson:
return False return False
configJson['rss_icon_at_top'] = atTop configJson['rss_icon_at_top'] = atTop
return saveJson(configJson, configFilename) return saveJson(configJson, config_filename)
def _setPublishButtonAtTop(base_dir: str, atTop: bool) -> bool: def _setPublishButtonAtTop(base_dir: str, atTop: bool) -> bool:
"""Whether to show the publish button above the title image """Whether to show the publish button above the title image
in the newswire column in the newswire column
""" """
configFilename = base_dir + '/config.json' config_filename = base_dir + '/config.json'
if not os.path.isfile(configFilename): if not os.path.isfile(config_filename):
return False return False
configJson = loadJson(configFilename, 0) configJson = loadJson(config_filename, 0)
if not configJson: if not configJson:
return False return False
configJson['publish_button_at_top'] = atTop configJson['publish_button_at_top'] = atTop
return saveJson(configJson, configFilename) return saveJson(configJson, config_filename)
def _setFullWidthTimelineButtonHeader(base_dir: str, fullWidth: bool) -> bool: def _setFullWidthTimelineButtonHeader(base_dir: str, fullWidth: bool) -> bool:
"""Shows the timeline button header containing inbox, outbox, """Shows the timeline button header containing inbox, outbox,
calendar, etc as full width calendar, etc as full width
""" """
configFilename = base_dir + '/config.json' config_filename = base_dir + '/config.json'
if not os.path.isfile(configFilename): if not os.path.isfile(config_filename):
return False return False
configJson = loadJson(configFilename, 0) configJson = loadJson(config_filename, 0)
if not configJson: if not configJson:
return False return False
configJson['full_width_tl_button_header'] = fullWidth configJson['full_width_tl_button_header'] = fullWidth
return saveJson(configJson, configFilename) return saveJson(configJson, config_filename)
def getTheme(base_dir: str) -> str: def getTheme(base_dir: str) -> str:
"""Gets the current theme name from config.json """Gets the current theme name from config.json
""" """
configFilename = base_dir + '/config.json' config_filename = base_dir + '/config.json'
if os.path.isfile(configFilename): if os.path.isfile(config_filename):
configJson = loadJson(configFilename, 0) configJson = loadJson(config_filename, 0)
if configJson: if configJson:
if configJson.get('theme'): if configJson.get('theme'):
return configJson['theme'] return configJson['theme']

View File

@ -494,35 +494,35 @@ def isSystemAccount(nickname: str) -> bool:
return False return False
def _createConfig(base_dir: str) -> None: def _create_config(base_dir: str) -> None:
"""Creates a configuration file """Creates a configuration file
""" """
configFilename = base_dir + '/config.json' config_filename = base_dir + '/config.json'
if os.path.isfile(configFilename): if os.path.isfile(config_filename):
return return
configJson = { config_json = {
} }
saveJson(configJson, configFilename) saveJson(config_json, config_filename)
def setConfigParam(base_dir: str, variableName: str, variableValue) -> None: def setConfigParam(base_dir: str, variableName: str, variableValue) -> None:
"""Sets a configuration value """Sets a configuration value
""" """
_createConfig(base_dir) _create_config(base_dir)
configFilename = base_dir + '/config.json' config_filename = base_dir + '/config.json'
configJson = {} configJson = {}
if os.path.isfile(configFilename): if os.path.isfile(config_filename):
configJson = loadJson(configFilename) configJson = loadJson(config_filename)
configJson[variableName] = variableValue configJson[variableName] = variableValue
saveJson(configJson, configFilename) saveJson(configJson, config_filename)
def get_config_param(base_dir: str, variableName: str): def get_config_param(base_dir: str, variableName: str):
"""Gets a configuration value """Gets a configuration value
""" """
_createConfig(base_dir) _create_config(base_dir)
configFilename = base_dir + '/config.json' config_filename = base_dir + '/config.json'
configJson = loadJson(configFilename) configJson = loadJson(config_filename)
if configJson: if configJson:
if variableName in configJson: if variableName in configJson:
return configJson[variableName] return configJson[variableName]