class NodeConfigs(Configs): TYPE = "base" TITLE_NAME = "Node" link_collection = ConfigList( config_obj_default=ConfigDict(layout={ "url": ConfigString(gui_name="Url"), "name": ConfigString(optional=True, gui_name="Name"), }, gui_name="Link"), gui_name="Link Collection" ) meta_data = ConfigDummy() def __init__(self, node_config=None): super().__init__() if node_config is not None: for config_obj in node_config: setattr(self, config_obj.name, config_obj.get()) def get_name(self): raise NotImplementedError def get_folder_name(self): return None def get_note(self): return "" def get_icon_path(self): return TemplateNode.DEFAULT_ICON_PATH
from core.exceptions import LoginError from sites.moodle.parser import parse_main_page from .constants import AUTH_URL from settings.config_objs import ConfigList, ConfigDict, ConfigString, ConfigBool PASSWORD_MAPPER_CONFIG = ConfigList( gui_name="Password Mapper", hint_text= "If a polybox or zoom link requires a password,<br> you can map the password with the name of the link.<br>" "The name parameter will be interpreted as a " "<a href=\"https://docs.python.org/3/library/re.html\">regrex expression</a>", optional=True, config_obj_default=ConfigDict(gui_name="", layout={ "name": ConfigString(gui_name="Name", ), "password": ConfigString(gui_name="Password", ), })) MOODLE_ID_CONFIG = ConfigString(gui_name="ID") PROCESS_EXTERNAL_LINKS_CONFIG = ConfigBool(default=True, gui_name="Process External Links", optional=True) KEEP_SECTION_ORDER_CONFIG = ConfigBool(default=False, gui_name="Keep Section Order", optional=True) async def producer(
REGEX_PATTERN_CONFIG = ConfigList( gui_name="Regex Patterns", hint_text="This uses the <a href=\"https://docs.python.org/3/library/re.html#re.sub\">re.sub</a>" " function. The replacements<br>are 'Folder Name', 'File Name' and 'Link Modifier'", config_obj_default=ConfigDict( gui_name="Filter", layout={ "pattern": ConfigString( gui_name="Pattern" ), "folder": ConfigString( gui_name="Folder Name", optional=True, ), "file_name": ConfigString( gui_name="File Name", optional=True, hint_text="<name> will be replaced with the link name from the website.", ), "link_regex": ConfigString( gui_name="Link Modifier", optional=True, ), } ) ) URL_CONFIG = ConfigString(gui_name="Url")
class SiteConfigs(NodeConfigs): TYPE = "site" TITLE_NAME = "Site" raw_module_name = ConfigOptions(optional=False, options=get_module_names(), gui_name="Module") use_folder = ConfigBool(default=True, gui_name="Use Folder") raw_folder_name = ConfigString(optional=True, active_func=raw_folder_name_active, gui_name="Folder Name", gray_out=True) raw_function = FunctionConfigString(active_func=raw_function_active, gui_name="Function") raw_folder_function = FunctionFolderConfigString( active_func=folder_function_active, gui_name="Function for Folder") raw_login_function = FunctionLoginConfigString( optional=True, gui_name="Login Function", active_func=raw_login_function_active) consumer_kwargs = ConfigDict(layout={ "allowed_extensions": ConfigListString(optional=True, gui_name="Allowed Extensions", hint_text="Add 'video' for all video types"), "forbidden_extensions": ConfigListString(optional=True, gui_name="Forbidden Extensions", hint_text="Add 'video' for all video types"), }, gui_name="Download Arguments") function_kwargs = FunctionKwargsConfigDict( gui_name="Function Specific Arguments") def get_name(self): if self.raw_module_name is not None: return self.raw_module_name return "+ Add Site" def get_folder_name(self): if self.raw_module_name is None: return None if not self.use_folder: return "<No Folder>" if self.raw_folder_name: return self.raw_folder_name kwargs = nodes.Site.get_unique_key_kwargs(**self.to_dict()) return get_folder_name_from_kwargs(kwargs) def get_icon(self): image_files = os.listdir(SITE_ICON_PATH) file_name = None for image_file in image_files: if self.raw_module_name is not None and self.raw_module_name in image_file: file_name = image_file break if file_name is None: return super(SiteConfigs, self).get_icon() path = os.path.join(SITE_ICON_PATH, file_name) return QIcon(path)
from core.constants import BEAUTIFUL_SOUP_PARSER from core.utils import safe_path_join from settings.config_objs import ConfigList, ConfigDict, ConfigString, ConfigBool HEADERS_CONFIG = ConfigList( gui_name="Headers", hint_text="This is only useful if you want to add your own headers", optional=True, config_obj_default=ConfigDict(gui_name="", layout={ "key": ConfigString( gui_name="Key", optional=True, ), "value": ConfigString( gui_name="Value", optional=True, ), })) def headers_config_to_session_kwargs(headers_config) -> dict: headers = {d["key"]: d["value"] for d in headers_config} return dict(headers=headers) def _basic_auth_config_use_eth_credentials(instance, from_widget, parent): if from_widget: