forked from openlp/openlp
Tidy ups + doc
This commit is contained in:
parent
5482e70e6d
commit
d178b7adba
@ -585,7 +585,8 @@ class Settings(QtCore.QSettings):
|
|||||||
:param value: The value to save
|
:param value: The value to save
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
if is_serializable(value): # TODO: doesnt handle list off path objects
|
if is_serializable(value) or isinstance(value, dict) or \
|
||||||
|
(isinstance(value, list) and value and is_serializable(value[0])):
|
||||||
value = json.dumps(value, cls=OpenLPJSONEncoder)
|
value = json.dumps(value, cls=OpenLPJSONEncoder)
|
||||||
super().setValue(key, value)
|
super().setValue(key, value)
|
||||||
|
|
||||||
@ -612,7 +613,7 @@ class Settings(QtCore.QSettings):
|
|||||||
elif isinstance(default_value, dict):
|
elif isinstance(default_value, dict):
|
||||||
return {}
|
return {}
|
||||||
elif isinstance(setting, str):
|
elif isinstance(setting, str):
|
||||||
if 'json_meta' in setting or setting.startswith('{'): # TODO: Appears screeen settings is using this, subcass from jsonmixin
|
if 'json_meta' in setting or setting.startswith('{'):
|
||||||
return json.loads(setting, cls=OpenLPJSONDecoder)
|
return json.loads(setting, cls=OpenLPJSONDecoder)
|
||||||
# Convert the setting to the correct type.
|
# Convert the setting to the correct type.
|
||||||
if isinstance(default_value, bool):
|
if isinstance(default_value, bool):
|
||||||
|
@ -165,8 +165,8 @@ def init_url(plugin_name, db_file_name=None):
|
|||||||
Construct the connection string for a database.
|
Construct the connection string for a database.
|
||||||
|
|
||||||
:param plugin_name: The name of the plugin for the database creation.
|
:param plugin_name: The name of the plugin for the database creation.
|
||||||
:param pathlib.Path | str | None db_file_name: The database file name. Defaults to None resulting
|
:param pathlib.Path | str | None db_file_name: The database file name. Defaults to None resulting in the plugin_name
|
||||||
in the plugin_name being used.
|
being used.
|
||||||
:return: The database URL
|
:return: The database URL
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
@ -216,6 +216,7 @@ class PathType(types.TypeDecorator):
|
|||||||
representation and store it as a Unicode type
|
representation and store it as a Unicode type
|
||||||
"""
|
"""
|
||||||
impl = types.Unicode
|
impl = types.Unicode
|
||||||
|
|
||||||
def coerce_compared_value(self, op, value):
|
def coerce_compared_value(self, op, value):
|
||||||
"""
|
"""
|
||||||
Some times it make sense to compare a PathType with a string. In the case a string is used coerce the the
|
Some times it make sense to compare a PathType with a string. In the case a string is used coerce the the
|
||||||
@ -223,10 +224,8 @@ class PathType(types.TypeDecorator):
|
|||||||
|
|
||||||
:param op: The operation being carried out. Not used, as we only care about the type that is being used with the
|
:param op: The operation being carried out. Not used, as we only care about the type that is being used with the
|
||||||
operation.
|
operation.
|
||||||
:param psthlib.Path | str value: The value being used for the comparison. Most likely a Path
|
:param pathlib.Path | str value: The value being used for the comparison. Most likely a Path Object or str.
|
||||||
Object or str.
|
:return PathType | UnicodeText: The coerced value stored in the db
|
||||||
:return: The coerced value stored in the db
|
|
||||||
:rtype: PathType or UnicodeText
|
|
||||||
"""
|
"""
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
return UnicodeText()
|
return UnicodeText()
|
||||||
@ -237,10 +236,9 @@ class PathType(types.TypeDecorator):
|
|||||||
"""
|
"""
|
||||||
Convert the Path object to a JSON representation
|
Convert the Path object to a JSON representation
|
||||||
|
|
||||||
:param psthlib.Path value: The value to convert
|
:param pathlib.Path value: The value to convert
|
||||||
:param dialect: Not used
|
:param dialect: Not used
|
||||||
:return: The Path object as a JSON string
|
:return str: The Path object as a JSON string
|
||||||
:rtype: str
|
|
||||||
"""
|
"""
|
||||||
data_path = AppLocation.get_data_path()
|
data_path = AppLocation.get_data_path()
|
||||||
return json.dumps(value, cls=OpenLPJSONEncoder, base_path=data_path)
|
return json.dumps(value, cls=OpenLPJSONEncoder, base_path=data_path)
|
||||||
@ -252,7 +250,7 @@ class PathType(types.TypeDecorator):
|
|||||||
:param types.UnicodeText value: The value to convert
|
:param types.UnicodeText value: The value to convert
|
||||||
:param dialect: Not used
|
:param dialect: Not used
|
||||||
:return: The JSON object converted Python object (in this case it should be a Path object)
|
:return: The JSON object converted Python object (in this case it should be a Path object)
|
||||||
:rtype: psthlib.Path
|
:rtype: pathlib.Path
|
||||||
"""
|
"""
|
||||||
data_path = AppLocation.get_data_path()
|
data_path = AppLocation.get_data_path()
|
||||||
return json.loads(value, cls=OpenLPJSONDecoder, base_path=data_path)
|
return json.loads(value, cls=OpenLPJSONDecoder, base_path=data_path)
|
||||||
@ -350,8 +348,8 @@ class Manager(object):
|
|||||||
|
|
||||||
:param plugin_name: The name to setup paths and settings section names
|
:param plugin_name: The name to setup paths and settings section names
|
||||||
:param init_schema: The init_schema function for this database
|
:param init_schema: The init_schema function for this database
|
||||||
:param pathlib.Path db_file_path: The file name to use for this database. Defaults to None
|
:param pathlib.Path | None db_file_path: The file name to use for this database. Defaults to None resulting in
|
||||||
resulting in the plugin_name being used.
|
the plugin_name being used.
|
||||||
:param upgrade_mod: The upgrade_schema function for this database
|
:param upgrade_mod: The upgrade_schema function for this database
|
||||||
"""
|
"""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
Loading…
Reference in New Issue
Block a user