def _extend_path(): # Inside a function to not leak variables to module namespace import os from kupfer import config from kupfer import pretty if not config.has_capability("CUSTOM_PLUGINS"): return # Add plugins in data directories __path__.extend(config.get_data_dirs("plugins")) # Add .zip files in plugins directories for directory in list(__path__): try: filenames = os.listdir(directory) except OSError, error: pretty.print_error(__name__, error) continue zipnames = [f for f in filenames if f.endswith(".zip")] if zipnames: pretty.print_debug(__name__, "Adding", directory, zipnames) __path__.extend(os.path.join(directory, z) for z in zipnames)
def _extend_path(): # Inside a function to not leak variables to module namespace import os from kupfer import config from kupfer import pretty if not config.has_capability("CUSTOM_PLUGINS"): return # Add plugins in data directories __path__.extend(config.get_data_dirs("plugins")) # Add .zip files in plugins directories for directory in list(__path__): try: filenames = os.listdir(directory) except OSError as error: pretty.print_error(__name__, error) continue zipnames = [f for f in filenames if f.endswith(".zip")] if zipnames: pretty.print_debug(__name__, "Adding", directory, zipnames) __path__.extend(os.path.join(directory, z) for z in zipnames)
def should_use_cache(self): return config.has_capability("CACHE")
def allows_keybinder(): return config.has_capability("KEYBINDER") and not is_wayland()
import gi from gi.repository import GObject from kupfer import pretty from kupfer import config KEYBINDING_DEFAULT = 1 KEYBINDING_MAGIC = 2 KEYRANGE_RESERVED = (3, 0x1000) KEYRANGE_TRIGGERS = (0x1000, 0x2000) Keybinder = None if config.has_capability("KEYBINDER"): try: gi.require_version("Keybinder", "3.0") except ValueError: pretty.print_debug(__name__, "Keybinder 3.0 not available in gi") else: from gi.repository import Keybinder Keybinder.init() else: pretty.print_debug(__name__, "Keybinder disabled") _keybound_object = None def GetKeyboundObject(): """Get the shared instance""" global _keybound_object if not _keybound_object:
def should_use_cache(cls): return config.has_capability("CACHE")