rename param js_use to is_js

This commit is contained in:
Phill 2019-06-21 23:09:36 +01:00
parent 3e2e272776
commit a432a57452
3 changed files with 8 additions and 8 deletions

View File

@ -186,12 +186,12 @@ class PathSerializer(JSONMixin, register_names=('Path', 'PosixPath', 'WindowsPat
return path
@classmethod
def json_object(cls, obj, base_path=None, js_use=False, **kwargs):
def json_object(cls, obj, base_path=None, is_js=False, **kwargs):
"""
Create a dictionary that can be JSON decoded.
:param Path base_path: If specified, an absolute path to make a relative path from.
:param bool js_use: Encode the path as a uri. For example for use in the js rendering code.
:param bool is_js: Encode the path as a uri. For example for use in the js rendering code.
:param kwargs: Contains any extra parameters. Not used!
:return: The dictionary representation of this Path object.
:rtype: dict[tuple]
@ -200,7 +200,7 @@ class PathSerializer(JSONMixin, register_names=('Path', 'PosixPath', 'WindowsPat
if base_path:
with suppress(ValueError):
path = path.relative_to(base_path)
if js_use is True:
if is_js is True:
return path.as_uri()
json_dict = {'parts': path.parts}
cls.attach_meta(json_dict)

View File

@ -332,9 +332,9 @@ class DisplayWindow(QtWidgets.QWidget):
theme_copy = copy.deepcopy(theme)
theme_copy.background_type = 'image'
theme_copy.background_filename = self.checkerboard_path
exported_theme = theme_copy.export_theme(js_use=True)
exported_theme = theme_copy.export_theme(is_js=True)
else:
exported_theme = theme.export_theme(js_use=True)
exported_theme = theme.export_theme(is_js=True)
self.run_javascript('Display.setTheme({theme});'.format(theme=exported_theme))
def get_video_types(self):

View File

@ -225,18 +225,18 @@ class Theme(object):
jsn = json.loads(theme, cls=OpenLPJSONDecoder)
self.expand_json(jsn)
def export_theme(self, theme_path=None, js_use=False):
def export_theme(self, theme_path=None, is_js=False):
"""
Loop through the fields and build a dictionary of them
:param pathlib.Path | None theme_path:
:param bool js_use: For internal use, for example with the theme js code.
:param bool is_js: For internal use, for example with the theme js code.
:return str: The json encoded theme object
"""
theme_data = {}
for attr, value in self.__dict__.items():
theme_data["{attr}".format(attr=attr)] = value
return json.dumps(theme_data, cls=OpenLPJSONEncoder, base_path=theme_path, js_use=js_use)
return json.dumps(theme_data, cls=OpenLPJSONEncoder, base_path=theme_path, is_js=is_js)
def parse(self, xml):
"""