repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
django-fluent/django-fluent-dashboard
fluent_dashboard/dashboard.py
FluentIndexDashboard.get_personal_module
def get_personal_module(self): """ Instantiate the :class:`~fluent_dashboard.modules.PersonalModule` for use in the dashboard. """ return PersonalModule( layout='inline', draggable=False, deletable=False, collapsible=False, )
python
def get_personal_module(self): """ Instantiate the :class:`~fluent_dashboard.modules.PersonalModule` for use in the dashboard. """ return PersonalModule( layout='inline', draggable=False, deletable=False, collapsible=False, )
[ "def", "get_personal_module", "(", "self", ")", ":", "return", "PersonalModule", "(", "layout", "=", "'inline'", ",", "draggable", "=", "False", ",", "deletable", "=", "False", ",", "collapsible", "=", "False", ",", ")" ]
Instantiate the :class:`~fluent_dashboard.modules.PersonalModule` for use in the dashboard.
[ "Instantiate", "the", ":", "class", ":", "~fluent_dashboard", ".", "modules", ".", "PersonalModule", "for", "use", "in", "the", "dashboard", "." ]
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/dashboard.py#L69-L78
django-fluent/django-fluent-dashboard
fluent_dashboard/dashboard.py
FluentIndexDashboard.get_application_modules
def get_application_modules(self): """ Instantiate all application modules (i.e. :class:`~admin_tools.dashboard.modules.AppList`, :class:`~fluent_dashboard.modules.AppIconList` and :class:`~fluent_dashboard.modules.CmsAppIconList`) for use in the dashboard. ""...
python
def get_application_modules(self): """ Instantiate all application modules (i.e. :class:`~admin_tools.dashboard.modules.AppList`, :class:`~fluent_dashboard.modules.AppIconList` and :class:`~fluent_dashboard.modules.CmsAppIconList`) for use in the dashboard. ""...
[ "def", "get_application_modules", "(", "self", ")", ":", "modules", "=", "[", "]", "appgroups", "=", "get_application_groups", "(", ")", "for", "title", ",", "kwargs", "in", "appgroups", ":", "AppListClass", "=", "get_class", "(", "kwargs", ".", "pop", "(", ...
Instantiate all application modules (i.e. :class:`~admin_tools.dashboard.modules.AppList`, :class:`~fluent_dashboard.modules.AppIconList` and :class:`~fluent_dashboard.modules.CmsAppIconList`) for use in the dashboard.
[ "Instantiate", "all", "application", "modules", "(", "i", ".", "e", ".", ":", "class", ":", "~admin_tools", ".", "dashboard", ".", "modules", ".", "AppList", ":", "class", ":", "~fluent_dashboard", ".", "modules", ".", "AppIconList", "and", ":", "class", "...
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/dashboard.py#L80-L93
django-fluent/django-fluent-dashboard
fluent_dashboard/dashboard.py
FluentAppIndexDashboard.get_recent_actions_module
def get_recent_actions_module(self): """ Instantiate the :class:`~admin_tools.dashboard.modules.RecentActions` module for use in the appliation index page. """ return modules.RecentActions( _('Recent Actions'), include_list=self.get_app_content_types(), ...
python
def get_recent_actions_module(self): """ Instantiate the :class:`~admin_tools.dashboard.modules.RecentActions` module for use in the appliation index page. """ return modules.RecentActions( _('Recent Actions'), include_list=self.get_app_content_types(), ...
[ "def", "get_recent_actions_module", "(", "self", ")", ":", "return", "modules", ".", "RecentActions", "(", "_", "(", "'Recent Actions'", ")", ",", "include_list", "=", "self", ".", "get_app_content_types", "(", ")", ",", "limit", "=", "5", ",", "enabled", "=...
Instantiate the :class:`~admin_tools.dashboard.modules.RecentActions` module for use in the appliation index page.
[ "Instantiate", "the", ":", "class", ":", "~admin_tools", ".", "dashboard", ".", "modules", ".", "RecentActions", "module", "for", "use", "in", "the", "appliation", "index", "page", "." ]
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/dashboard.py#L153-L164
django-fluent/django-fluent-dashboard
fluent_dashboard/appgroups.py
get_application_groups
def get_application_groups(): """ Return the applications of the system, organized in various groups. These groups are not connected with the application names, but rather with a pattern of applications. """ groups = [] for title, groupdict in appsettings.FLUENT_DASHBOARD_APP_GROUPS: ...
python
def get_application_groups(): """ Return the applications of the system, organized in various groups. These groups are not connected with the application names, but rather with a pattern of applications. """ groups = [] for title, groupdict in appsettings.FLUENT_DASHBOARD_APP_GROUPS: ...
[ "def", "get_application_groups", "(", ")", ":", "groups", "=", "[", "]", "for", "title", ",", "groupdict", "in", "appsettings", ".", "FLUENT_DASHBOARD_APP_GROUPS", ":", "# Allow to pass all possible arguments to the DashboardModule class.", "module_kwargs", "=", "groupdict"...
Return the applications of the system, organized in various groups. These groups are not connected with the application names, but rather with a pattern of applications.
[ "Return", "the", "applications", "of", "the", "system", "organized", "in", "various", "groups", "." ]
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/appgroups.py#L27-L55
django-fluent/django-fluent-dashboard
fluent_dashboard/appgroups.py
sort_cms_models
def sort_cms_models(cms_models): """ Sort a set of CMS-related models in a custom (predefined) order. """ cms_models.sort(key=lambda model: ( get_cms_model_order(model['name']) if is_cms_app(model['app_name']) else 999, model['app_name'], model['title'] ))
python
def sort_cms_models(cms_models): """ Sort a set of CMS-related models in a custom (predefined) order. """ cms_models.sort(key=lambda model: ( get_cms_model_order(model['name']) if is_cms_app(model['app_name']) else 999, model['app_name'], model['title'] ))
[ "def", "sort_cms_models", "(", "cms_models", ")", ":", "cms_models", ".", "sort", "(", "key", "=", "lambda", "model", ":", "(", "get_cms_model_order", "(", "model", "[", "'name'", "]", ")", "if", "is_cms_app", "(", "model", "[", "'app_name'", "]", ")", "...
Sort a set of CMS-related models in a custom (predefined) order.
[ "Sort", "a", "set", "of", "CMS", "-", "related", "models", "in", "a", "custom", "(", "predefined", ")", "order", "." ]
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/appgroups.py#L58-L66
django-fluent/django-fluent-dashboard
fluent_dashboard/appgroups.py
is_cms_app
def is_cms_app(app_name): """ Return whether the given application is a CMS app """ for pat in appsettings.FLUENT_DASHBOARD_CMS_APP_NAMES: if fnmatch(app_name, pat): return True return False
python
def is_cms_app(app_name): """ Return whether the given application is a CMS app """ for pat in appsettings.FLUENT_DASHBOARD_CMS_APP_NAMES: if fnmatch(app_name, pat): return True return False
[ "def", "is_cms_app", "(", "app_name", ")", ":", "for", "pat", "in", "appsettings", ".", "FLUENT_DASHBOARD_CMS_APP_NAMES", ":", "if", "fnmatch", "(", "app_name", ",", "pat", ")", ":", "return", "True", "return", "False" ]
Return whether the given application is a CMS app
[ "Return", "whether", "the", "given", "application", "is", "a", "CMS", "app" ]
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/appgroups.py#L69-L77
django-fluent/django-fluent-dashboard
fluent_dashboard/appgroups.py
get_cms_model_order
def get_cms_model_order(model_name): """ Return a numeric ordering for a model name. """ for (name, order) in iteritems(appsettings.FLUENT_DASHBOARD_CMS_MODEL_ORDER): if name in model_name: return order return 999
python
def get_cms_model_order(model_name): """ Return a numeric ordering for a model name. """ for (name, order) in iteritems(appsettings.FLUENT_DASHBOARD_CMS_MODEL_ORDER): if name in model_name: return order return 999
[ "def", "get_cms_model_order", "(", "model_name", ")", ":", "for", "(", "name", ",", "order", ")", "in", "iteritems", "(", "appsettings", ".", "FLUENT_DASHBOARD_CMS_MODEL_ORDER", ")", ":", "if", "name", "in", "model_name", ":", "return", "order", "return", "999...
Return a numeric ordering for a model name.
[ "Return", "a", "numeric", "ordering", "for", "a", "model", "name", "." ]
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/appgroups.py#L80-L87
django-fluent/django-fluent-dashboard
fluent_dashboard/menu.py
FluentMenu.init_with_context
def init_with_context(self, context): """ Initialize the menu items. """ site_name = get_admin_site_name(context) self.children += [ items.MenuItem(_('Dashboard'), reverse('{0}:index'.format(site_name))), items.Bookmarks(), ] for title, k...
python
def init_with_context(self, context): """ Initialize the menu items. """ site_name = get_admin_site_name(context) self.children += [ items.MenuItem(_('Dashboard'), reverse('{0}:index'.format(site_name))), items.Bookmarks(), ] for title, k...
[ "def", "init_with_context", "(", "self", ",", "context", ")", ":", "site_name", "=", "get_admin_site_name", "(", "context", ")", "self", ".", "children", "+=", "[", "items", ".", "MenuItem", "(", "_", "(", "'Dashboard'", ")", ",", "reverse", "(", "'{0}:ind...
Initialize the menu items.
[ "Initialize", "the", "menu", "items", "." ]
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/menu.py#L31-L48
django-fluent/django-fluent-dashboard
fluent_dashboard/modules.py
PersonalModule.init_with_context
def init_with_context(self, context): """ Initializes the link list. """ super(PersonalModule, self).init_with_context(context) current_user = context['request'].user if django.VERSION < (1, 5): current_username = current_user.first_name or current_user.userna...
python
def init_with_context(self, context): """ Initializes the link list. """ super(PersonalModule, self).init_with_context(context) current_user = context['request'].user if django.VERSION < (1, 5): current_username = current_user.first_name or current_user.userna...
[ "def", "init_with_context", "(", "self", ",", "context", ")", ":", "super", "(", "PersonalModule", ",", "self", ")", ".", "init_with_context", "(", "context", ")", "current_user", "=", "context", "[", "'request'", "]", ".", "user", "if", "django", ".", "VE...
Initializes the link list.
[ "Initializes", "the", "link", "list", "." ]
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/modules.py#L61-L99
django-fluent/django-fluent-dashboard
fluent_dashboard/modules.py
AppIconList.init_with_context
def init_with_context(self, context): """ Initializes the icon list. """ super(AppIconList, self).init_with_context(context) apps = self.children # Standard model only has a title, change_url and add_url. # Restore the app_name and name, so icons can be matched. ...
python
def init_with_context(self, context): """ Initializes the icon list. """ super(AppIconList, self).init_with_context(context) apps = self.children # Standard model only has a title, change_url and add_url. # Restore the app_name and name, so icons can be matched. ...
[ "def", "init_with_context", "(", "self", ",", "context", ")", ":", "super", "(", "AppIconList", ",", "self", ")", ".", "init_with_context", "(", "context", ")", "apps", "=", "self", ".", "children", "# Standard model only has a title, change_url and add_url.", "# Re...
Initializes the icon list.
[ "Initializes", "the", "icon", "list", "." ]
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/modules.py#L126-L149
django-fluent/django-fluent-dashboard
fluent_dashboard/modules.py
AppIconList._get_model_name
def _get_model_name(self, modeldata): """ Extract the model name from the ``modeldata`` that *django-admin-tools* provides. """ if 'change_url' in modeldata: return modeldata['change_url'].strip('/').split('/')[-1] # /foo/admin/appname/modelname elif 'add_url' in mo...
python
def _get_model_name(self, modeldata): """ Extract the model name from the ``modeldata`` that *django-admin-tools* provides. """ if 'change_url' in modeldata: return modeldata['change_url'].strip('/').split('/')[-1] # /foo/admin/appname/modelname elif 'add_url' in mo...
[ "def", "_get_model_name", "(", "self", ",", "modeldata", ")", ":", "if", "'change_url'", "in", "modeldata", ":", "return", "modeldata", "[", "'change_url'", "]", ".", "strip", "(", "'/'", ")", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", "# /foo/...
Extract the model name from the ``modeldata`` that *django-admin-tools* provides.
[ "Extract", "the", "model", "name", "from", "the", "modeldata", "that", "*", "django", "-", "admin", "-", "tools", "*", "provides", "." ]
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/modules.py#L157-L166
django-fluent/django-fluent-dashboard
fluent_dashboard/modules.py
AppIconList.get_icon_for_model
def get_icon_for_model(self, app_name, model_name, default=None): """ Return the icon for the given model. It reads the :ref:`FLUENT_DASHBOARD_APP_ICONS` setting. """ key = "{0}/{1}".format(app_name, model_name) return appsettings.FLUENT_DASHBOARD_APP_ICONS.get(key, defau...
python
def get_icon_for_model(self, app_name, model_name, default=None): """ Return the icon for the given model. It reads the :ref:`FLUENT_DASHBOARD_APP_ICONS` setting. """ key = "{0}/{1}".format(app_name, model_name) return appsettings.FLUENT_DASHBOARD_APP_ICONS.get(key, defau...
[ "def", "get_icon_for_model", "(", "self", ",", "app_name", ",", "model_name", ",", "default", "=", "None", ")", ":", "key", "=", "\"{0}/{1}\"", ".", "format", "(", "app_name", ",", "model_name", ")", "return", "appsettings", ".", "FLUENT_DASHBOARD_APP_ICONS", ...
Return the icon for the given model. It reads the :ref:`FLUENT_DASHBOARD_APP_ICONS` setting.
[ "Return", "the", "icon", "for", "the", "given", "model", ".", "It", "reads", "the", ":", "ref", ":", "FLUENT_DASHBOARD_APP_ICONS", "setting", "." ]
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/modules.py#L168-L174
django-fluent/django-fluent-dashboard
fluent_dashboard/modules.py
AppIconList.get_icon_url
def get_icon_url(self, icon): """ Replaces the "icon name" with a full usable URL. * When the icon is an absolute URL, it is used as-is. * When the icon contains a slash, it is relative from the ``STATIC_URL``. * Otherwise, it's relative to the theme url folder. """ ...
python
def get_icon_url(self, icon): """ Replaces the "icon name" with a full usable URL. * When the icon is an absolute URL, it is used as-is. * When the icon contains a slash, it is relative from the ``STATIC_URL``. * Otherwise, it's relative to the theme url folder. """ ...
[ "def", "get_icon_url", "(", "self", ",", "icon", ")", ":", "if", "not", "icon", ".", "startswith", "(", "'/'", ")", "and", "not", "icon", ".", "startswith", "(", "'http://'", ")", "and", "not", "icon", ".", "startswith", "(", "'https://'", ")", ":", ...
Replaces the "icon name" with a full usable URL. * When the icon is an absolute URL, it is used as-is. * When the icon contains a slash, it is relative from the ``STATIC_URL``. * Otherwise, it's relative to the theme url folder.
[ "Replaces", "the", "icon", "name", "with", "a", "full", "usable", "URL", "." ]
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/modules.py#L176-L192
django-fluent/django-fluent-dashboard
fluent_dashboard/modules.py
CmsAppIconList.init_with_context
def init_with_context(self, context): """ Initializes the icon list. """ super(CmsAppIconList, self).init_with_context(context) apps = self.children cms_apps = [a for a in apps if is_cms_app(a['name'])] non_cms_apps = [a for a in apps if a not in cms_apps] ...
python
def init_with_context(self, context): """ Initializes the icon list. """ super(CmsAppIconList, self).init_with_context(context) apps = self.children cms_apps = [a for a in apps if is_cms_app(a['name'])] non_cms_apps = [a for a in apps if a not in cms_apps] ...
[ "def", "init_with_context", "(", "self", ",", "context", ")", ":", "super", "(", "CmsAppIconList", ",", "self", ")", ".", "init_with_context", "(", "context", ")", "apps", "=", "self", ".", "children", "cms_apps", "=", "[", "a", "for", "a", "in", "apps",...
Initializes the icon list.
[ "Initializes", "the", "icon", "list", "." ]
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/modules.py#L206-L226
django-fluent/django-fluent-dashboard
fluent_dashboard/modules.py
CacheStatusGroup.init_with_context
def init_with_context(self, context): """ Initializes the status list. """ super(CacheStatusGroup, self).init_with_context(context) if 'dashboardmods' in settings.INSTALLED_APPS: import dashboardmods memcache_mods = dashboardmods.get_memcache_dash_modules...
python
def init_with_context(self, context): """ Initializes the status list. """ super(CacheStatusGroup, self).init_with_context(context) if 'dashboardmods' in settings.INSTALLED_APPS: import dashboardmods memcache_mods = dashboardmods.get_memcache_dash_modules...
[ "def", "init_with_context", "(", "self", ",", "context", ")", ":", "super", "(", "CacheStatusGroup", ",", "self", ")", ".", "init_with_context", "(", "context", ")", "if", "'dashboardmods'", "in", "settings", ".", "INSTALLED_APPS", ":", "import", "dashboardmods"...
Initializes the status list.
[ "Initializes", "the", "status", "list", "." ]
train
https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/modules.py#L250-L270
facelessuser/soupsieve
setup.py
get_version
def get_version(): """Get version and version_info without importing the entire module.""" path = os.path.join(os.path.dirname(__file__), 'soupsieve') fp, pathname, desc = imp.find_module('__meta__', [path]) try: meta = imp.load_module('__meta__', fp, pathname, desc) return meta.__versi...
python
def get_version(): """Get version and version_info without importing the entire module.""" path = os.path.join(os.path.dirname(__file__), 'soupsieve') fp, pathname, desc = imp.find_module('__meta__', [path]) try: meta = imp.load_module('__meta__', fp, pathname, desc) return meta.__versi...
[ "def", "get_version", "(", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'soupsieve'", ")", "fp", ",", "pathname", ",", "desc", "=", "imp", ".", "find_module", "(", "'__me...
Get version and version_info without importing the entire module.
[ "Get", "version", "and", "version_info", "without", "importing", "the", "entire", "module", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/setup.py#L10-L19
facelessuser/soupsieve
setup.py
get_requirements
def get_requirements(): """Get the dependencies.""" with open("requirements/project.txt") as f: requirements = [] for line in f.readlines(): line = line.strip() if line and not line.startswith('#'): requirements.append(line) return requirements
python
def get_requirements(): """Get the dependencies.""" with open("requirements/project.txt") as f: requirements = [] for line in f.readlines(): line = line.strip() if line and not line.startswith('#'): requirements.append(line) return requirements
[ "def", "get_requirements", "(", ")", ":", "with", "open", "(", "\"requirements/project.txt\"", ")", "as", "f", ":", "requirements", "=", "[", "]", "for", "line", "in", "f", ".", "readlines", "(", ")", ":", "line", "=", "line", ".", "strip", "(", ")", ...
Get the dependencies.
[ "Get", "the", "dependencies", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/setup.py#L22-L31
facelessuser/soupsieve
soupsieve/css_parser.py
_cached_css_compile
def _cached_css_compile(pattern, namespaces, custom, flags): """Cached CSS compile.""" custom_selectors = process_custom(custom) return cm.SoupSieve( pattern, CSSParser(pattern, custom=custom_selectors, flags=flags).process_selectors(), namespaces, custom, flags ...
python
def _cached_css_compile(pattern, namespaces, custom, flags): """Cached CSS compile.""" custom_selectors = process_custom(custom) return cm.SoupSieve( pattern, CSSParser(pattern, custom=custom_selectors, flags=flags).process_selectors(), namespaces, custom, flags ...
[ "def", "_cached_css_compile", "(", "pattern", ",", "namespaces", ",", "custom", ",", "flags", ")", ":", "custom_selectors", "=", "process_custom", "(", "custom", ")", "return", "cm", ".", "SoupSieve", "(", "pattern", ",", "CSSParser", "(", "pattern", ",", "c...
Cached CSS compile.
[ "Cached", "CSS", "compile", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L208-L218
facelessuser/soupsieve
soupsieve/css_parser.py
process_custom
def process_custom(custom): """Process custom.""" custom_selectors = {} if custom is not None: for key, value in custom.items(): name = util.lower(key) if RE_CUSTOM.match(name) is None: raise SelectorSyntaxError("The name '{}' is not a valid custom pseudo-cla...
python
def process_custom(custom): """Process custom.""" custom_selectors = {} if custom is not None: for key, value in custom.items(): name = util.lower(key) if RE_CUSTOM.match(name) is None: raise SelectorSyntaxError("The name '{}' is not a valid custom pseudo-cla...
[ "def", "process_custom", "(", "custom", ")", ":", "custom_selectors", "=", "{", "}", "if", "custom", "is", "not", "None", ":", "for", "key", ",", "value", "in", "custom", ".", "items", "(", ")", ":", "name", "=", "util", ".", "lower", "(", "key", "...
Process custom.
[ "Process", "custom", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L227-L239
facelessuser/soupsieve
soupsieve/css_parser.py
css_unescape
def css_unescape(content, string=False): """ Unescape CSS value. Strings allow for spanning the value on multiple strings by escaping a new line. """ def replace(m): """Replace with the appropriate substitute.""" if m.group(1): codepoint = int(m.group(1)[1:], 16) ...
python
def css_unescape(content, string=False): """ Unescape CSS value. Strings allow for spanning the value on multiple strings by escaping a new line. """ def replace(m): """Replace with the appropriate substitute.""" if m.group(1): codepoint = int(m.group(1)[1:], 16) ...
[ "def", "css_unescape", "(", "content", ",", "string", "=", "False", ")", ":", "def", "replace", "(", "m", ")", ":", "\"\"\"Replace with the appropriate substitute.\"\"\"", "if", "m", ".", "group", "(", "1", ")", ":", "codepoint", "=", "int", "(", "m", ".",...
Unescape CSS value. Strings allow for spanning the value on multiple strings by escaping a new line.
[ "Unescape", "CSS", "value", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L242-L266
facelessuser/soupsieve
soupsieve/css_parser.py
escape
def escape(ident): """Escape identifier.""" string = [] length = len(ident) start_dash = length > 0 and ident[0] == '-' if length == 1 and start_dash: # Need to escape identifier that is a single `-` with no other characters string.append('\\{}'.format(ident)) else: for ...
python
def escape(ident): """Escape identifier.""" string = [] length = len(ident) start_dash = length > 0 and ident[0] == '-' if length == 1 and start_dash: # Need to escape identifier that is a single `-` with no other characters string.append('\\{}'.format(ident)) else: for ...
[ "def", "escape", "(", "ident", ")", ":", "string", "=", "[", "]", "length", "=", "len", "(", "ident", ")", "start_dash", "=", "length", ">", "0", "and", "ident", "[", "0", "]", "==", "'-'", "if", "length", "==", "1", "and", "start_dash", ":", "# ...
Escape identifier.
[ "Escape", "identifier", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L269-L294
facelessuser/soupsieve
soupsieve/css_parser.py
SpecialPseudoPattern.match
def match(self, selector, index): """Match the selector.""" pseudo = None m = self.re_pseudo_name.match(selector, index) if m: name = util.lower(css_unescape(m.group('name'))) pattern = self.patterns.get(name) if pattern: pseudo = patt...
python
def match(self, selector, index): """Match the selector.""" pseudo = None m = self.re_pseudo_name.match(selector, index) if m: name = util.lower(css_unescape(m.group('name'))) pattern = self.patterns.get(name) if pattern: pseudo = patt...
[ "def", "match", "(", "self", ",", "selector", ",", "index", ")", ":", "pseudo", "=", "None", "m", "=", "self", ".", "re_pseudo_name", ".", "match", "(", "selector", ",", "index", ")", "if", "m", ":", "name", "=", "util", ".", "lower", "(", "css_une...
Match the selector.
[ "Match", "the", "selector", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L348-L361
facelessuser/soupsieve
soupsieve/css_parser.py
_Selector._freeze_relations
def _freeze_relations(self, relations): """Freeze relation.""" if relations: sel = relations[0] sel.relations.extend(relations[1:]) return ct.SelectorList([sel.freeze()]) else: return ct.SelectorList()
python
def _freeze_relations(self, relations): """Freeze relation.""" if relations: sel = relations[0] sel.relations.extend(relations[1:]) return ct.SelectorList([sel.freeze()]) else: return ct.SelectorList()
[ "def", "_freeze_relations", "(", "self", ",", "relations", ")", ":", "if", "relations", ":", "sel", "=", "relations", "[", "0", "]", "sel", ".", "relations", ".", "extend", "(", "relations", "[", "1", ":", "]", ")", "return", "ct", ".", "SelectorList",...
Freeze relation.
[ "Freeze", "relation", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L398-L406
facelessuser/soupsieve
soupsieve/css_parser.py
_Selector.freeze
def freeze(self): """Freeze self.""" if self.no_match: return ct.SelectorNull() else: return ct.Selector( self.tag, tuple(self.ids), tuple(self.classes), tuple(self.attributes), tuple(self.nt...
python
def freeze(self): """Freeze self.""" if self.no_match: return ct.SelectorNull() else: return ct.Selector( self.tag, tuple(self.ids), tuple(self.classes), tuple(self.attributes), tuple(self.nt...
[ "def", "freeze", "(", "self", ")", ":", "if", "self", ".", "no_match", ":", "return", "ct", ".", "SelectorNull", "(", ")", "else", ":", "return", "ct", ".", "Selector", "(", "self", ".", "tag", ",", "tuple", "(", "self", ".", "ids", ")", ",", "tu...
Freeze self.
[ "Freeze", "self", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L408-L426
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.parse_attribute_selector
def parse_attribute_selector(self, sel, m, has_selector, quirks): """Create attribute selector from the returned regex match.""" inverse = False op = m.group('cmp') case = util.lower(m.group('case')) if m.group('case') else None parts = [css_unescape(a) for a in m.group('ns_attr...
python
def parse_attribute_selector(self, sel, m, has_selector, quirks): """Create attribute selector from the returned regex match.""" inverse = False op = m.group('cmp') case = util.lower(m.group('case')) if m.group('case') else None parts = [css_unescape(a) for a in m.group('ns_attr...
[ "def", "parse_attribute_selector", "(", "self", ",", "sel", ",", "m", ",", "has_selector", ",", "quirks", ")", ":", "inverse", "=", "False", "op", "=", "m", ".", "group", "(", "'cmp'", ")", "case", "=", "util", ".", "lower", "(", "m", ".", "group", ...
Create attribute selector from the returned regex match.
[ "Create", "attribute", "selector", "from", "the", "returned", "regex", "match", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L477-L550
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.parse_tag_pattern
def parse_tag_pattern(self, sel, m, has_selector): """Parse tag pattern from regex match.""" parts = [css_unescape(x) for x in m.group(0).split('|')] if len(parts) > 1: prefix = parts[0] tag = parts[1] else: tag = parts[0] prefix = None ...
python
def parse_tag_pattern(self, sel, m, has_selector): """Parse tag pattern from regex match.""" parts = [css_unescape(x) for x in m.group(0).split('|')] if len(parts) > 1: prefix = parts[0] tag = parts[1] else: tag = parts[0] prefix = None ...
[ "def", "parse_tag_pattern", "(", "self", ",", "sel", ",", "m", ",", "has_selector", ")", ":", "parts", "=", "[", "css_unescape", "(", "x", ")", "for", "x", "in", "m", ".", "group", "(", "0", ")", ".", "split", "(", "'|'", ")", "]", "if", "len", ...
Parse tag pattern from regex match.
[ "Parse", "tag", "pattern", "from", "regex", "match", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L552-L564
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.parse_pseudo_class_custom
def parse_pseudo_class_custom(self, sel, m, has_selector): """ Parse custom pseudo class alias. Compile custom selectors as we need them. When compiling a custom selector, set it to `None` in the dictionary so we can avoid an infinite loop. """ pseudo = util.lower(css_u...
python
def parse_pseudo_class_custom(self, sel, m, has_selector): """ Parse custom pseudo class alias. Compile custom selectors as we need them. When compiling a custom selector, set it to `None` in the dictionary so we can avoid an infinite loop. """ pseudo = util.lower(css_u...
[ "def", "parse_pseudo_class_custom", "(", "self", ",", "sel", ",", "m", ",", "has_selector", ")", ":", "pseudo", "=", "util", ".", "lower", "(", "css_unescape", "(", "m", ".", "group", "(", "'name'", ")", ")", ")", "selector", "=", "self", ".", "custom"...
Parse custom pseudo class alias. Compile custom selectors as we need them. When compiling a custom selector, set it to `None` in the dictionary so we can avoid an infinite loop.
[ "Parse", "custom", "pseudo", "class", "alias", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L566-L592
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.parse_pseudo_class
def parse_pseudo_class(self, sel, m, has_selector, iselector, is_html): """Parse pseudo class.""" complex_pseudo = False pseudo = util.lower(css_unescape(m.group('name'))) if m.group('open'): complex_pseudo = True if complex_pseudo and pseudo in PSEUDO_COMPLEX: ...
python
def parse_pseudo_class(self, sel, m, has_selector, iselector, is_html): """Parse pseudo class.""" complex_pseudo = False pseudo = util.lower(css_unescape(m.group('name'))) if m.group('open'): complex_pseudo = True if complex_pseudo and pseudo in PSEUDO_COMPLEX: ...
[ "def", "parse_pseudo_class", "(", "self", ",", "sel", ",", "m", ",", "has_selector", ",", "iselector", ",", "is_html", ")", ":", "complex_pseudo", "=", "False", "pseudo", "=", "util", ".", "lower", "(", "css_unescape", "(", "m", ".", "group", "(", "'name...
Parse pseudo class.
[ "Parse", "pseudo", "class", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L594-L680
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.parse_pseudo_nth
def parse_pseudo_nth(self, sel, m, has_selector, iselector): """Parse `nth` pseudo.""" mdict = m.groupdict() if mdict.get('pseudo_nth_child'): postfix = '_child' else: postfix = '_type' mdict['name'] = util.lower(css_unescape(mdict['name'])) conte...
python
def parse_pseudo_nth(self, sel, m, has_selector, iselector): """Parse `nth` pseudo.""" mdict = m.groupdict() if mdict.get('pseudo_nth_child'): postfix = '_child' else: postfix = '_type' mdict['name'] = util.lower(css_unescape(mdict['name'])) conte...
[ "def", "parse_pseudo_nth", "(", "self", ",", "sel", ",", "m", ",", "has_selector", ",", "iselector", ")", ":", "mdict", "=", "m", ".", "groupdict", "(", ")", "if", "mdict", ".", "get", "(", "'pseudo_nth_child'", ")", ":", "postfix", "=", "'_child'", "e...
Parse `nth` pseudo.
[ "Parse", "nth", "pseudo", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L682-L739
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.parse_pseudo_open
def parse_pseudo_open(self, sel, name, has_selector, iselector, index): """Parse pseudo with opening bracket.""" flags = FLG_PSEUDO | FLG_OPEN if name == ':not': flags |= FLG_NOT if name == ':has': flags |= FLG_RELATIVE sel.selectors.append(self.parse_se...
python
def parse_pseudo_open(self, sel, name, has_selector, iselector, index): """Parse pseudo with opening bracket.""" flags = FLG_PSEUDO | FLG_OPEN if name == ':not': flags |= FLG_NOT if name == ':has': flags |= FLG_RELATIVE sel.selectors.append(self.parse_se...
[ "def", "parse_pseudo_open", "(", "self", ",", "sel", ",", "name", ",", "has_selector", ",", "iselector", ",", "index", ")", ":", "flags", "=", "FLG_PSEUDO", "|", "FLG_OPEN", "if", "name", "==", "':not'", ":", "flags", "|=", "FLG_NOT", "if", "name", "==",...
Parse pseudo with opening bracket.
[ "Parse", "pseudo", "with", "opening", "bracket", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L741-L752
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.parse_has_combinator
def parse_has_combinator(self, sel, m, has_selector, selectors, rel_type, index): """Parse combinator tokens.""" combinator = m.group('relation').strip() if not combinator: combinator = WS_COMBINATOR if combinator == COMMA_COMBINATOR: if not has_selector: ...
python
def parse_has_combinator(self, sel, m, has_selector, selectors, rel_type, index): """Parse combinator tokens.""" combinator = m.group('relation').strip() if not combinator: combinator = WS_COMBINATOR if combinator == COMMA_COMBINATOR: if not has_selector: ...
[ "def", "parse_has_combinator", "(", "self", ",", "sel", ",", "m", ",", "has_selector", ",", "selectors", ",", "rel_type", ",", "index", ")", ":", "combinator", "=", "m", ".", "group", "(", "'relation'", ")", ".", "strip", "(", ")", "if", "not", "combin...
Parse combinator tokens.
[ "Parse", "combinator", "tokens", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L754-L794
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.parse_combinator
def parse_combinator(self, sel, m, has_selector, selectors, relations, is_pseudo, index): """Parse combinator tokens.""" combinator = m.group('relation').strip() if not combinator: combinator = WS_COMBINATOR if not has_selector: # The only way we don't fail is if...
python
def parse_combinator(self, sel, m, has_selector, selectors, relations, is_pseudo, index): """Parse combinator tokens.""" combinator = m.group('relation').strip() if not combinator: combinator = WS_COMBINATOR if not has_selector: # The only way we don't fail is if...
[ "def", "parse_combinator", "(", "self", ",", "sel", ",", "m", ",", "has_selector", ",", "selectors", ",", "relations", ",", "is_pseudo", ",", "index", ")", ":", "combinator", "=", "m", ".", "group", "(", "'relation'", ")", ".", "strip", "(", ")", "if",...
Parse combinator tokens.
[ "Parse", "combinator", "tokens", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L796-L834
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.parse_class_id
def parse_class_id(self, sel, m, has_selector): """Parse HTML classes and ids.""" selector = m.group(0) if selector.startswith('.'): sel.classes.append(css_unescape(selector[1:])) else: sel.ids.append(css_unescape(selector[1:])) has_selector = True ...
python
def parse_class_id(self, sel, m, has_selector): """Parse HTML classes and ids.""" selector = m.group(0) if selector.startswith('.'): sel.classes.append(css_unescape(selector[1:])) else: sel.ids.append(css_unescape(selector[1:])) has_selector = True ...
[ "def", "parse_class_id", "(", "self", ",", "sel", ",", "m", ",", "has_selector", ")", ":", "selector", "=", "m", ".", "group", "(", "0", ")", "if", "selector", ".", "startswith", "(", "'.'", ")", ":", "sel", ".", "classes", ".", "append", "(", "css...
Parse HTML classes and ids.
[ "Parse", "HTML", "classes", "and", "ids", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L836-L845
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.parse_pseudo_contains
def parse_pseudo_contains(self, sel, m, has_selector): """Parse contains.""" values = m.group('values') patterns = [] for token in RE_VALUES.finditer(values): if token.group('split'): continue value = token.group('value') if value.star...
python
def parse_pseudo_contains(self, sel, m, has_selector): """Parse contains.""" values = m.group('values') patterns = [] for token in RE_VALUES.finditer(values): if token.group('split'): continue value = token.group('value') if value.star...
[ "def", "parse_pseudo_contains", "(", "self", ",", "sel", ",", "m", ",", "has_selector", ")", ":", "values", "=", "m", ".", "group", "(", "'values'", ")", "patterns", "=", "[", "]", "for", "token", "in", "RE_VALUES", ".", "finditer", "(", "values", ")",...
Parse contains.
[ "Parse", "contains", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L847-L863
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.parse_pseudo_lang
def parse_pseudo_lang(self, sel, m, has_selector): """Parse pseudo language.""" values = m.group('values') patterns = [] for token in RE_VALUES.finditer(values): if token.group('split'): continue value = token.group('value') if value.s...
python
def parse_pseudo_lang(self, sel, m, has_selector): """Parse pseudo language.""" values = m.group('values') patterns = [] for token in RE_VALUES.finditer(values): if token.group('split'): continue value = token.group('value') if value.s...
[ "def", "parse_pseudo_lang", "(", "self", ",", "sel", ",", "m", ",", "has_selector", ")", ":", "values", "=", "m", ".", "group", "(", "'values'", ")", "patterns", "=", "[", "]", "for", "token", "in", "RE_VALUES", ".", "finditer", "(", "values", ")", "...
Parse pseudo language.
[ "Parse", "pseudo", "language", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L865-L892
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.parse_pseudo_dir
def parse_pseudo_dir(self, sel, m, has_selector): """Parse pseudo direction.""" value = ct.SEL_DIR_LTR if util.lower(m.group('dir')) == 'ltr' else ct.SEL_DIR_RTL sel.flags |= value has_selector = True return has_selector
python
def parse_pseudo_dir(self, sel, m, has_selector): """Parse pseudo direction.""" value = ct.SEL_DIR_LTR if util.lower(m.group('dir')) == 'ltr' else ct.SEL_DIR_RTL sel.flags |= value has_selector = True return has_selector
[ "def", "parse_pseudo_dir", "(", "self", ",", "sel", ",", "m", ",", "has_selector", ")", ":", "value", "=", "ct", ".", "SEL_DIR_LTR", "if", "util", ".", "lower", "(", "m", ".", "group", "(", "'dir'", ")", ")", "==", "'ltr'", "else", "ct", ".", "SEL_...
Parse pseudo direction.
[ "Parse", "pseudo", "direction", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L894-L900
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.parse_selectors
def parse_selectors(self, iselector, index=0, flags=0): """Parse selectors.""" sel = _Selector() selectors = [] has_selector = False closed = False relations = [] rel_type = ":" + WS_COMBINATOR is_open = bool(flags & FLG_OPEN) is_pseudo = bool(fla...
python
def parse_selectors(self, iselector, index=0, flags=0): """Parse selectors.""" sel = _Selector() selectors = [] has_selector = False closed = False relations = [] rel_type = ":" + WS_COMBINATOR is_open = bool(flags & FLG_OPEN) is_pseudo = bool(fla...
[ "def", "parse_selectors", "(", "self", ",", "iselector", ",", "index", "=", "0", ",", "flags", "=", "0", ")", ":", "sel", "=", "_Selector", "(", ")", "selectors", "=", "[", "]", "has_selector", "=", "False", "closed", "=", "False", "relations", "=", ...
Parse selectors.
[ "Parse", "selectors", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L902-L1057
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.selector_iter
def selector_iter(self, pattern): """Iterate selector tokens.""" # Ignore whitespace and comments at start and end of pattern m = RE_WS_BEGIN.search(pattern) index = m.end(0) if m else 0 m = RE_WS_END.search(pattern) end = (m.start(0) - 1) if m else (len(pattern) - 1) ...
python
def selector_iter(self, pattern): """Iterate selector tokens.""" # Ignore whitespace and comments at start and end of pattern m = RE_WS_BEGIN.search(pattern) index = m.end(0) if m else 0 m = RE_WS_END.search(pattern) end = (m.start(0) - 1) if m else (len(pattern) - 1) ...
[ "def", "selector_iter", "(", "self", ",", "pattern", ")", ":", "# Ignore whitespace and comments at start and end of pattern", "m", "=", "RE_WS_BEGIN", ".", "search", "(", "pattern", ")", "index", "=", "m", ".", "end", "(", "0", ")", "if", "m", "else", "0", ...
Iterate selector tokens.
[ "Iterate", "selector", "tokens", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L1059-L1102
facelessuser/soupsieve
soupsieve/css_parser.py
CSSParser.process_selectors
def process_selectors(self, index=0, flags=0): """ Process selectors. We do our own selectors as BeautifulSoup4 has some annoying quirks, and we don't really need to do nth selectors or siblings or descendants etc. """ return self.parse_selectors(self.selector_i...
python
def process_selectors(self, index=0, flags=0): """ Process selectors. We do our own selectors as BeautifulSoup4 has some annoying quirks, and we don't really need to do nth selectors or siblings or descendants etc. """ return self.parse_selectors(self.selector_i...
[ "def", "process_selectors", "(", "self", ",", "index", "=", "0", ",", "flags", "=", "0", ")", ":", "return", "self", ".", "parse_selectors", "(", "self", ".", "selector_iter", "(", "self", ".", "pattern", ")", ",", "index", ",", "flags", ")" ]
Process selectors. We do our own selectors as BeautifulSoup4 has some annoying quirks, and we don't really need to do nth selectors or siblings or descendants etc.
[ "Process", "selectors", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_parser.py#L1104-L1113
facelessuser/soupsieve
tools/gh_labels.py
find_label
def find_label(label, label_color, label_description): """Find label.""" edit = None for name, values in label_list.items(): color, description = values if isinstance(name, tuple): old_name = name[0] new_name = name[1] else: old_name = name ...
python
def find_label(label, label_color, label_description): """Find label.""" edit = None for name, values in label_list.items(): color, description = values if isinstance(name, tuple): old_name = name[0] new_name = name[1] else: old_name = name ...
[ "def", "find_label", "(", "label", ",", "label_color", ",", "label_description", ")", ":", "edit", "=", "None", "for", "name", ",", "values", "in", "label_list", ".", "items", "(", ")", ":", "color", ",", "description", "=", "values", "if", "isinstance", ...
Find label.
[ "Find", "label", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/tools/gh_labels.py#L75-L89
facelessuser/soupsieve
tools/gh_labels.py
update_labels
def update_labels(repo): """Update labels.""" updated = set() for label in repo.get_labels(): edit = find_label(label.name, label.color, label.description) if edit is not None: print(' Updating {}: #{} "{}"'.format(edit.new, edit.color, edit.description)) label.edi...
python
def update_labels(repo): """Update labels.""" updated = set() for label in repo.get_labels(): edit = find_label(label.name, label.color, label.description) if edit is not None: print(' Updating {}: #{} "{}"'.format(edit.new, edit.color, edit.description)) label.edi...
[ "def", "update_labels", "(", "repo", ")", ":", "updated", "=", "set", "(", ")", "for", "label", "in", "repo", ".", "get_labels", "(", ")", ":", "edit", "=", "find_label", "(", "label", ".", "name", ",", "label", ".", "color", ",", "label", ".", "de...
Update labels.
[ "Update", "labels", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/tools/gh_labels.py#L92-L117
facelessuser/soupsieve
tools/gh_labels.py
get_auth
def get_auth(): """Get authentication.""" import getpass user = input("User Name: ") # noqa pswd = getpass.getpass('Password: ') return Github(user, pswd)
python
def get_auth(): """Get authentication.""" import getpass user = input("User Name: ") # noqa pswd = getpass.getpass('Password: ') return Github(user, pswd)
[ "def", "get_auth", "(", ")", ":", "import", "getpass", "user", "=", "input", "(", "\"User Name: \"", ")", "# noqa", "pswd", "=", "getpass", ".", "getpass", "(", "'Password: '", ")", "return", "Github", "(", "user", ",", "pswd", ")" ]
Get authentication.
[ "Get", "authentication", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/tools/gh_labels.py#L121-L126
facelessuser/soupsieve
tools/gh_labels.py
main
def main(): """Main.""" if len(sys.argv) > 1 and os.path.exists(sys.argv[1]): try: with open(sys.argv[1], 'r') as f: user_name, password = f.read().strip().split(':') git = Github(user_name, password) password = None except Exception: ...
python
def main(): """Main.""" if len(sys.argv) > 1 and os.path.exists(sys.argv[1]): try: with open(sys.argv[1], 'r') as f: user_name, password = f.read().strip().split(':') git = Github(user_name, password) password = None except Exception: ...
[ "def", "main", "(", ")", ":", "if", "len", "(", "sys", ".", "argv", ")", ">", "1", "and", "os", ".", "path", ".", "exists", "(", "sys", ".", "argv", "[", "1", "]", ")", ":", "try", ":", "with", "open", "(", "sys", ".", "argv", "[", "1", "...
Main.
[ "Main", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/tools/gh_labels.py#L129-L151
facelessuser/soupsieve
soupsieve/__meta__.py
parse_version
def parse_version(ver, pre=False): """Parse version into a comparable Version tuple.""" m = RE_VER.match(ver) # Handle major, minor, micro major = int(m.group('major')) minor = int(m.group('minor')) if m.group('minor') else 0 micro = int(m.group('micro')) if m.group('micro') else 0 # Hand...
python
def parse_version(ver, pre=False): """Parse version into a comparable Version tuple.""" m = RE_VER.match(ver) # Handle major, minor, micro major = int(m.group('major')) minor = int(m.group('minor')) if m.group('minor') else 0 micro = int(m.group('micro')) if m.group('micro') else 0 # Hand...
[ "def", "parse_version", "(", "ver", ",", "pre", "=", "False", ")", ":", "m", "=", "RE_VER", ".", "match", "(", "ver", ")", "# Handle major, minor, micro", "major", "=", "int", "(", "m", ".", "group", "(", "'major'", ")", ")", "minor", "=", "int", "("...
Parse version into a comparable Version tuple.
[ "Parse", "version", "into", "a", "comparable", "Version", "tuple", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/__meta__.py#L157-L186
facelessuser/soupsieve
soupsieve/__meta__.py
Version._get_canonical
def _get_canonical(self): """Get the canonical output string.""" # Assemble major, minor, micro version and append `pre`, `post`, or `dev` if needed.. if self.micro == 0: ver = "{}.{}".format(self.major, self.minor) else: ver = "{}.{}.{}".format(self.major, self....
python
def _get_canonical(self): """Get the canonical output string.""" # Assemble major, minor, micro version and append `pre`, `post`, or `dev` if needed.. if self.micro == 0: ver = "{}.{}".format(self.major, self.minor) else: ver = "{}.{}.{}".format(self.major, self....
[ "def", "_get_canonical", "(", "self", ")", ":", "# Assemble major, minor, micro version and append `pre`, `post`, or `dev` if needed..", "if", "self", ".", "micro", "==", "0", ":", "ver", "=", "\"{}.{}\"", ".", "format", "(", "self", ".", "major", ",", "self", ".", ...
Get the canonical output string.
[ "Get", "the", "canonical", "output", "string", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/__meta__.py#L139-L154
facelessuser/soupsieve
soupsieve/css_match.py
Document.assert_valid_input
def assert_valid_input(cls, tag): """Check if valid input tag or document.""" # Fail on unexpected types. if not cls.is_tag(tag): raise TypeError("Expected a BeautifulSoup 'Tag', but instead recieved type {}".format(type(tag)))
python
def assert_valid_input(cls, tag): """Check if valid input tag or document.""" # Fail on unexpected types. if not cls.is_tag(tag): raise TypeError("Expected a BeautifulSoup 'Tag', but instead recieved type {}".format(type(tag)))
[ "def", "assert_valid_input", "(", "cls", ",", "tag", ")", ":", "# Fail on unexpected types.", "if", "not", "cls", ".", "is_tag", "(", "tag", ")", ":", "raise", "TypeError", "(", "\"Expected a BeautifulSoup 'Tag', but instead recieved type {}\"", ".", "format", "(", ...
Check if valid input tag or document.
[ "Check", "if", "valid", "input", "tag", "or", "document", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L80-L85
facelessuser/soupsieve
soupsieve/css_match.py
Document.is_special_string
def is_special_string(obj): """Is special string.""" import bs4 return isinstance(obj, (bs4.Comment, bs4.Declaration, bs4.CData, bs4.ProcessingInstruction))
python
def is_special_string(obj): """Is special string.""" import bs4 return isinstance(obj, (bs4.Comment, bs4.Declaration, bs4.CData, bs4.ProcessingInstruction))
[ "def", "is_special_string", "(", "obj", ")", ":", "import", "bs4", "return", "isinstance", "(", "obj", ",", "(", "bs4", ".", "Comment", ",", "bs4", ".", "Declaration", ",", "bs4", ".", "CData", ",", "bs4", ".", "ProcessingInstruction", ")", ")" ]
Is special string.
[ "Is", "special", "string", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L137-L141
facelessuser/soupsieve
soupsieve/css_match.py
Document.is_iframe
def is_iframe(self, el): """Check if element is an `iframe`.""" return ((el.name if self.is_xml_tree(el) else util.lower(el.name)) == 'iframe') and self.is_html_tag(el)
python
def is_iframe(self, el): """Check if element is an `iframe`.""" return ((el.name if self.is_xml_tree(el) else util.lower(el.name)) == 'iframe') and self.is_html_tag(el)
[ "def", "is_iframe", "(", "self", ",", "el", ")", ":", "return", "(", "(", "el", ".", "name", "if", "self", ".", "is_xml_tree", "(", "el", ")", "else", "util", ".", "lower", "(", "el", ".", "name", ")", ")", "==", "'iframe'", ")", "and", "self", ...
Check if element is an `iframe`.
[ "Check", "if", "element", "is", "an", "iframe", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L161-L164
facelessuser/soupsieve
soupsieve/css_match.py
Document.is_root
def is_root(self, el): """ Return whether element is a root element. We check that the element is the root of the tree (which we have already pre-calculated), and we check if it is the root element under an `iframe`. """ root = self.root and self.root is el if n...
python
def is_root(self, el): """ Return whether element is a root element. We check that the element is the root of the tree (which we have already pre-calculated), and we check if it is the root element under an `iframe`. """ root = self.root and self.root is el if n...
[ "def", "is_root", "(", "self", ",", "el", ")", ":", "root", "=", "self", ".", "root", "and", "self", ".", "root", "is", "el", "if", "not", "root", ":", "parent", "=", "self", ".", "get_parent", "(", "el", ")", "root", "=", "parent", "is", "not", ...
Return whether element is a root element. We check that the element is the root of the tree (which we have already pre-calculated), and we check if it is the root element under an `iframe`.
[ "Return", "whether", "element", "is", "a", "root", "element", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L166-L178
facelessuser/soupsieve
soupsieve/css_match.py
Document.get_contents
def get_contents(self, el, no_iframe=False): """Get contents or contents in reverse.""" if not no_iframe or not self.is_iframe(el): for content in el.contents: yield content
python
def get_contents(self, el, no_iframe=False): """Get contents or contents in reverse.""" if not no_iframe or not self.is_iframe(el): for content in el.contents: yield content
[ "def", "get_contents", "(", "self", ",", "el", ",", "no_iframe", "=", "False", ")", ":", "if", "not", "no_iframe", "or", "not", "self", ".", "is_iframe", "(", "el", ")", ":", "for", "content", "in", "el", ".", "contents", ":", "yield", "content" ]
Get contents or contents in reverse.
[ "Get", "contents", "or", "contents", "in", "reverse", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L180-L184
facelessuser/soupsieve
soupsieve/css_match.py
Document.get_children
def get_children(self, el, start=None, reverse=False, tags=True, no_iframe=False): """Get children.""" if not no_iframe or not self.is_iframe(el): last = len(el.contents) - 1 if start is None: index = last if reverse else 0 else: index...
python
def get_children(self, el, start=None, reverse=False, tags=True, no_iframe=False): """Get children.""" if not no_iframe or not self.is_iframe(el): last = len(el.contents) - 1 if start is None: index = last if reverse else 0 else: index...
[ "def", "get_children", "(", "self", ",", "el", ",", "start", "=", "None", ",", "reverse", "=", "False", ",", "tags", "=", "True", ",", "no_iframe", "=", "False", ")", ":", "if", "not", "no_iframe", "or", "not", "self", ".", "is_iframe", "(", "el", ...
Get children.
[ "Get", "children", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L186-L203
facelessuser/soupsieve
soupsieve/css_match.py
Document.get_descendants
def get_descendants(self, el, tags=True, no_iframe=False): """Get descendants.""" if not no_iframe or not self.is_iframe(el): next_good = None for child in el.descendants: if next_good is not None: if child is not next_good: ...
python
def get_descendants(self, el, tags=True, no_iframe=False): """Get descendants.""" if not no_iframe or not self.is_iframe(el): next_good = None for child in el.descendants: if next_good is not None: if child is not next_good: ...
[ "def", "get_descendants", "(", "self", ",", "el", ",", "tags", "=", "True", ",", "no_iframe", "=", "False", ")", ":", "if", "not", "no_iframe", "or", "not", "self", ".", "is_iframe", "(", "el", ")", ":", "next_good", "=", "None", "for", "child", "in"...
Get descendants.
[ "Get", "descendants", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L205-L234
facelessuser/soupsieve
soupsieve/css_match.py
Document.get_parent
def get_parent(self, el, no_iframe=False): """Get parent.""" parent = el.parent if no_iframe and parent is not None and self.is_iframe(parent): parent = None return parent
python
def get_parent(self, el, no_iframe=False): """Get parent.""" parent = el.parent if no_iframe and parent is not None and self.is_iframe(parent): parent = None return parent
[ "def", "get_parent", "(", "self", ",", "el", ",", "no_iframe", "=", "False", ")", ":", "parent", "=", "el", ".", "parent", "if", "no_iframe", "and", "parent", "is", "not", "None", "and", "self", ".", "is_iframe", "(", "parent", ")", ":", "parent", "=...
Get parent.
[ "Get", "parent", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L236-L242
facelessuser/soupsieve
soupsieve/css_match.py
Document.get_next_tag
def get_next_tag(cls, el): """Get next sibling tag.""" sibling = el.next_sibling while not cls.is_tag(sibling) and sibling is not None: sibling = sibling.next_sibling return sibling
python
def get_next_tag(cls, el): """Get next sibling tag.""" sibling = el.next_sibling while not cls.is_tag(sibling) and sibling is not None: sibling = sibling.next_sibling return sibling
[ "def", "get_next_tag", "(", "cls", ",", "el", ")", ":", "sibling", "=", "el", ".", "next_sibling", "while", "not", "cls", ".", "is_tag", "(", "sibling", ")", "and", "sibling", "is", "not", "None", ":", "sibling", "=", "sibling", ".", "next_sibling", "r...
Get next sibling tag.
[ "Get", "next", "sibling", "tag", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L257-L263
facelessuser/soupsieve
soupsieve/css_match.py
Document.get_previous_tag
def get_previous_tag(cls, el): """Get previous sibling tag.""" sibling = el.previous_sibling while not cls.is_tag(sibling) and sibling is not None: sibling = sibling.previous_sibling return sibling
python
def get_previous_tag(cls, el): """Get previous sibling tag.""" sibling = el.previous_sibling while not cls.is_tag(sibling) and sibling is not None: sibling = sibling.previous_sibling return sibling
[ "def", "get_previous_tag", "(", "cls", ",", "el", ")", ":", "sibling", "=", "el", ".", "previous_sibling", "while", "not", "cls", ".", "is_tag", "(", "sibling", ")", "and", "sibling", "is", "not", "None", ":", "sibling", "=", "sibling", ".", "previous_si...
Get previous sibling tag.
[ "Get", "previous", "sibling", "tag", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L266-L272
facelessuser/soupsieve
soupsieve/css_match.py
Document.get_attribute_by_name
def get_attribute_by_name(el, name, default=None): """Get attribute by name.""" value = default if el._is_xml: try: value = el.attrs[name] except KeyError: pass else: for k, v in el.attrs.items(): if uti...
python
def get_attribute_by_name(el, name, default=None): """Get attribute by name.""" value = default if el._is_xml: try: value = el.attrs[name] except KeyError: pass else: for k, v in el.attrs.items(): if uti...
[ "def", "get_attribute_by_name", "(", "el", ",", "name", ",", "default", "=", "None", ")", ":", "value", "=", "default", "if", "el", ".", "_is_xml", ":", "try", ":", "value", "=", "el", ".", "attrs", "[", "name", "]", "except", "KeyError", ":", "pass"...
Get attribute by name.
[ "Get", "attribute", "by", "name", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L293-L307
facelessuser/soupsieve
soupsieve/css_match.py
Document.get_classes
def get_classes(cls, el): """Get classes.""" classes = cls.get_attribute_by_name(el, 'class', []) if isinstance(classes, util.ustr): classes = RE_NOT_WS.findall(classes) return classes
python
def get_classes(cls, el): """Get classes.""" classes = cls.get_attribute_by_name(el, 'class', []) if isinstance(classes, util.ustr): classes = RE_NOT_WS.findall(classes) return classes
[ "def", "get_classes", "(", "cls", ",", "el", ")", ":", "classes", "=", "cls", ".", "get_attribute_by_name", "(", "el", ",", "'class'", ",", "[", "]", ")", "if", "isinstance", "(", "classes", ",", "util", ".", "ustr", ")", ":", "classes", "=", "RE_NOT...
Get classes.
[ "Get", "classes", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L317-L323
facelessuser/soupsieve
soupsieve/css_match.py
Document.get_text
def get_text(self, el, no_iframe=False): """Get text.""" return ''.join( [node for node in self.get_descendants(el, tags=False, no_iframe=no_iframe) if self.is_content_string(node)] )
python
def get_text(self, el, no_iframe=False): """Get text.""" return ''.join( [node for node in self.get_descendants(el, tags=False, no_iframe=no_iframe) if self.is_content_string(node)] )
[ "def", "get_text", "(", "self", ",", "el", ",", "no_iframe", "=", "False", ")", ":", "return", "''", ".", "join", "(", "[", "node", "for", "node", "in", "self", ".", "get_descendants", "(", "el", ",", "tags", "=", "False", ",", "no_iframe", "=", "n...
Get text.
[ "Get", "text", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L325-L330
facelessuser/soupsieve
soupsieve/css_match.py
Inputs.validate_day
def validate_day(year, month, day): """Validate day.""" max_days = LONG_MONTH if month == FEB: max_days = FEB_LEAP_MONTH if ((year % 4 == 0) and (year % 100 != 0)) or (year % 400 == 0) else FEB_MONTH elif month in MONTHS_30: max_days = SHORT_MONTH return ...
python
def validate_day(year, month, day): """Validate day.""" max_days = LONG_MONTH if month == FEB: max_days = FEB_LEAP_MONTH if ((year % 4 == 0) and (year % 100 != 0)) or (year % 400 == 0) else FEB_MONTH elif month in MONTHS_30: max_days = SHORT_MONTH return ...
[ "def", "validate_day", "(", "year", ",", "month", ",", "day", ")", ":", "max_days", "=", "LONG_MONTH", "if", "month", "==", "FEB", ":", "max_days", "=", "FEB_LEAP_MONTH", "if", "(", "(", "year", "%", "4", "==", "0", ")", "and", "(", "year", "%", "1...
Validate day.
[ "Validate", "day", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L337-L345
facelessuser/soupsieve
soupsieve/css_match.py
Inputs.validate_week
def validate_week(year, week): """Validate week.""" max_week = datetime.strptime("{}-{}-{}".format(12, 31, year), "%m-%d-%Y").isocalendar()[1] if max_week == 1: max_week = 53 return 1 <= week <= max_week
python
def validate_week(year, week): """Validate week.""" max_week = datetime.strptime("{}-{}-{}".format(12, 31, year), "%m-%d-%Y").isocalendar()[1] if max_week == 1: max_week = 53 return 1 <= week <= max_week
[ "def", "validate_week", "(", "year", ",", "week", ")", ":", "max_week", "=", "datetime", ".", "strptime", "(", "\"{}-{}-{}\"", ".", "format", "(", "12", ",", "31", ",", "year", ")", ",", "\"%m-%d-%Y\"", ")", ".", "isocalendar", "(", ")", "[", "1", "]...
Validate week.
[ "Validate", "week", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L348-L354
facelessuser/soupsieve
soupsieve/css_match.py
Inputs.parse_value
def parse_value(cls, itype, value): """Parse the input value.""" parsed = None if itype == "date": m = RE_DATE.match(value) if m: year = int(m.group('year'), 10) month = int(m.group('month'), 10) day = int(m.group('day'), 1...
python
def parse_value(cls, itype, value): """Parse the input value.""" parsed = None if itype == "date": m = RE_DATE.match(value) if m: year = int(m.group('year'), 10) month = int(m.group('month'), 10) day = int(m.group('day'), 1...
[ "def", "parse_value", "(", "cls", ",", "itype", ",", "value", ")", ":", "parsed", "=", "None", "if", "itype", "==", "\"date\"", ":", "m", "=", "RE_DATE", ".", "match", "(", "value", ")", "if", "m", ":", "year", "=", "int", "(", "m", ".", "group",...
Parse the input value.
[ "Parse", "the", "input", "value", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L381-L431
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.get_tag_ns
def get_tag_ns(self, el): """Get tag namespace.""" if self.supports_namespaces(): namespace = '' ns = el.namespace if ns: namespace = ns else: namespace = NS_XHTML return namespace
python
def get_tag_ns(self, el): """Get tag namespace.""" if self.supports_namespaces(): namespace = '' ns = el.namespace if ns: namespace = ns else: namespace = NS_XHTML return namespace
[ "def", "get_tag_ns", "(", "self", ",", "el", ")", ":", "if", "self", ".", "supports_namespaces", "(", ")", ":", "namespace", "=", "''", "ns", "=", "el", ".", "namespace", "if", "ns", ":", "namespace", "=", "ns", "else", ":", "namespace", "=", "NS_XHT...
Get tag namespace.
[ "Get", "tag", "namespace", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L477-L487
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.get_tag
def get_tag(self, el): """Get tag.""" name = self.get_tag_name(el) return util.lower(name) if name is not None and not self.is_xml else name
python
def get_tag(self, el): """Get tag.""" name = self.get_tag_name(el) return util.lower(name) if name is not None and not self.is_xml else name
[ "def", "get_tag", "(", "self", ",", "el", ")", ":", "name", "=", "self", ".", "get_tag_name", "(", "el", ")", "return", "util", ".", "lower", "(", "name", ")", "if", "name", "is", "not", "None", "and", "not", "self", ".", "is_xml", "else", "name" ]
Get tag.
[ "Get", "tag", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L494-L498
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.get_prefix
def get_prefix(self, el): """Get prefix.""" prefix = self.get_prefix_name(el) return util.lower(prefix) if prefix is not None and not self.is_xml else prefix
python
def get_prefix(self, el): """Get prefix.""" prefix = self.get_prefix_name(el) return util.lower(prefix) if prefix is not None and not self.is_xml else prefix
[ "def", "get_prefix", "(", "self", ",", "el", ")", ":", "prefix", "=", "self", ".", "get_prefix_name", "(", "el", ")", "return", "util", ".", "lower", "(", "prefix", ")", "if", "prefix", "is", "not", "None", "and", "not", "self", ".", "is_xml", "else"...
Get prefix.
[ "Get", "prefix", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L500-L504
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.find_bidi
def find_bidi(self, el): """Get directionality from element text.""" for node in self.get_children(el, tags=False): # Analyze child text nodes if self.is_tag(node): # Avoid analyzing certain elements specified in the specification. direction = D...
python
def find_bidi(self, el): """Get directionality from element text.""" for node in self.get_children(el, tags=False): # Analyze child text nodes if self.is_tag(node): # Avoid analyzing certain elements specified in the specification. direction = D...
[ "def", "find_bidi", "(", "self", ",", "el", ")", ":", "for", "node", "in", "self", ".", "get_children", "(", "el", ",", "tags", "=", "False", ")", ":", "# Analyze child text nodes", "if", "self", ".", "is_tag", "(", "node", ")", ":", "# Avoid analyzing c...
Get directionality from element text.
[ "Get", "directionality", "from", "element", "text", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L506-L540
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_attribute_name
def match_attribute_name(self, el, attr, prefix): """Match attribute name and return value if it exists.""" value = None if self.supports_namespaces(): value = None # If we have not defined namespaces, we can't very well find them, so don't bother trying. if ...
python
def match_attribute_name(self, el, attr, prefix): """Match attribute name and return value if it exists.""" value = None if self.supports_namespaces(): value = None # If we have not defined namespaces, we can't very well find them, so don't bother trying. if ...
[ "def", "match_attribute_name", "(", "self", ",", "el", ",", "attr", ",", "prefix", ")", ":", "value", "=", "None", "if", "self", ".", "supports_namespaces", "(", ")", ":", "value", "=", "None", "# If we have not defined namespaces, we can't very well find them, so d...
Match attribute name and return value if it exists.
[ "Match", "attribute", "name", "and", "return", "value", "if", "it", "exists", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L542-L588
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_namespace
def match_namespace(self, el, tag): """Match the namespace of the element.""" match = True namespace = self.get_tag_ns(el) default_namespace = self.namespaces.get('') tag_ns = '' if tag.prefix is None else self.namespaces.get(tag.prefix, None) # We must match the default...
python
def match_namespace(self, el, tag): """Match the namespace of the element.""" match = True namespace = self.get_tag_ns(el) default_namespace = self.namespaces.get('') tag_ns = '' if tag.prefix is None else self.namespaces.get(tag.prefix, None) # We must match the default...
[ "def", "match_namespace", "(", "self", ",", "el", ",", "tag", ")", ":", "match", "=", "True", "namespace", "=", "self", ".", "get_tag_ns", "(", "el", ")", "default_namespace", "=", "self", ".", "namespaces", ".", "get", "(", "''", ")", "tag_ns", "=", ...
Match the namespace of the element.
[ "Match", "the", "namespace", "of", "the", "element", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L590-L609
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_attributes
def match_attributes(self, el, attributes): """Match attributes.""" match = True if attributes: for a in attributes: value = self.match_attribute_name(el, a.attribute, a.prefix) pattern = a.xml_type_pattern if self.is_xml and a.xml_type_pattern else a...
python
def match_attributes(self, el, attributes): """Match attributes.""" match = True if attributes: for a in attributes: value = self.match_attribute_name(el, a.attribute, a.prefix) pattern = a.xml_type_pattern if self.is_xml and a.xml_type_pattern else a...
[ "def", "match_attributes", "(", "self", ",", "el", ",", "attributes", ")", ":", "match", "=", "True", "if", "attributes", ":", "for", "a", "in", "attributes", ":", "value", "=", "self", ".", "match_attribute_name", "(", "el", ",", "a", ".", "attribute", ...
Match attributes.
[ "Match", "attributes", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L611-L629
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_tagname
def match_tagname(self, el, tag): """Match tag name.""" name = (util.lower(tag.name) if not self.is_xml and tag.name is not None else tag.name) return not ( name is not None and name not in (self.get_tag(el), '*') )
python
def match_tagname(self, el, tag): """Match tag name.""" name = (util.lower(tag.name) if not self.is_xml and tag.name is not None else tag.name) return not ( name is not None and name not in (self.get_tag(el), '*') )
[ "def", "match_tagname", "(", "self", ",", "el", ",", "tag", ")", ":", "name", "=", "(", "util", ".", "lower", "(", "tag", ".", "name", ")", "if", "not", "self", ".", "is_xml", "and", "tag", ".", "name", "is", "not", "None", "else", "tag", ".", ...
Match tag name.
[ "Match", "tag", "name", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L631-L638
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_tag
def match_tag(self, el, tag): """Match the tag.""" match = True if tag is not None: # Verify namespace if not self.match_namespace(el, tag): match = False if not self.match_tagname(el, tag): match = False return match
python
def match_tag(self, el, tag): """Match the tag.""" match = True if tag is not None: # Verify namespace if not self.match_namespace(el, tag): match = False if not self.match_tagname(el, tag): match = False return match
[ "def", "match_tag", "(", "self", ",", "el", ",", "tag", ")", ":", "match", "=", "True", "if", "tag", "is", "not", "None", ":", "# Verify namespace", "if", "not", "self", ".", "match_namespace", "(", "el", ",", "tag", ")", ":", "match", "=", "False", ...
Match the tag.
[ "Match", "the", "tag", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L640-L650
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_past_relations
def match_past_relations(self, el, relation): """Match past relationship.""" found = False if relation[0].rel_type == REL_PARENT: parent = self.get_parent(el, no_iframe=self.iframe_restrict) while not found and parent: found = self.match_selectors(parent,...
python
def match_past_relations(self, el, relation): """Match past relationship.""" found = False if relation[0].rel_type == REL_PARENT: parent = self.get_parent(el, no_iframe=self.iframe_restrict) while not found and parent: found = self.match_selectors(parent,...
[ "def", "match_past_relations", "(", "self", ",", "el", ",", "relation", ")", ":", "found", "=", "False", "if", "relation", "[", "0", "]", ".", "rel_type", "==", "REL_PARENT", ":", "parent", "=", "self", ".", "get_parent", "(", "el", ",", "no_iframe", "...
Match past relationship.
[ "Match", "past", "relationship", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L652-L674
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_future_child
def match_future_child(self, parent, relation, recursive=False): """Match future child.""" match = False children = self.get_descendants if recursive else self.get_children for child in children(parent, no_iframe=self.iframe_restrict): match = self.match_selectors(child, rel...
python
def match_future_child(self, parent, relation, recursive=False): """Match future child.""" match = False children = self.get_descendants if recursive else self.get_children for child in children(parent, no_iframe=self.iframe_restrict): match = self.match_selectors(child, rel...
[ "def", "match_future_child", "(", "self", ",", "parent", ",", "relation", ",", "recursive", "=", "False", ")", ":", "match", "=", "False", "children", "=", "self", ".", "get_descendants", "if", "recursive", "else", "self", ".", "get_children", "for", "child"...
Match future child.
[ "Match", "future", "child", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L676-L685
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_future_relations
def match_future_relations(self, el, relation): """Match future relationship.""" found = False if relation[0].rel_type == REL_HAS_PARENT: found = self.match_future_child(el, relation, True) elif relation[0].rel_type == REL_HAS_CLOSE_PARENT: found = self.match_fut...
python
def match_future_relations(self, el, relation): """Match future relationship.""" found = False if relation[0].rel_type == REL_HAS_PARENT: found = self.match_future_child(el, relation, True) elif relation[0].rel_type == REL_HAS_CLOSE_PARENT: found = self.match_fut...
[ "def", "match_future_relations", "(", "self", ",", "el", ",", "relation", ")", ":", "found", "=", "False", "if", "relation", "[", "0", "]", ".", "rel_type", "==", "REL_HAS_PARENT", ":", "found", "=", "self", ".", "match_future_child", "(", "el", ",", "re...
Match future relationship.
[ "Match", "future", "relationship", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L687-L704
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_relations
def match_relations(self, el, relation): """Match relationship to other elements.""" found = False if relation[0].rel_type.startswith(':'): found = self.match_future_relations(el, relation) else: found = self.match_past_relations(el, relation) return fo...
python
def match_relations(self, el, relation): """Match relationship to other elements.""" found = False if relation[0].rel_type.startswith(':'): found = self.match_future_relations(el, relation) else: found = self.match_past_relations(el, relation) return fo...
[ "def", "match_relations", "(", "self", ",", "el", ",", "relation", ")", ":", "found", "=", "False", "if", "relation", "[", "0", "]", ".", "rel_type", ".", "startswith", "(", "':'", ")", ":", "found", "=", "self", ".", "match_future_relations", "(", "el...
Match relationship to other elements.
[ "Match", "relationship", "to", "other", "elements", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L706-L716
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_id
def match_id(self, el, ids): """Match element's ID.""" found = True for i in ids: if i != self.get_attribute_by_name(el, 'id', ''): found = False break return found
python
def match_id(self, el, ids): """Match element's ID.""" found = True for i in ids: if i != self.get_attribute_by_name(el, 'id', ''): found = False break return found
[ "def", "match_id", "(", "self", ",", "el", ",", "ids", ")", ":", "found", "=", "True", "for", "i", "in", "ids", ":", "if", "i", "!=", "self", ".", "get_attribute_by_name", "(", "el", ",", "'id'", ",", "''", ")", ":", "found", "=", "False", "break...
Match element's ID.
[ "Match", "element", "s", "ID", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L718-L726
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_classes
def match_classes(self, el, classes): """Match element's classes.""" current_classes = self.get_classes(el) found = True for c in classes: if c not in current_classes: found = False break return found
python
def match_classes(self, el, classes): """Match element's classes.""" current_classes = self.get_classes(el) found = True for c in classes: if c not in current_classes: found = False break return found
[ "def", "match_classes", "(", "self", ",", "el", ",", "classes", ")", ":", "current_classes", "=", "self", ".", "get_classes", "(", "el", ")", "found", "=", "True", "for", "c", "in", "classes", ":", "if", "c", "not", "in", "current_classes", ":", "found...
Match element's classes.
[ "Match", "element", "s", "classes", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L728-L737
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_nth_tag_type
def match_nth_tag_type(self, el, child): """Match tag type for `nth` matches.""" return( (self.get_tag(child) == self.get_tag(el)) and (self.get_tag_ns(child) == self.get_tag_ns(el)) )
python
def match_nth_tag_type(self, el, child): """Match tag type for `nth` matches.""" return( (self.get_tag(child) == self.get_tag(el)) and (self.get_tag_ns(child) == self.get_tag_ns(el)) )
[ "def", "match_nth_tag_type", "(", "self", ",", "el", ",", "child", ")", ":", "return", "(", "(", "self", ".", "get_tag", "(", "child", ")", "==", "self", ".", "get_tag", "(", "el", ")", ")", "and", "(", "self", ".", "get_tag_ns", "(", "child", ")",...
Match tag type for `nth` matches.
[ "Match", "tag", "type", "for", "nth", "matches", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L749-L755
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_nth
def match_nth(self, el, nth): """Match `nth` elements.""" matched = True for n in nth: matched = False if n.selectors and not self.match_selectors(el, n.selectors): break parent = self.get_parent(el) if parent is None: ...
python
def match_nth(self, el, nth): """Match `nth` elements.""" matched = True for n in nth: matched = False if n.selectors and not self.match_selectors(el, n.selectors): break parent = self.get_parent(el) if parent is None: ...
[ "def", "match_nth", "(", "self", ",", "el", ",", "nth", ")", ":", "matched", "=", "True", "for", "n", "in", "nth", ":", "matched", "=", "False", "if", "n", ".", "selectors", "and", "not", "self", ".", "match_selectors", "(", "el", ",", "n", ".", ...
Match `nth` elements.
[ "Match", "nth", "elements", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L757-L856
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_empty
def match_empty(self, el): """Check if element is empty (if requested).""" is_empty = True for child in self.get_children(el, tags=False): if self.is_tag(child): is_empty = False break elif self.is_content_string(child) and RE_NOT_EMPTY.se...
python
def match_empty(self, el): """Check if element is empty (if requested).""" is_empty = True for child in self.get_children(el, tags=False): if self.is_tag(child): is_empty = False break elif self.is_content_string(child) and RE_NOT_EMPTY.se...
[ "def", "match_empty", "(", "self", ",", "el", ")", ":", "is_empty", "=", "True", "for", "child", "in", "self", ".", "get_children", "(", "el", ",", "tags", "=", "False", ")", ":", "if", "self", ".", "is_tag", "(", "child", ")", ":", "is_empty", "="...
Check if element is empty (if requested).
[ "Check", "if", "element", "is", "empty", "(", "if", "requested", ")", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L858-L869
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_subselectors
def match_subselectors(self, el, selectors): """Match selectors.""" match = True for sel in selectors: if not self.match_selectors(el, sel): match = False return match
python
def match_subselectors(self, el, selectors): """Match selectors.""" match = True for sel in selectors: if not self.match_selectors(el, sel): match = False return match
[ "def", "match_subselectors", "(", "self", ",", "el", ",", "selectors", ")", ":", "match", "=", "True", "for", "sel", "in", "selectors", ":", "if", "not", "self", ".", "match_selectors", "(", "el", ",", "sel", ")", ":", "match", "=", "False", "return", ...
Match selectors.
[ "Match", "selectors", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L871-L878
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_contains
def match_contains(self, el, contains): """Match element if it contains text.""" match = True content = None for contain_list in contains: if content is None: content = self.get_text(el, no_iframe=self.is_html) found = False for text i...
python
def match_contains(self, el, contains): """Match element if it contains text.""" match = True content = None for contain_list in contains: if content is None: content = self.get_text(el, no_iframe=self.is_html) found = False for text i...
[ "def", "match_contains", "(", "self", ",", "el", ",", "contains", ")", ":", "match", "=", "True", "content", "=", "None", "for", "contain_list", "in", "contains", ":", "if", "content", "is", "None", ":", "content", "=", "self", ".", "get_text", "(", "e...
Match element if it contains text.
[ "Match", "element", "if", "it", "contains", "text", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L880-L895
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_default
def match_default(self, el): """Match default.""" match = False # Find this input's form form = None parent = self.get_parent(el, no_iframe=True) while parent and form is None: if self.get_tag(parent) == 'form' and self.is_html_tag(parent): f...
python
def match_default(self, el): """Match default.""" match = False # Find this input's form form = None parent = self.get_parent(el, no_iframe=True) while parent and form is None: if self.get_tag(parent) == 'form' and self.is_html_tag(parent): f...
[ "def", "match_default", "(", "self", ",", "el", ")", ":", "match", "=", "False", "# Find this input's form", "form", "=", "None", "parent", "=", "self", ".", "get_parent", "(", "el", ",", "no_iframe", "=", "True", ")", "while", "parent", "and", "form", "...
Match default.
[ "Match", "default", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L897-L934
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_indeterminate
def match_indeterminate(self, el): """Match default.""" match = False name = self.get_attribute_by_name(el, 'name') def get_parent_form(el): """Find this input's form.""" form = None parent = self.get_parent(el, no_iframe=True) while form...
python
def match_indeterminate(self, el): """Match default.""" match = False name = self.get_attribute_by_name(el, 'name') def get_parent_form(el): """Find this input's form.""" form = None parent = self.get_parent(el, no_iframe=True) while form...
[ "def", "match_indeterminate", "(", "self", ",", "el", ")", ":", "match", "=", "False", "name", "=", "self", ".", "get_attribute_by_name", "(", "el", ",", "'name'", ")", "def", "get_parent_form", "(", "el", ")", ":", "\"\"\"Find this input's form.\"\"\"", "form...
Match default.
[ "Match", "default", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L936-L995
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_lang
def match_lang(self, el, langs): """Match languages.""" match = False has_ns = self.supports_namespaces() root = self.root has_html_namespace = self.has_html_namespace # Walk parents looking for `lang` (HTML) or `xml:lang` XML property. parent = el found...
python
def match_lang(self, el, langs): """Match languages.""" match = False has_ns = self.supports_namespaces() root = self.root has_html_namespace = self.has_html_namespace # Walk parents looking for `lang` (HTML) or `xml:lang` XML property. parent = el found...
[ "def", "match_lang", "(", "self", ",", "el", ",", "langs", ")", ":", "match", "=", "False", "has_ns", "=", "self", ".", "supports_namespaces", "(", ")", "root", "=", "self", ".", "root", "has_html_namespace", "=", "self", ".", "has_html_namespace", "# Walk...
Match languages.
[ "Match", "languages", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L997-L1081
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_dir
def match_dir(self, el, directionality): """Check directionality.""" # If we have to match both left and right, we can't match either. if directionality & ct.SEL_DIR_LTR and directionality & ct.SEL_DIR_RTL: return False if el is None or not self.is_html_tag(el): ...
python
def match_dir(self, el, directionality): """Check directionality.""" # If we have to match both left and right, we can't match either. if directionality & ct.SEL_DIR_LTR and directionality & ct.SEL_DIR_RTL: return False if el is None or not self.is_html_tag(el): ...
[ "def", "match_dir", "(", "self", ",", "el", ",", "directionality", ")", ":", "# If we have to match both left and right, we can't match either.", "if", "directionality", "&", "ct", ".", "SEL_DIR_LTR", "and", "directionality", "&", "ct", ".", "SEL_DIR_RTL", ":", "retur...
Check directionality.
[ "Check", "directionality", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1083-L1144
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_range
def match_range(self, el, condition): """ Match range. Behavior is modeled after what we see in browsers. Browsers seem to evaluate if the value is out of range, and if not, it is in range. So a missing value will not evaluate out of range; therefore, value is in range. Personal...
python
def match_range(self, el, condition): """ Match range. Behavior is modeled after what we see in browsers. Browsers seem to evaluate if the value is out of range, and if not, it is in range. So a missing value will not evaluate out of range; therefore, value is in range. Personal...
[ "def", "match_range", "(", "self", ",", "el", ",", "condition", ")", ":", "out_of_range", "=", "False", "itype", "=", "self", ".", "get_attribute_by_name", "(", "el", ",", "'type'", ")", ".", "lower", "(", ")", "mn", "=", "self", ".", "get_attribute_by_n...
Match range. Behavior is modeled after what we see in browsers. Browsers seem to evaluate if the value is out of range, and if not, it is in range. So a missing value will not evaluate out of range; therefore, value is in range. Personally, I feel like this should evaluate as neither in...
[ "Match", "range", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1146-L1190
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_defined
def match_defined(self, el): """ Match defined. `:defined` is related to custom elements in a browser. - If the document is XML (not XHTML), all tags will match. - Tags that are not custom (don't have a hyphen) are marked defined. - If the tag has a prefix (without or w...
python
def match_defined(self, el): """ Match defined. `:defined` is related to custom elements in a browser. - If the document is XML (not XHTML), all tags will match. - Tags that are not custom (don't have a hyphen) are marked defined. - If the tag has a prefix (without or w...
[ "def", "match_defined", "(", "self", ",", "el", ")", ":", "name", "=", "self", ".", "get_tag", "(", "el", ")", "return", "(", "name", ".", "find", "(", "'-'", ")", "==", "-", "1", "or", "name", ".", "find", "(", "':'", ")", "!=", "-", "1", "o...
Match defined. `:defined` is related to custom elements in a browser. - If the document is XML (not XHTML), all tags will match. - Tags that are not custom (don't have a hyphen) are marked defined. - If the tag has a prefix (without or without a namespace), it will not match. ...
[ "Match", "defined", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1192-L1211
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match_selectors
def match_selectors(self, el, selectors): """Check if element matches one of the selectors.""" match = False is_not = selectors.is_not is_html = selectors.is_html # Internal selector lists that use the HTML flag, will automatically get the `html` namespace. if is_html: ...
python
def match_selectors(self, el, selectors): """Check if element matches one of the selectors.""" match = False is_not = selectors.is_not is_html = selectors.is_html # Internal selector lists that use the HTML flag, will automatically get the `html` namespace. if is_html: ...
[ "def", "match_selectors", "(", "self", ",", "el", ",", "selectors", ")", ":", "match", "=", "False", "is_not", "=", "selectors", ".", "is_not", "is_html", "=", "selectors", ".", "is_html", "# Internal selector lists that use the HTML flag, will automatically get the `ht...
Check if element matches one of the selectors.
[ "Check", "if", "element", "matches", "one", "of", "the", "selectors", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1213-L1292
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.select
def select(self, limit=0): """Match all tags under the targeted tag.""" if limit < 1: limit = None for child in self.get_descendants(self.tag): if self.match(child): yield child if limit is not None: limit -= 1 ...
python
def select(self, limit=0): """Match all tags under the targeted tag.""" if limit < 1: limit = None for child in self.get_descendants(self.tag): if self.match(child): yield child if limit is not None: limit -= 1 ...
[ "def", "select", "(", "self", ",", "limit", "=", "0", ")", ":", "if", "limit", "<", "1", ":", "limit", "=", "None", "for", "child", "in", "self", ".", "get_descendants", "(", "self", ".", "tag", ")", ":", "if", "self", ".", "match", "(", "child",...
Match all tags under the targeted tag.
[ "Match", "all", "tags", "under", "the", "targeted", "tag", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1294-L1306
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.closest
def closest(self): """Match closest ancestor.""" current = self.tag closest = None while closest is None and current is not None: if self.match(current): closest = current else: current = self.get_parent(current) return clo...
python
def closest(self): """Match closest ancestor.""" current = self.tag closest = None while closest is None and current is not None: if self.match(current): closest = current else: current = self.get_parent(current) return clo...
[ "def", "closest", "(", "self", ")", ":", "current", "=", "self", ".", "tag", "closest", "=", "None", "while", "closest", "is", "None", "and", "current", "is", "not", "None", ":", "if", "self", ".", "match", "(", "current", ")", ":", "closest", "=", ...
Match closest ancestor.
[ "Match", "closest", "ancestor", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1308-L1318
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.filter
def filter(self): # noqa A001 """Filter tag's children.""" return [tag for tag in self.get_contents(self.tag) if not self.is_navigable_string(tag) and self.match(tag)]
python
def filter(self): # noqa A001 """Filter tag's children.""" return [tag for tag in self.get_contents(self.tag) if not self.is_navigable_string(tag) and self.match(tag)]
[ "def", "filter", "(", "self", ")", ":", "# noqa A001", "return", "[", "tag", "for", "tag", "in", "self", ".", "get_contents", "(", "self", ".", "tag", ")", "if", "not", "self", ".", "is_navigable_string", "(", "tag", ")", "and", "self", ".", "match", ...
Filter tag's children.
[ "Filter", "tag", "s", "children", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1320-L1323
facelessuser/soupsieve
soupsieve/css_match.py
CSSMatch.match
def match(self, el): """Match.""" return not self.is_doc(el) and self.is_tag(el) and self.match_selectors(el, self.selectors)
python
def match(self, el): """Match.""" return not self.is_doc(el) and self.is_tag(el) and self.match_selectors(el, self.selectors)
[ "def", "match", "(", "self", ",", "el", ")", ":", "return", "not", "self", ".", "is_doc", "(", "el", ")", "and", "self", ".", "is_tag", "(", "el", ")", "and", "self", ".", "match_selectors", "(", "el", ",", "self", ".", "selectors", ")" ]
Match.
[ "Match", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1325-L1328
facelessuser/soupsieve
soupsieve/css_match.py
CommentsMatch.get_comments
def get_comments(self, limit=0): """Get comments.""" if limit < 1: limit = None for child in self.get_descendants(self.tag, tags=False): if self.is_comment(child): yield child if limit is not None: limit -= 1 ...
python
def get_comments(self, limit=0): """Get comments.""" if limit < 1: limit = None for child in self.get_descendants(self.tag, tags=False): if self.is_comment(child): yield child if limit is not None: limit -= 1 ...
[ "def", "get_comments", "(", "self", ",", "limit", "=", "0", ")", ":", "if", "limit", "<", "1", ":", "limit", "=", "None", "for", "child", "in", "self", ".", "get_descendants", "(", "self", ".", "tag", ",", "tags", "=", "False", ")", ":", "if", "s...
Get comments.
[ "Get", "comments", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1340-L1352
facelessuser/soupsieve
soupsieve/css_match.py
SoupSieve.match
def match(self, tag): """Match.""" return CSSMatch(self.selectors, tag, self.namespaces, self.flags).match(tag)
python
def match(self, tag): """Match.""" return CSSMatch(self.selectors, tag, self.namespaces, self.flags).match(tag)
[ "def", "match", "(", "self", ",", "tag", ")", ":", "return", "CSSMatch", "(", "self", ".", "selectors", ",", "tag", ",", "self", ".", "namespaces", ",", "self", ".", "flags", ")", ".", "match", "(", "tag", ")" ]
Match.
[ "Match", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1371-L1374
facelessuser/soupsieve
soupsieve/css_match.py
SoupSieve.closest
def closest(self, tag): """Match closest ancestor.""" return CSSMatch(self.selectors, tag, self.namespaces, self.flags).closest()
python
def closest(self, tag): """Match closest ancestor.""" return CSSMatch(self.selectors, tag, self.namespaces, self.flags).closest()
[ "def", "closest", "(", "self", ",", "tag", ")", ":", "return", "CSSMatch", "(", "self", ".", "selectors", ",", "tag", ",", "self", ".", "namespaces", ",", "self", ".", "flags", ")", ".", "closest", "(", ")" ]
Match closest ancestor.
[ "Match", "closest", "ancestor", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1376-L1379
facelessuser/soupsieve
soupsieve/css_match.py
SoupSieve.filter
def filter(self, iterable): # noqa A001 """ Filter. `CSSMatch` can cache certain searches for tags of the same document, so if we are given a tag, all tags are from the same document, and we can take advantage of the optimization. Any other kind of iterable could have ...
python
def filter(self, iterable): # noqa A001 """ Filter. `CSSMatch` can cache certain searches for tags of the same document, so if we are given a tag, all tags are from the same document, and we can take advantage of the optimization. Any other kind of iterable could have ...
[ "def", "filter", "(", "self", ",", "iterable", ")", ":", "# noqa A001", "if", "CSSMatch", ".", "is_tag", "(", "iterable", ")", ":", "return", "CSSMatch", "(", "self", ".", "selectors", ",", "iterable", ",", "self", ".", "namespaces", ",", "self", ".", ...
Filter. `CSSMatch` can cache certain searches for tags of the same document, so if we are given a tag, all tags are from the same document, and we can take advantage of the optimization. Any other kind of iterable could have tags from different documents or detached tags, so fo...
[ "Filter", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1381-L1396
facelessuser/soupsieve
soupsieve/css_match.py
SoupSieve.comments
def comments(self, tag, limit=0): """Get comments only.""" return [comment for comment in CommentsMatch(tag).get_comments(limit)]
python
def comments(self, tag, limit=0): """Get comments only.""" return [comment for comment in CommentsMatch(tag).get_comments(limit)]
[ "def", "comments", "(", "self", ",", "tag", ",", "limit", "=", "0", ")", ":", "return", "[", "comment", "for", "comment", "in", "CommentsMatch", "(", "tag", ")", ".", "get_comments", "(", "limit", ")", "]" ]
Get comments only.
[ "Get", "comments", "only", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1399-L1402
facelessuser/soupsieve
soupsieve/css_match.py
SoupSieve.icomments
def icomments(self, tag, limit=0): """Iterate comments only.""" for comment in CommentsMatch(tag).get_comments(limit): yield comment
python
def icomments(self, tag, limit=0): """Iterate comments only.""" for comment in CommentsMatch(tag).get_comments(limit): yield comment
[ "def", "icomments", "(", "self", ",", "tag", ",", "limit", "=", "0", ")", ":", "for", "comment", "in", "CommentsMatch", "(", "tag", ")", ".", "get_comments", "(", "limit", ")", ":", "yield", "comment" ]
Iterate comments only.
[ "Iterate", "comments", "only", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1405-L1409
facelessuser/soupsieve
soupsieve/css_match.py
SoupSieve.select_one
def select_one(self, tag): """Select a single tag.""" tags = self.select(tag, limit=1) return tags[0] if tags else None
python
def select_one(self, tag): """Select a single tag.""" tags = self.select(tag, limit=1) return tags[0] if tags else None
[ "def", "select_one", "(", "self", ",", "tag", ")", ":", "tags", "=", "self", ".", "select", "(", "tag", ",", "limit", "=", "1", ")", "return", "tags", "[", "0", "]", "if", "tags", "else", "None" ]
Select a single tag.
[ "Select", "a", "single", "tag", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1411-L1415
facelessuser/soupsieve
soupsieve/css_match.py
SoupSieve.iselect
def iselect(self, tag, limit=0): """Iterate the specified tags.""" for el in CSSMatch(self.selectors, tag, self.namespaces, self.flags).select(limit): yield el
python
def iselect(self, tag, limit=0): """Iterate the specified tags.""" for el in CSSMatch(self.selectors, tag, self.namespaces, self.flags).select(limit): yield el
[ "def", "iselect", "(", "self", ",", "tag", ",", "limit", "=", "0", ")", ":", "for", "el", "in", "CSSMatch", "(", "self", ".", "selectors", ",", "tag", ",", "self", ".", "namespaces", ",", "self", ".", "flags", ")", ".", "select", "(", "limit", ")...
Iterate the specified tags.
[ "Iterate", "the", "specified", "tags", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1422-L1426