diff --git a/bkt/addin.py b/bkt/addin.py index 7f8d2340..13d852e0 100644 --- a/bkt/addin.py +++ b/bkt/addin.py @@ -68,7 +68,7 @@ def __init__(self): def init_callbacks_from_control(self, control): ''' initialize all callbacks from given control and its children ''' - logging.debug('CallbackManager: init_callbacks for %s ', control) + logging.debug('CallbackManager: init_callbacks for %s ' % control) if (not control): return @@ -209,13 +209,13 @@ def fallback_get_enabled(self, control): return False def _callback(self, callback_type, control, *args, **kwargs): - logging.debug("invoke callback for control. callback=%s, control.id=%s", callback_type, control.id) + logging.debug("invoke callback for control. callback=" + str(callback_type) + ", control.id=" + str(control.id)) #logging.debug("invoke callback for control. callback=" + str(callback_type) + ", control=" + str(control)) my_control, callback = self.callback_manager.resolve_callback(callback_type, control) return_value = None if my_control is None: - logging.warning("could not process callback. no control for control %s, event type %s", control, callback_type) + logging.warning("could not process callback. no control for control %s, event type %s" % (control, callback_type)) if callback_type == bkt.CallbackTypes.get_enabled: return True else: @@ -224,9 +224,9 @@ def _callback(self, callback_type, control, *args, **kwargs): if callback is None: #Do not show hundreds of warnings due to get_enabled if callback_type == bkt.CallbackTypes.get_enabled: - logging.debug("could not process callback. no callback of type %s for control %s. trying fallback", callback_type, control) + logging.debug("could not process callback. no callback of type %s for control %s. trying fallback" % (callback_type, control)) else: - logging.warning("could not process callback. no callback of type %s for control %s. trying fallback", callback_type, control) + logging.warning("could not process callback. no callback of type %s for control %s. trying fallback" % (callback_type, control)) #logging.warning("could not process callback. no callback of type %s for control %s. trying fallback" % (callback_type, control)) fallback = self.fallback_map.get(callback_type) @@ -244,7 +244,7 @@ def _callback(self, callback_type, control, *args, **kwargs): #kwargs.update(self.context.resolve_callback.resolve_arguments(callback.invocation_context)) #return_value= self.app_callbacks.invoke_callback(callback, *args, **kwargs) return_value= self.context.invoke_callback(callback, *args, **kwargs) - logging.debug("return value=%s", return_value) + logging.debug("return value={}".format(return_value)) if callback.callback_type == bkt.CallbackTypes.get_content: # get_content return ribbon-menu-object @@ -256,13 +256,13 @@ def _callback(self, callback_type, control, *args, **kwargs): #FIXME: workaround for ampersand in label, etc... But would be better to escape this properly also incl. < and > return_value = return_value.replace("&", "&") else: - logging.warning("Unexpected return-type in callback for get_content: got %s, expected %s", type(menu), bkt.ribbon.Menu) + logging.warning("Unexpected return-type in callback for get_content: got %s, expected %s" % (type(menu), bkt.ribbon.Menu)) return_value = str(menu) - logging.debug("get_content returned:\n%s", return_value) + logging.debug("get_content returned:\n {}".format(return_value)) except: - logging.error("invoke callback failed for\ncallback-type=%s\ncallback=%s", callback_type, callback) + logging.error("invoke callback failed for\ncallback-type=" + str(callback_type) + "\ncallback=" + str(callback)) logging.debug(traceback.format_exc()) try: if bkt.config.show_exception: @@ -295,7 +295,7 @@ def _callback(self, callback_type, control, *args, **kwargs): def task_pane(self, sender, eventargs): - logging.debug("---------- event: %s ---------- type / name: %s / %s ----------", eventargs.RoutedEvent, type(eventargs.Source), eventargs.Source.Name) + logging.debug("---------- event: %s ---------- type / name: %s / %s ----------" % (eventargs.RoutedEvent, type(eventargs.Source), eventargs.Source.Name)) #logging.debug("task pane invoked callback. event-type=%s, sender name/type=%s/%s" % (eventargs.RoutedEvent, eventargs.Source.Name, eventargs.Source)) # logging.debug("routed event details: type=%s" % type(eventargs.RoutedEvent)) # logging.debug("routed event details: name=%s" % eventargs.RoutedEvent.Name) @@ -314,37 +314,37 @@ def task_pane(self, sender, eventargs): # 2) reroute by EventType # FIXME: define routings in taskpane.py # TODO: invalidation und Nutzung get_pressed, get_enabled, get_text, ... - logging.debug("Start RoutedEvents-mapping: RoutedEvent-Name=%s, Source-Type=%s", str(eventargs.RoutedEvent.Name), str(eventargs.Source.GetType())) + logging.debug("Start RoutedEvents-mapping: RoutedEvent-Name=%s, Source-Type=%s" % (str(eventargs.RoutedEvent.Name), str(eventargs.Source.GetType()))) if str(eventargs.RoutedEvent.Name)=='LostFocus': if str(eventargs.Source.GetType()) in ['Fluent.TextBox', 'Fluent.Spinner']: ### TEXTBOX LOST FOCUS EVENT - logging.debug("map RoutedEvent to CallbackType.on_change: text=%s", eventargs.Source.Text) + logging.debug("map RoutedEvent to CallbackType.on_change: text=%s" % eventargs.Source.Text) self._callback(bkt.CallbackTypes.on_change, eventargs.Source, eventargs.Source.Text) elif str(eventargs.Source.GetType()) in ['Fluent.ComboBox']: if not eventargs.Source.IsReadOnly: ### EDITABLE COMBOBOX LOST FOCUS EVENT - logging.debug("map RoutedEvent to CallbackType.on_change: text=%s", eventargs.Source.Text) + logging.debug("map RoutedEvent to CallbackType.on_change: text=%s" % eventargs.Source.Text) self._callback(bkt.CallbackTypes.on_change, eventargs.Source, eventargs.Source.Text) elif str(eventargs.RoutedEvent.Name)=='KeyDown': if str(eventargs.Source.GetType()) in ['Fluent.TextBox', 'Fluent.Spinner']: ### TEXTBOX ENTER FIRED - logging.debug("map RoutedEvent to CallbackType.on_change: text=%s", eventargs.Source.Text) + logging.debug("map RoutedEvent to CallbackType.on_change: text=%s" % eventargs.Source.Text) self._callback(bkt.CallbackTypes.on_change, eventargs.Source, eventargs.Source.Text) elif str(eventargs.Source.GetType()) in ['Fluent.ComboBox']: if not eventargs.Source.IsReadOnly: ### EDITABLE COMBOBOX ENTER FIRED - logging.debug("map RoutedEvent to CallbackType.on_change: text=%s", eventargs.Source.Text) + logging.debug("map RoutedEvent to CallbackType.on_change: text=%s" % eventargs.Source.Text) self._callback(bkt.CallbackTypes.on_change, eventargs.Source, eventargs.Source.Text) elif str(eventargs.RoutedEvent.Name)=='Click': if str(eventargs.Source.GetType()) in ['Fluent.MenuItem']: if eventargs.Source.IsCheckable == True: ### MENU ITEM TOGGLE EVENT - logging.debug("map RoutedEvent to CallbackType.on_toggle_action: pressed/checked=%s", eventargs.Source.IsChecked) + logging.debug("map RoutedEvent to CallbackType.on_toggle_action: pressed/checked=%s" % eventargs.Source.IsChecked) self._callback(bkt.CallbackTypes.on_toggle_action, eventargs.Source, eventargs.Source.IsChecked) else: @@ -360,7 +360,7 @@ def task_pane(self, sender, eventargs): elif str(eventargs.Source.GetType()) in ['System.Windows.Controls.Primitives.ToggleButton', 'Fluent.ToggleButton', 'Fluent.CheckBox', 'Fluent.RadioButton']: ### TOGGLE EVENT - logging.debug("map RoutedEvent to CallbackType.on_toggle_action: pressed/checked=%s", eventargs.Source.IsChecked) + logging.debug("map RoutedEvent to CallbackType.on_toggle_action: pressed/checked=%s" % eventargs.Source.IsChecked) self._callback(bkt.CallbackTypes.on_toggle_action, eventargs.Source, eventargs.Source.IsChecked) else: @@ -377,27 +377,27 @@ def task_pane(self, sender, eventargs): if str(eventargs.Source.GetType()) in ['Fluent.Gallery', 'Fluent.InRibbonGallery']: ### GALLERY SELECTION CHANGE EVENT # assume eventargs.Source.SelectedValue is TextBlock - logging.debug("map RoutedEvent to on_change: value=%s", eventargs.Source.SelectedValue.Text) + logging.debug("map RoutedEvent to on_change: value=%s" % eventargs.Source.SelectedValue.Text) self._callback(bkt.CallbackTypes.on_change, eventargs.Source, eventargs.Source.SelectedValue.Text) elif str(eventargs.Source.GetType()) in ['Fluent.ComboBox']: ### COMBOBOX ACTION INDEXD EVENT / SELECTION CHANGE EVENT - logging.debug("map RoutedEvent to on_action_indexed: index=%s", eventargs.Source.SelectedIndex) + logging.debug("map RoutedEvent to on_action_indexed: index=%s" % eventargs.Source.SelectedIndex) self._callback(bkt.CallbackTypes.on_action_indexed, eventargs.Source, eventargs.Source.SelectedIndex, eventargs.Source.SelectedIndex) - logging.debug("map RoutedEvent to on_change: value=%s", eventargs.Source.SelectedValue) + logging.debug("map RoutedEvent to on_change: value=%s" % str(eventargs.Source.SelectedValue)) self._callback(bkt.CallbackTypes.on_change, eventargs.Source, str(eventargs.Source.SelectedValue.Content)) elif str(eventargs.RoutedEvent.Name)=='SelectedDateChanged': ### DATE PICKER CHANGE EVENT - logging.debug("map RoutedEvent to CallbackType.on_change: value=%s", eventargs.Source.SelectedDate) + logging.debug("map RoutedEvent to CallbackType.on_change: value=%s" % eventargs.Source.SelectedDate) self._callback(bkt.CallbackTypes.on_change, eventargs.Source, eventargs.Source.SelectedDate) elif str(eventargs.RoutedEvent.Name)=='SelectedColorChanged': ### SELECTED COLOR CHANGE EVENT - logging.debug("map RoutedEvent to on_rgb_color_change: value=%s", eventargs.Source.SelectedColor) + logging.debug("map RoutedEvent to on_rgb_color_change: value=%s" % eventargs.Source.SelectedColor) self._callback(bkt.CallbackTypes.on_rgb_color_change, eventargs.Source, color=eventargs.Source.SelectedColor) logging.debug("done") @@ -423,12 +423,12 @@ def task_pane(self, sender, eventargs): def task_pane_value_changed(self, sender, eventargs): - logging.debug("---------- event: ValueCanged ---------- type / name: %s ----------", sender.Name) + logging.debug("---------- event: ValueCanged ---------- type / name: %s ----------" % (sender.Name)) try: # eventargs RoutedPropertyChangedEventArgs - logging.debug('value changed, old-value=%s, new-value=%s', eventargs.OldValue, eventargs.NewValue) + logging.debug('value changed, old-value=%s, new-value=%s' % (eventargs.OldValue, eventargs.NewValue) ) logging.debug("map RoutedEvent to CallbackType.on_change") self._callback(bkt.CallbackTypes.on_change, sender, eventargs.NewValue, old_value=eventargs.OldValue, new_value=eventargs.NewValue) @@ -557,16 +557,16 @@ def on_create(self, dotnet_context): # load modules listed in configuration for module in bkt.config.modules or []: if not module in sys.modules: - logging.info('importing module: %s', module) + logging.info('importing module: %s' % module) try: importlib.import_module(module) # __import__(module) except: - logging.critical('failed to load %s', module) + logging.critical('failed to load %s' % module) logging.debug(traceback.format_exc()) - bkt.message.error('failed to load %s', module) + bkt.message.error('failed to load %s' % module) if bkt.config.show_exception: - _h.exception_as_message('failed to load %s', module) + _h.exception_as_message('failed to load %s' % module) CACHE_VERSION = "20191213" @@ -596,7 +596,7 @@ def on_create(self, dotnet_context): for module_name, feature in import_cache['inits.features'].iteritems(): # feature = import_cache['feature.'+module_name] - logging.info('importing bkt feature: %s', feature['name']) + logging.info('importing bkt feature: %s' % feature['name']) try: # import module as package, acts like 'import module_name' #f, path, description = imp.find_module(module_name, base_folder) @@ -606,28 +606,28 @@ def on_create(self, dotnet_context): module = importlib.import_module(module_name + '.__bkt_init__') if feature['use_constructor']: - logging.debug("loading bkt feature %s using constructor method", feature['name']) + logging.debug("loading bkt feature %s using constructor method" % feature['name']) module.BktFeature.contructor() except: - logging.critical('failed to load feature %s from cache', module_name) + logging.critical('failed to load feature %s from cache' % module_name) logging.debug(traceback.format_exc()) - bkt.message.error('failed to load feature %s from cache', module_name) + bkt.message.error('failed to load feature %s from cache' % module_name) if bkt.config.show_exception: - _h.exception_as_message('failed to load feature %s from cache', module_name) + _h.exception_as_message('failed to load feature %s from cache' % module_name) #TODO: remove cache on error? for module_name, folder in import_cache['inits.legacy']: - logging.info('importing legacy feature-folder: %s', folder) + logging.info('importing legacy feature-folder: %s' % folder) try: # imp.load_source(module_name, os.path.join(folder, "__init__.py")) importlib.import_module(module_name) except: - logging.critical('failed to load legacy feature %s from cache', module_name) + logging.critical('failed to load legacy feature %s from cache' % module_name) logging.debug(traceback.format_exc()) - bkt.message.error('failed to load legacy feature %s from cache', module_name) + bkt.message.error('failed to load legacy feature %s from cache' % module_name) if bkt.config.show_exception: - _h.exception_as_message('failed to load legacy feature %s from cache', module_name) + _h.exception_as_message('failed to load legacy feature %s from cache' % module_name) #TODO: remove cache on error? # load and renew cache: @@ -645,7 +645,7 @@ def on_create(self, dotnet_context): # load modules from feature-folders and fill cache on-the-fly for folder in bkt.config.feature_folders: - logging.info('importing feature-folder: %s', folder) + logging.info('importing feature-folder: %s' % folder) base_folder = os.path.realpath(os.path.join(folder, "..")) module_name = os.path.basename(folder) @@ -668,16 +668,16 @@ def on_create(self, dotnet_context): # run bkt_init # module = imp.load_source(module_name + '.__bkt_init__' , init_filename) module = importlib.import_module(module_name + '.__bkt_init__') - logging.debug('module: %s', module) + logging.debug('module: %s' % module) try: #only load if relevant for active app if self.context.host_app_name not in module.BktFeature.relevant_apps: - logging.info("bkt feature %s not relevant for current app", module.BktFeature.name) + logging.info("bkt feature %s not relevant for current app" % module.BktFeature.name) continue except AttributeError: #legacy bkt_init, load for all apps, always - logging.warning("bkt feature %s not using new loading mechanism", module_name) + logging.warning("bkt feature %s not using new loading mechanism" % module_name) _c_bkt_inits[module_name] = { 'name': module_name, 'folder': folder, @@ -687,15 +687,15 @@ def on_create(self, dotnet_context): #only load if dependencies are loaded dependencies = getattr(module.BktFeature, "dependencies", []) if not all(d in _c_bkt_inits for d in dependencies): - logging.warning("bkt feature %s is missing dependencies", module.BktFeature.name) + logging.warning("bkt feature %s is missing dependencies" % module.BktFeature.name) continue #only load if there are no conflicting features loaded conflicts = getattr(module.BktFeature, "conflicts", []) if module_name in _known_conflicts or any(m in _c_bkt_inits for m in conflicts): - logging.warning("bkt feature %s has a conflict", module.BktFeature.name) + logging.warning("bkt feature %s has a conflict" % module.BktFeature.name) continue - logging.debug("loading bkt feature %s using constructor method", module.BktFeature.name) + logging.debug("loading bkt feature %s using constructor method" % module.BktFeature.name) module.BktFeature.contructor() #add to cache only if relevant for this app and loading successful @@ -707,17 +707,17 @@ def on_create(self, dotnet_context): #add conflicting modules _known_conflicts.extend(conflicts) except: - logging.critical('failed to load feature-folder %s', folder) + logging.critical('failed to load feature-folder %s' % folder) logging.debug(traceback.format_exc()) - bkt.message.error('failed to load feature-folder %s', folder) + bkt.message.error('failed to load feature-folder %s' % folder) if bkt.config.show_exception: - _h.exception_as_message('failed to load feature-folder %s', folder) + _h.exception_as_message('failed to load feature-folder %s' % folder) #TODO: Offer user to remove feature folder from config on error # backwards compatibility: load module from init.py elif os.path.isfile(os.path.join(folder, "__init__.py")): try: - logging.warning("bkt feature %s is using legacy import", module_name) + logging.warning("bkt feature %s is using legacy import" % module_name) # sys.path.append(folder) # imp.load_source(module_name, os.path.join(folder, "__init__.py")) sys.path.append(base_folder) @@ -726,16 +726,16 @@ def on_create(self, dotnet_context): _c_sys_paths.add(base_folder) _c_legacy_inits.append((module_name, folder)) except: - logging.critical('failed to load legacy feature-folder %s', folder) + logging.critical('failed to load legacy feature-folder %s' % folder) logging.debug(traceback.format_exc()) - bkt.message.error('failed to load legacy feature-folder %s', folder) + bkt.message.error('failed to load legacy feature-folder %s' % folder) if bkt.config.show_exception: - _h.exception_as_message('failed to load legacy feature-folder %s', folder) + _h.exception_as_message('failed to load legacy feature-folder %s' % folder) #TODO: Offer user to remove feature folder from config on error # feature folder without python init file else: - logging.warning('feature-folder %s has no init files', folder) + logging.warning('feature-folder %s has no init files' % folder) #save to cache @@ -754,7 +754,7 @@ def on_create(self, dotnet_context): #### initialize AppUI, AppCallbacks try: - logging.debug('initialize classes for app: %s', self.context.host_app_name) + logging.debug('initialize classes for app: %s' % self.context.host_app_name) # retrieve AppUI-instance self.app_ui = bkt.appui.AppUIs.get_app_ui(self.context.host_app_name) self.events = bkt.apps.AppEvents @@ -805,7 +805,7 @@ def load_image(self, image_name): def get_custom_ui(self, ribbon_id): try: - logging.info('Retrieve CustomUI for ribbon: %s', ribbon_id) + logging.info('Retrieve CustomUI for ribbon: %s' % ribbon_id) if self.app_ui is None: return None diff --git a/bkt/apps.py b/bkt/apps.py index e3cb0e3c..93542a2d 100644 --- a/bkt/apps.py +++ b/bkt/apps.py @@ -31,7 +31,7 @@ def set_attribute(self, attr): self.event_name = attr def register(self, method): - logging.debug("Method registered for event: %r", self.event_name) + logging.debug("Method registered for event: %r" % self.event_name) if isinstance(method, Callback) and method.callback_type is None: method.callback_type = CallbackTypes.bkt_event @@ -40,7 +40,7 @@ def register(self, method): return self def unregister(self, method): - logging.debug("Method unregistered for event: %r", self.event_name) + logging.debug("Method unregistered for event: %r" % self.event_name) self.registered_methods.remove(method) return self @@ -155,7 +155,7 @@ def destroy(self): # ========== def fire_event(self, event, **kwargs): - logging.debug("Event triggered: %r", event) + logging.debug("Event triggered: %r" % event) for method in event: try: if isinstance(method, Callback): @@ -201,12 +201,12 @@ def invoke_callback(self, context, callback, *args, **kwargs): cache_key = str(callback.method) #TESTME: is method string representation sufficient as key? add callback type? do_cache = True try: - logging.debug("trying cache for %r", cache_key) + logging.debug("trying cache for %r" % cache_key) return self.cache[cache_key] # if time.time() - self.cache[cache_key][1] < self.cache_timeout: # return self.cache[cache_key][0] except KeyError: - logging.debug("no cache for %r", cache_key) + logging.debug("no cache for %r" % cache_key) for i, arg in enumerate(args): kwargs[callback.callback_type.pos_args[i]] = arg @@ -225,7 +225,7 @@ def invoke_callback(self, context, callback, *args, **kwargs): return self.undo_start(callback) - logging.debug("AppCallbacksBase.invoke_callback: run callback method\nkwargs=%s", kwargs) + logging.debug("AppCallbacksBase.invoke_callback: run callback method\nkwargs=%s" % kwargs) return_value = callback.method(**kwargs) self.undo_end(callback) diff --git a/bkt/appui.py b/bkt/appui.py index ddf9f377..e2692aae 100644 --- a/bkt/appui.py +++ b/bkt/appui.py @@ -228,10 +228,10 @@ def create_control(self, element, ribbon_id=None): element_id = element.id if element_id in self.custom_ribbon_uis[ribbon_id].lazy_replacements: element = self.custom_ribbon_uis[ribbon_id].lazy_replacements[element_id] - logging.debug("create_control: element with id %s replaced by element with id %s", element_id, element.id) + logging.debug("create_control: element with id {} replaced by element with id {}".format(element_id, element.id)) if element_id in self.custom_ribbon_uis[ribbon_id].lazy_extensions: element.children.extend( self.custom_ribbon_uis[ribbon_id].lazy_extensions[element_id] ) - logging.debug("create_control: element with id %s extended", element_id) + logging.debug("create_control: element with id {} extended".format(element_id)) element.children = [self.create_control(c, ribbon_id=ribbon_id) for c in element.children ] return element @@ -241,15 +241,15 @@ def create_control(self, element, ribbon_id=None): from bkt.factory import ControlFactory #@deprecated if isinstance(element, ContainerUsage): - logging.debug("create_control for ContainerUsage: %s", element.container) + logging.debug("create_control for ContainerUsage: %s" % element.container) return ControlFactory(element.container, ribbon_info=None).create_control() else: - logging.warning("FeatureContainer used where instance of ContainerUsage was expected: %s", element) + logging.warning("FeatureContainer used where instance of ContainerUsage was expected: %s" % element) return ControlFactory(element, ribbon_info=None).create_control() else: - logging.warning("create_control for element %s skipped", element) + logging.warning("create_control for element {} skipped".format(element)) @@ -363,7 +363,7 @@ def create_taskpane_control(self): image_name: _h.Resources.images.locate(image_name) for image_name in stack_panel.collect_image_resources() } - logging.debug('image resources: %s', image_resources) + logging.debug('image resources: %s' % image_resources) taskpane_control = bkt.taskpane.BaseScrollViewer( image_resources = image_resources, children = [stack_panel] diff --git a/bkt/contextdialogs.py b/bkt/contextdialogs.py index fa270a36..ab9a28c9 100644 --- a/bkt/contextdialogs.py +++ b/bkt/contextdialogs.py @@ -58,7 +58,7 @@ def trigger_doubleclick(self, shape, context): return self.module.trigger_doubleclick(shape, context) except AttributeError: - logging.warning("ContextDialog.trigger_doubleclick: No double click action defined in module %s", self.module_name) + logging.warning("ContextDialog.trigger_doubleclick: No double click action defined in module %s" % self.module_name) except: logging.error(traceback.format_exc()) @@ -151,7 +151,7 @@ def import_module(self): will not reload if module was already loaded ''' if not self.module: - logging.debug('ContextDialog.import_module importing %s', self.module_name) + logging.debug('ContextDialog.import_module importing %s' % self.module_name) #do an import equivalent to: import <> self.module = importlib.import_module(self.module_name) # self.module = __import__(self.module_name, globals(), locals(), [], -1) @@ -184,17 +184,17 @@ def __init__(self): def register(self, id, module): ''' register a context dialog ''' - logging.debug('ContextDialogs.register: id=%s', id) + logging.debug('ContextDialogs.register: id=%s' % id) self.dialogs[id] = ContextDialog(id,module) def register_dialog(self, context_dialog): ''' register a context dialog from context-dialog-object ''' - logging.debug('ContextDialogs.register_dialog: id=%s', context_dialog.id) + logging.debug('ContextDialogs.register_dialog: id=%s' % context_dialog.id) self.dialogs[context_dialog.id] = context_dialog def unregister(self, id): ''' unregister a context dialog ''' - logging.debug('ContextDialogs.unregister: id=%s', id) + logging.debug('ContextDialogs.unregister: id=%s' % id) try: del self.dialogs[id] except KeyError: @@ -278,7 +278,7 @@ def show_shape_dialog_for_shape(self, shape, context): try: ctx_dialog = self.dialogs[shape_tag] except KeyError: - logging.warning('No dialog registered for given key: %s', shape_tag) + logging.warning('No dialog registered for given key: %s' % shape_tag) return self.active_dialog = ctx_dialog.show_dialog_at_shape_position(shape, context) @@ -354,7 +354,7 @@ def trigger_doubleclick_for_shape(self, shape, context): try: ctx_dialog = self.dialogs[shape_tag] except KeyError: - logging.warning('No dialog registered for given key: %s', shape_tag) + logging.warning('No dialog registered for given key: %s' % shape_tag) return ctx_dialog.trigger_doubleclick(shape, context) diff --git a/bkt/library/comrelease.py b/bkt/library/comrelease.py index f97b4702..db5dfec9 100644 --- a/bkt/library/comrelease.py +++ b/bkt/library/comrelease.py @@ -42,7 +42,7 @@ def __init__(self, comobj, release_self=True): self._comobj = comobj self._release_self = release_self self._accessed_com_attributes = [] - logging.debug("Com-Release: created %s", self) + logging.debug("Com-Release: created %s" % (self)) # Magic methods: https://rszalski.github.io/magicmethods/ @@ -76,11 +76,7 @@ def __isub__(self, other): # def __str__(self): #__str__ not required as __repr__ returns a string def __repr__(self): - try: - return "" % (self._comobj) - except SystemError: - #in rare situations the com object is already released and logging calls __repr__ which throws SystemError - return ">" + return "" % (self._comobj) def __dir__(self): #this is essential for interactive python console @@ -118,7 +114,7 @@ def __getattr__(self, attr): return self value = getattr(self._comobj, attr) - logging.debug("Com-Release: access to attribute %s", attr) + logging.debug("Com-Release: access to attribute %s" % (attr)) if type(value).__name__ != 'DispCallable': # attribute did not return a function @@ -229,12 +225,12 @@ def create_and_register_auto_release_com_object(self, com_obj): if type(com_obj).__name__ == '__ComObject': if self._is_comobj: auto_release_com_obj = AutoReleasingComObject(com_obj, release_self=True) - logging.debug("Com-Release: created com-object %s", com_obj) + logging.debug("Com-Release: created com-object %s" % (com_obj)) else: # self is no com-Object, but the attribute is. # Hence, attribute is not generated here and should not be disposed. # therefore: release_self=False - logging.debug("Com-Release: accessed existing com-object %s", com_obj) + logging.debug("Com-Release: accessed existing com-object %s" % (com_obj)) auto_release_com_obj = AutoReleasingComObject(com_obj, release_self=False) self._accessed_com_attributes.append(auto_release_com_obj) @@ -256,14 +252,14 @@ def dispose(self): Therefore, all ComObjects accessed in the object-tree are released by a single dispose-call. ''' # release ComObjects generated further down the object-tree - logging.debug("Com-Release: dispose on %s", self) + logging.debug("Com-Release: dispose on %s" % (self)) for auto_release_com_obj in self._accessed_com_attributes: auto_release_com_obj.dispose() self._accessed_com_attributes = [] # release wrapped ComObject if self._release_self: - logging.debug("Com-Release: releasing %s", self) + logging.debug("Com-Release: releasing %s" % (self._comobj)) Marshal.ReleaseComObject(self._comobj) diff --git a/bkt/library/search.py b/bkt/library/search.py index 23cf3885..17d8c911 100644 --- a/bkt/library/search.py +++ b/bkt/library/search.py @@ -145,7 +145,7 @@ def commit(self): #do not create duplicates if doc_hash in self._engine._docs: - logging.debug("SEARCH: duplicate doc hash %s", doc_hash) + logging.debug("SEARCH: duplicate doc hash "+str(doc_hash)) continue #split comma-seperated values in list @@ -156,7 +156,7 @@ def commit(self): keywords = doc.keywords self._engine._docs[doc_hash] = doc - logging.debug("SEARCH: commit document %s for keywords: %s", doc_hash, keywords) + logging.debug("SEARCH: commit document {} for keywords: {}".format(doc_hash, keywords)) for keyword in keywords: keyword = keyword.lower() self._engine._keywords.add(keyword) @@ -178,7 +178,7 @@ def search(self, query, join_and=True): join_and=True > multiple keywords are connected with AND join_and=False > multiple keywords are connected with OR ''' - logging.debug("SEARCH: for %s", query) + logging.debug("SEARCH: for "+query) #add to search history self._engine.add_to_recent(query) @@ -260,7 +260,7 @@ def search_exact(self, query, join_and=True): join_and=True > multiple keywords are connected with AND join_and=False > multiple keywords are connected with OR ''' - logging.debug("SEARCH EXACT: for %s", query) + logging.debug("SEARCH EXACT: for "+query) #add to search history self._engine.add_to_recent(query) diff --git a/bkt/library/table.py b/bkt/library/table.py index 68abde76..05ae02c3 100644 --- a/bkt/library/table.py +++ b/bkt/library/table.py @@ -8,7 +8,7 @@ from __future__ import absolute_import, division #always force float-division, for int divison use // import math -# import logging +import logging from .algorithms import mean, median @@ -192,7 +192,7 @@ def get_index(cell): continue index = get_index(cell) if line_new[index] is not None: - # logging.debug("cell index %d is duplicated in line %d\r\nedges: %r" % (index,i,edges)) + logging.debug("cell index %d is duplicated in line %d\r\nedges: %r" % (index,i,edges)) line_new = list(line) while len(line_new) < num_cols: line_new.append(None) diff --git a/bkt/ribbon.py b/bkt/ribbon.py index 96d9e85f..55914855 100644 --- a/bkt/ribbon.py +++ b/bkt/ribbon.py @@ -124,7 +124,7 @@ def __init__(self, xml_name, id_tag=None, attributes={}, **kwargs): self._attributes[self._id_attribute_key] = self.create_persisting_id() # elif isinstance(self, Tab): else: - logging.debug("Predefined ID found: %s (%s)", pre_id, self._attributes[pre_id]) + logging.debug("Predefined ID found: %s (%s)" % (pre_id, self._attributes[pre_id])) # enable callbacks for idMso tab (e.g. powerpoint contextual tabs) self._id_attribute_key = pre_id diff --git a/bkt/taskpane.py b/bkt/taskpane.py index 83b88501..6b495dc1 100644 --- a/bkt/taskpane.py +++ b/bkt/taskpane.py @@ -303,7 +303,7 @@ def __init__(self, *args, **user_kwargs): # add image resources for image_name, image_path in self.image_resources.items(): - logging.debug('image resource %s=%s', image_name, image_path) + logging.debug('image resource %s=%s' % (image_name, image_path)) resources_node.root.Add( XmlPart('' % (image_name, image_path)).wpf_xml() ) diff --git a/features/ppt_quickedit/quickedit.py b/features/ppt_quickedit/quickedit.py index 0ec3b637..e5f1ba8d 100644 --- a/features/ppt_quickedit/quickedit.py +++ b/features/ppt_quickedit/quickedit.py @@ -60,7 +60,7 @@ def close_panel_for_active_window(cls, context, presentation): @classmethod def _show_panel(cls, context, windowid): - logging.debug("show panel for window %s", windowid) + logging.debug("show panel for window %s" % windowid) try: panel = cls._create_panel(context) panel.SetOwner(windowid) @@ -77,7 +77,7 @@ def _show_panel(cls, context, windowid): @classmethod def _close_panel(cls, windowid): - logging.debug("close panel for window %s", windowid) + logging.debug("close panel for window %s" % windowid) try: cls.panel_windows[windowid].Close() del cls.panel_windows[windowid] diff --git a/features/ppt_quickedit/quickedit_model.py b/features/ppt_quickedit/quickedit_model.py index 6cfc74b3..93d7c5e6 100644 --- a/features/ppt_quickedit/quickedit_model.py +++ b/features/ppt_quickedit/quickedit_model.py @@ -72,11 +72,11 @@ def update_rgb_from_context(self, context): if self.shade_index == -1: color = pplib.ColorHelper.get_theme_color(context, self.color_index, brightness=self.brightness) self.shade_index = color.shade_index - logging.debug("QuickEdit: shade index changed to %s", self.shade_index) + logging.debug("QuickEdit: shade index changed to %s" % str(self.shade_index)) elif self.shade_index is not None: color = pplib.ColorHelper.get_theme_color(context, self.color_index, shade_index=self.shade_index) self.brightness = color.brightness - logging.debug("QuickEdit: brightness changed to %s", self.brightness) + logging.debug("QuickEdit: brightness changed to %s" % str(self.brightness)) else: color = pplib.ColorHelper.get_theme_color(context, self.color_index, brightness=self.brightness) self.color_rgb = color.rgb diff --git a/features/ppt_quickedit/quickedit_panel.py b/features/ppt_quickedit/quickedit_panel.py index bdef9bf8..190d573a 100644 --- a/features/ppt_quickedit/quickedit_panel.py +++ b/features/ppt_quickedit/quickedit_panel.py @@ -12,7 +12,6 @@ from System.Collections.ObjectModel import ObservableCollection from System.Windows.Controls import Orientation -from System.Windows.Media import Colors, SolidColorBrush from System.Windows import Visibility import bkt.ui @@ -51,7 +50,6 @@ VIEWSTATE_RECENT_HIDDEN = 1 DOCKING_SLIDE_LEFT = 2 -DARK_THEME = 4 class ViewModel(bkt.ui.ViewModelSingleton): def __init__(self, orientation_mode, window_left, window_top, viewstate): @@ -63,9 +61,6 @@ def __init__(self, orientation_mode, window_left, window_top, viewstate): self._viewstate = viewstate self._editmode = False - - self._brush_dark = SolidColorBrush(Colors.DimGray) - self._brush_light = SolidColorBrush(Colors.WhiteSmoke) self._catalogs = ObservableCollection[QECatalog]() for cat in QuickEdit._catalogs: @@ -161,20 +156,6 @@ def recent_visibility(self): return Visibility.Visible else: return Visibility.Collapsed - - @notify_property - def color_background(self): - if self.dark_theme: - return self._brush_dark - else: - return self._brush_light - - @notify_property - def color_foreground(self): - if self.dark_theme: - return self._brush_light - else: - return self._brush_dark @notify_property def recent_visible(self): @@ -199,18 +180,6 @@ def docking_left(self, value): # self.OnPropertyChanged("window_left") # self.OnPropertyChanged("window_top") - @notify_property - def dark_theme(self): - return self._viewstate & DARK_THEME == DARK_THEME - @dark_theme.setter - def dark_theme(self, value): - if value: - self._viewstate = self._viewstate | DARK_THEME - else: - self._viewstate = self._viewstate ^ DARK_THEME - self.OnPropertyChanged("color_background") - self.OnPropertyChanged("color_foreground") - @notify_property def window_left(self): return self._left diff --git a/features/ppt_quickedit/resources/xaml/quickedit_panel.xaml b/features/ppt_quickedit/resources/xaml/quickedit_panel.xaml index 26d94a6e..e256cf65 100644 --- a/features/ppt_quickedit/resources/xaml/quickedit_panel.xaml +++ b/features/ppt_quickedit/resources/xaml/quickedit_panel.xaml @@ -26,7 +26,6 @@ - - + + - @@ -73,36 +71,36 @@ - - - QE + QE - - -