def keywords(self) -> List[str]: if self.extension == '.mp3': return mysplit(self._comment, ' ') if self.extension == '.flac': if self._comment and not self._description: logger.warning(f'{self} : fixing flac keywords with mp3 comment') self._description = self._comment return mysplit(self._description, ' ') return []
def config_list(ctx: click.Context, param: click.Parameter, value: Any) -> Any: arg_value = value logger.info( f"{param.name} : try list loading with arg value : {arg_value}") config_value = Conf.config.configfile.get('musicbot', param.name, fallback=None) list_value = tuple(mysplit(config_value, ',')) if config_value is not None else [] logger.info( f"{param.name} : try list loading with config key : {list_value}") if arg_value: value = arg_value if list_value: if not value or value == param.default: value = list_value elif arg_value and arg_value != list_value: logger.warning( f"{param.name} : config list value {list_value} is not sync with arg value {arg_value}" ) if not value and param.required: raise click.BadParameter( f'missing list arg or config {param.name} in {Conf.config.config}', ctx, param, param.name) logger.info(f"{param.name} : list final value {value}") ctx.params[param.name] = value return value
def test_folder_find(cli_runner): musics = run_cli(cli_runner, cli, [ '--quiet', 'folder', 'find', *fixtures.folders, ]) assert len(mysplit(musics, "\n")) == 5
def config_list(ctx: click.Context, param: click.Parameter, value: Any) -> Any: value = sane_list(ctx, param, value) arg_value = value list_value = [] logger.info( f"{param.name} : try list loading with arg value : {arg_value}") if param.name: config_value = MusicbotObject.config.configfile.get('musicbot', param.name, fallback=None) if config_value: for v in mysplit(config_value, ','): try: list_value.append(param.type(v)) except Exception as e: # pylint: disable=broad-except logger.warning(e) logger.info( f"{param.name} : try list loading with config key : {list_value}") if arg_value: value = arg_value if list_value: if not value or value == param.default: value = list_value elif arg_value and arg_value != list_value: logger.warning( f"{param.name} : config list value {list_value} is not sync with arg value {arg_value}" ) if not value and param.required: raise click.BadParameter( f'missing list arg or config {param.name} in {MusicbotObject.config.config}', ctx, param, param.name) logger.info(f"{param.name} : list final value {value}") if param.name: ctx.params[param.name] = value return value