def test_config_set_subconfig(config): """Field is a config object and it should just works""" config.deffield('nowplaying', type_=Config) config.nowplaying = Config() config.nowplaying.deffield('control', type_=True, default=False) assert config.nowplaying.control is False config.nowplaying.control = True assert config.nowplaying.control is True
def init_config(self, config: Config): """Call plugin.init_config function if possible :param config: app config instance. .. versionadded: 3.7.15 """ # Define a subconfig(namespace) for plugin so that plugin can # define its own configuration fields. config.deffield(self.name, type_=Config, default=Config(), desc=f'Configurations for plugin {self.name}') try: fn = self._module.init_config except AttributeError: # The plugin does not define any config field. pass else: fn(getattr(config, self.name))
def create_config(): config = Config() config.deffield('DEBUG', type_=bool, desc='是否为调试模式') config.deffield('VERBOSE', default=0, type_=int, desc='日志详细程度') config.deffield('MODE', default=0x0000, desc='CLI or GUI 模式') config.deffield('THEME', default='auto', desc='auto/light/dark') config.deffield('MPV_AUDIO_DEVICE', default='auto', desc='MPV 播放设备') config.deffield('COLLECTIONS_DIR', desc='本地收藏所在目录') config.deffield('FORCE_MAC_HOTKEY', desc='强制开启 macOS 全局快捷键功能', warn='Will be remove in version 3.0') config.deffield('LOG_TO_FILE', desc='将日志输出到文件中') config.deffield('AUDIO_SELECT_POLICY', default='hq<>') config.deffield('VIDEO_SELECT_POLICY', default='hd<>') config.deffield('ALLOW_LAN_CONNECT', type_=bool, default=False, desc='是否可以从局域网连接服务器') return config
def test_plugin_init_config(foo_plugin): config = Config() foo_plugin.init_config(config) # `config.foo` should be created and foo.VERBOSE should be equal to 0. assert config.foo.VERBOSE == 0
def create_config(): config = Config() config.deffield('DEBUG', type_=bool, desc='是否为调试模式') config.deffield('VERBOSE', default=0, type_=int, desc='日志详细程度') config.deffield('MODE', default=0x0000, desc='CLI or GUI 模式') config.deffield('THEME', default='auto', desc='auto/light/dark') config.deffield('MPV_AUDIO_DEVICE', default='auto', desc='MPV 播放设备') config.deffield('COLLECTIONS_DIR', desc='本地收藏所在目录') config.deffield('FORCE_MAC_HOTKEY', desc='强制开启 macOS 全局快捷键功能', warn='Will be remove in version 3.0') config.deffield('LOG_TO_FILE', desc='将日志输出到文件中') config.deffield('AUDIO_SELECT_POLICY', default='hq<>') config.deffield('VIDEO_SELECT_POLICY', default='hd<>') config.deffield('ALLOW_LAN_CONNECT', type_=bool, default=False, desc='是否可以从局域网连接服务器') config.deffield('PROVIDERS_STANDBY', type_=list, default=None, desc='') config.deffield('ENABLE_TRAY', type_=bool, default=True, desc='启用系统托盘') config.deffield('NOTIFY_ON_TRACK_CHANGED', type_=bool, default=False, desc='切换歌曲时显示桌面通知') config.deffield('NOTIFY_DURATION', type_=int, default=3000, desc='桌面通知保留时长(ms)') return config
def create_config(): from feeluown.config import Config config = Config() config.deffield('DEBUG', type_=bool, desc='是否为调试模式') config.deffield('MODE', default=0x0000, desc='CLI or GUI 模式') config.deffield('THEME', default='auto', desc='auto/light/dark') config.deffield('MPV_AUDIO_DEVICE', default='auto', desc='MPV 播放设备') config.deffield('COLLECTIONS_DIR', desc='本地收藏所在目录') config.deffield('FORCE_MAC_HOTKEY', desc='强制开启 macOS 全局快捷键功能') config.deffield('LOG_TO_FILE', desc='将日志输出到文件中') return config
def config(): c = Config() c.deffield('VERBOSE', type_=int, default=1) return c