def inject_json_data(self, data: dict): self.description = data["description"] self.store = Store(data["store"]) self.modes = [TriggerMode(item) for item in data["modes"]] self.usageCount = data["usageCount"] self.prompt = data["prompt"] self.omitTrigger = data["omitTrigger"] self.show_in_tray_menu = data["showInTrayMenu"] AbstractAbbreviation.load_from_serialized(self, data["abbreviation"]) AbstractHotkey.load_from_serialized(self, data["hotkey"]) AbstractWindowFilter.load_from_serialized(self, data["filter"])
def __init__(self, description: str, source_code: str, path=None): AbstractAbbreviation.__init__(self) AbstractHotkey.__init__(self) AbstractWindowFilter.__init__(self) self.description = description self.code = source_code self.store = Store() self.modes = [] # type: typing.List[TriggerMode] self.usageCount = 0 self.prompt = False self.omitTrigger = False self.parent = None self.show_in_tray_menu = False self.path = path
def __init__(self, description, code, path=None): AbstractAbbreviation.__init__(self) AbstractHotkey.__init__(self) AbstractWindowFilter.__init__(self) self.description = description self.code = code self.store = Store() self.modes = [] self.usageCount = 0 self.prompt = False self.omitTrigger = False self.parent = None self.showInTrayMenu = False self.path = path
def _remove_non_serializable_store_entries(store: Store) -> dict: """ Copy all serializable data into a new dict, and skip the rest. This makes sure to keep the items during runtime, even if the user edits and saves the script. """ cleaned_store_data = {} for key, value in store.items(): if Script._is_serializable(key) and Script._is_serializable(value): cleaned_store_data[key] = value else: _logger.info("Skip non-serializable item in the local script store. Key: '{}', Value: '{}'. " "This item cannot be saved and therefore will be lost when autokey quits.".format( key, value )) return cleaned_store_data