Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
Configuration.set_value
(self, key, value)
Modify a value in the configuration.
Modify a value in the configuration.
def set_value(self, key, value): # type: (str, Any) -> None """Modify a value in the configuration. """ self._ensure_have_load_only() assert self.load_only fname, parser = self._get_parser_to_modify() if parser is not None: section, name = _disassemb...
[ "def", "set_value", "(", "self", ",", "key", ",", "value", ")", ":", "# type: (str, Any) -> None", "self", ".", "_ensure_have_load_only", "(", ")", "assert", "self", ".", "load_only", "fname", ",", "parser", "=", "self", ".", "_get_parser_to_modify", "(", ")",...
[ 178, 4 ]
[ 196, 45 ]
python
en
['en', 'it', 'en']
True
Configuration.unset_value
(self, key)
Unset a value in the configuration.
Unset a value in the configuration.
def unset_value(self, key): # type: (str) -> None """Unset a value in the configuration.""" self._ensure_have_load_only() assert self.load_only if key not in self._config[self.load_only]: raise ConfigurationError("No such key - {}".format(key)) fname, parser...
[ "def", "unset_value", "(", "self", ",", "key", ")", ":", "# type: (str) -> None", "self", ".", "_ensure_have_load_only", "(", ")", "assert", "self", ".", "load_only", "if", "key", "not", "in", "self", ".", "_config", "[", "self", ".", "load_only", "]", ":"...
[ 198, 4 ]
[ 223, 45 ]
python
en
['en', 'en', 'en']
True
Configuration.save
(self)
Save the current in-memory state.
Save the current in-memory state.
def save(self): # type: () -> None """Save the current in-memory state. """ self._ensure_have_load_only() for fname, parser in self._modified_parsers: logger.info("Writing to %s", fname) # Ensure directory exists. ensure_dir(os.path.dirname(f...
[ "def", "save", "(", "self", ")", ":", "# type: () -> None", "self", ".", "_ensure_have_load_only", "(", ")", "for", "fname", ",", "parser", "in", "self", ".", "_modified_parsers", ":", "logger", ".", "info", "(", "\"Writing to %s\"", ",", "fname", ")", "# En...
[ 225, 4 ]
[ 238, 31 ]
python
en
['en', 'en', 'en']
True
Configuration._dictionary
(self)
A dictionary representing the loaded configuration.
A dictionary representing the loaded configuration.
def _dictionary(self): # type: () -> Dict[str, Any] """A dictionary representing the loaded configuration. """ # NOTE: Dictionaries are not populated if not loaded. So, conditionals # are not needed here. retval = {} for variant in self._override_order: ...
[ "def", "_dictionary", "(", "self", ")", ":", "# type: () -> Dict[str, Any]", "# NOTE: Dictionaries are not populated if not loaded. So, conditionals", "# are not needed here.", "retval", "=", "{", "}", "for", "variant", "in", "self", ".", "_override_order", ":", "retval...
[ 251, 4 ]
[ 262, 21 ]
python
en
['en', 'en', 'en']
True
Configuration._load_config_files
(self)
Loads configuration from configuration files
Loads configuration from configuration files
def _load_config_files(self): # type: () -> None """Loads configuration from configuration files """ config_files = dict(self.iter_config_files()) if config_files[kinds.ENV][0:1] == [os.devnull]: logger.debug( "Skipping loading configuration files due ...
[ "def", "_load_config_files", "(", "self", ")", ":", "# type: () -> None", "config_files", "=", "dict", "(", "self", ".", "iter_config_files", "(", ")", ")", "if", "config_files", "[", "kinds", ".", "ENV", "]", "[", "0", ":", "1", "]", "==", "[", "os", ...
[ 264, 4 ]
[ 289, 62 ]
python
en
['en', 'en', 'en']
True
Configuration._load_environment_vars
(self)
Loads configuration from environment variables
Loads configuration from environment variables
def _load_environment_vars(self): # type: () -> None """Loads configuration from environment variables """ self._config[kinds.ENV_VAR].update( self._normalized_keys(":env:", self.get_environ_vars()) )
[ "def", "_load_environment_vars", "(", "self", ")", ":", "# type: () -> None", "self", ".", "_config", "[", "kinds", ".", "ENV_VAR", "]", ".", "update", "(", "self", ".", "_normalized_keys", "(", "\":env:\"", ",", "self", ".", "get_environ_vars", "(", ")", ")...
[ 325, 4 ]
[ 331, 9 ]
python
en
['en', 'en', 'en']
True
Configuration._normalized_keys
(self, section, items)
Normalizes items to construct a dictionary with normalized keys. This routine is where the names become keys and are made the same regardless of source - configuration files or environment.
Normalizes items to construct a dictionary with normalized keys.
def _normalized_keys(self, section, items): # type: (str, Iterable[Tuple[str, Any]]) -> Dict[str, Any] """Normalizes items to construct a dictionary with normalized keys. This routine is where the names become keys and are made the same regardless of source - configuration files or envi...
[ "def", "_normalized_keys", "(", "self", ",", "section", ",", "items", ")", ":", "# type: (str, Iterable[Tuple[str, Any]]) -> Dict[str, Any]", "normalized", "=", "{", "}", "for", "name", ",", "val", "in", "items", ":", "key", "=", "section", "+", "\".\"", "+", ...
[ 333, 4 ]
[ 344, 25 ]
python
en
['en', 'en', 'en']
True
Configuration.get_environ_vars
(self)
Returns a generator with all environmental vars with prefix PIP_
Returns a generator with all environmental vars with prefix PIP_
def get_environ_vars(self): # type: () -> Iterable[Tuple[str, str]] """Returns a generator with all environmental vars with prefix PIP_""" for key, val in os.environ.items(): should_be_yielded = ( key.startswith("PIP_") and key[4:].lower() not in self....
[ "def", "get_environ_vars", "(", "self", ")", ":", "# type: () -> Iterable[Tuple[str, str]]", "for", "key", ",", "val", "in", "os", ".", "environ", ".", "items", "(", ")", ":", "should_be_yielded", "=", "(", "key", ".", "startswith", "(", "\"PIP_\"", ")", "an...
[ 346, 4 ]
[ 355, 42 ]
python
en
['en', 'en', 'en']
True
Configuration.iter_config_files
(self)
Yields variant and configuration files associated with it. This should be treated like items of a dictionary.
Yields variant and configuration files associated with it.
def iter_config_files(self): # type: () -> Iterable[Tuple[Kind, List[str]]] """Yields variant and configuration files associated with it. This should be treated like items of a dictionary. """ # SMELL: Move the conditions out of this function # environment variables hav...
[ "def", "iter_config_files", "(", "self", ")", ":", "# type: () -> Iterable[Tuple[Kind, List[str]]]", "# SMELL: Move the conditions out of this function", "# environment variables have the lowest priority", "config_file", "=", "os", ".", "environ", ".", "get", "(", "'PIP_CONFIG_FILE...
[ 358, 4 ]
[ 387, 50 ]
python
en
['en', 'en', 'en']
True
Configuration.get_values_in_config
(self, variant)
Get values present in a config file
Get values present in a config file
def get_values_in_config(self, variant): # type: (Kind) -> Dict[str, Any] """Get values present in a config file""" return self._config[variant]
[ "def", "get_values_in_config", "(", "self", ",", "variant", ")", ":", "# type: (Kind) -> Dict[str, Any]", "return", "self", ".", "_config", "[", "variant", "]" ]
[ 389, 4 ]
[ 392, 36 ]
python
en
['en', 'en', 'en']
True
bs_progress_bar
(*args, **kwargs)
A Standard Bootstrap Progress Bar. http://getbootstrap.com/components/#progress param args (Array of Numbers: 0-100): Percent of Progress Bars param context (String): Adds 'progress-bar-{context} to the class attribute param contexts (Array of Strings): Cycles through contexts for stacked bars par...
A Standard Bootstrap Progress Bar.
def bs_progress_bar(*args, **kwargs): """A Standard Bootstrap Progress Bar. http://getbootstrap.com/components/#progress param args (Array of Numbers: 0-100): Percent of Progress Bars param context (String): Adds 'progress-bar-{context} to the class attribute param contexts (Array of Strings): Cyc...
[ "def", "bs_progress_bar", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "bars", "=", "[", "]", "contexts", "=", "kwargs", ".", "get", "(", "'contexts'", ",", "[", "''", ",", "'success'", ",", "'info'", ",", "'warning'", ",", "'danger'", "]", ...
[ 24, 0 ]
[ 58, 5 ]
python
en
['en', 'lb', 'en']
True
MultiRef.process
(self, body)
Process the specified soap envelope body and replace I{multiref} node references with the contents of the referenced node. @param body: A soap envelope body node. @type body: L{Element} @return: The processed I{body} @rtype: L{Element}
Process the specified soap envelope body and replace I{multiref} node references with the contents of the referenced node.
def process(self, body): """ Process the specified soap envelope body and replace I{multiref} node references with the contents of the referenced node. @param body: A soap envelope body node. @type body: L{Element} @return: The processed I{body} @rtype: L{Element}...
[ "def", "process", "(", "self", ",", "body", ")", ":", "self", ".", "nodes", "=", "[", "]", "self", ".", "catalog", "=", "{", "}", "self", ".", "build_catalog", "(", "body", ")", "self", ".", "update", "(", "body", ")", "body", ".", "children", "=...
[ 41, 4 ]
[ 55, 19 ]
python
en
['en', 'error', 'th']
False
MultiRef.update
(self, node)
Update the specified I{node} by replacing the I{multiref} references with the contents of the referenced nodes and remove the I{href} attribute. @param node: A node to update. @type node: L{Element} @return: The updated node @rtype: L{Element}
Update the specified I{node} by replacing the I{multiref} references with the contents of the referenced nodes and remove the I{href} attribute.
def update(self, node): """ Update the specified I{node} by replacing the I{multiref} references with the contents of the referenced nodes and remove the I{href} attribute. @param node: A node to update. @type node: L{Element} @return: The updated node @rtype: L{E...
[ "def", "update", "(", "self", ",", "node", ")", ":", "self", ".", "replace_references", "(", "node", ")", "for", "c", "in", "node", ".", "children", ":", "self", ".", "update", "(", "c", ")", "return", "node" ]
[ 57, 4 ]
[ 69, 19 ]
python
en
['en', 'error', 'th']
False
MultiRef.replace_references
(self, node)
Replacing the I{multiref} references with the contents of the referenced nodes and remove the I{href} attribute. Warning: since the I{ref} is not cloned, @param node: A node to update. @type node: L{Element}
Replacing the I{multiref} references with the contents of the referenced nodes and remove the I{href} attribute. Warning: since the I{ref} is not cloned,
def replace_references(self, node): """ Replacing the I{multiref} references with the contents of the referenced nodes and remove the I{href} attribute. Warning: since the I{ref} is not cloned, @param node: A node to update. @type node: L{Element} """ ...
[ "def", "replace_references", "(", "self", ",", "node", ")", ":", "href", "=", "node", ".", "getAttribute", "(", "'href'", ")", "if", "href", "is", "None", ":", "return", "id", "=", "href", ".", "getValue", "(", ")", "ref", "=", "self", ".", "catalog"...
[ 71, 4 ]
[ 92, 25 ]
python
en
['en', 'error', 'th']
False
MultiRef.build_catalog
(self, body)
Create the I{catalog} of multiref nodes by id and the list of non-multiref nodes. @param body: A soap envelope body node. @type body: L{Element}
Create the I{catalog} of multiref nodes by id and the list of non-multiref nodes.
def build_catalog(self, body): """ Create the I{catalog} of multiref nodes by id and the list of non-multiref nodes. @param body: A soap envelope body node. @type body: L{Element} """ for child in body.children: if self.soaproot(child): ...
[ "def", "build_catalog", "(", "self", ",", "body", ")", ":", "for", "child", "in", "body", ".", "children", ":", "if", "self", ".", "soaproot", "(", "child", ")", ":", "self", ".", "nodes", ".", "append", "(", "child", ")", "id", "=", "child", ".", ...
[ 94, 4 ]
[ 107, 37 ]
python
en
['en', 'error', 'th']
False
MultiRef.soaproot
(self, node)
Get whether the specified I{node} is a soap encoded root. This is determined by examining @soapenc:root='1'. The node is considered to be a root when the attribute is not specified. @param node: A node to evaluate. @type node: L{Element} @return: True if a soap e...
Get whether the specified I{node} is a soap encoded root. This is determined by examining
def soaproot(self, node): """ Get whether the specified I{node} is a soap encoded root. This is determined by examining @soapenc:root='1'. The node is considered to be a root when the attribute is not specified. @param node: A node to evaluate. @type node: L{Eleme...
[ "def", "soaproot", "(", "self", ",", "node", ")", ":", "root", "=", "node", ".", "getAttribute", "(", "'root'", ",", "ns", "=", "soapenc", ")", "if", "root", "is", "None", ":", "return", "True", "else", ":", "return", "(", "root", ".", "value", "==...
[ 109, 4 ]
[ 124, 40 ]
python
en
['en', 'error', 'th']
False
with_metaclass
(meta, *bases)
Create a base class with a metaclass.
Create a base class with a metaclass.
def with_metaclass(meta, *bases): # type: (Type[Any], Tuple[Type[Any], ...]) -> Any """ Create a base class with a metaclass. """ # This requires a bit of explanation: the basic idea is to make a dummy # metaclass for one level of class instantiation that replaces itself with # the actual me...
[ "def", "with_metaclass", "(", "meta", ",", "*", "bases", ")", ":", "# type: (Type[Any], Tuple[Type[Any], ...]) -> Any", "# This requires a bit of explanation: the basic idea is to make a dummy", "# metaclass for one level of class instantiation that replaces itself with", "# the actual metac...
[ 24, 0 ]
[ 37, 61 ]
python
en
['en', 'error', 'th']
False
tenant_quota_usages
(request, tenant_id=None, targets=None)
Get our quotas and construct our usage object. :param tenant_id: Target tenant ID. If no tenant_id is provided, a the request.user.project_id is assumed to be used. :param targets: A tuple of quota names to be retrieved. If unspecified, all quota and usage information is retrieved.
Get our quotas and construct our usage object.
def tenant_quota_usages(request, tenant_id=None, targets=None): """Get our quotas and construct our usage object. :param tenant_id: Target tenant ID. If no tenant_id is provided, a the request.user.project_id is assumed to be used. :param targets: A tuple of quota names to be retrieved. If ...
[ "def", "tenant_quota_usages", "(", "request", ",", "tenant_id", "=", "None", ",", "targets", "=", "None", ")", ":", "if", "not", "tenant_id", ":", "tenant_id", "=", "request", ".", "user", ".", "project_id", "disabled_quotas", "=", "get_disabled_quotas", "(", ...
[ 430, 0 ]
[ 452, 17 ]
python
en
['en', 'en', 'en']
True
enabled_quotas
(request)
Returns the list of quotas available minus those that are disabled
Returns the list of quotas available minus those that are disabled
def enabled_quotas(request): """Returns the list of quotas available minus those that are disabled""" return QUOTA_FIELDS - get_disabled_quotas(request)
[ "def", "enabled_quotas", "(", "request", ")", ":", "return", "QUOTA_FIELDS", "-", "get_disabled_quotas", "(", "request", ")" ]
[ 455, 0 ]
[ 457, 54 ]
python
en
['en', 'en', 'en']
True
QuotaUsage.add_quota
(self, quota)
Adds an internal tracking reference for the given quota.
Adds an internal tracking reference for the given quota.
def add_quota(self, quota): """Adds an internal tracking reference for the given quota.""" if quota.limit in (None, -1, float('inf')): # Handle "unlimited" quotas. self.usages[quota.name]['quota'] = float("inf") self.usages[quota.name]['available'] = float("inf") ...
[ "def", "add_quota", "(", "self", ",", "quota", ")", ":", "if", "quota", ".", "limit", "in", "(", "None", ",", "-", "1", ",", "float", "(", "'inf'", ")", ")", ":", "# Handle \"unlimited\" quotas.", "self", ".", "usages", "[", "quota", ".", "name", "]"...
[ 143, 4 ]
[ 150, 63 ]
python
en
['en', 'en', 'en']
True
QuotaUsage.tally
(self, name, value)
Adds to the "used" metric for the given quota.
Adds to the "used" metric for the given quota.
def tally(self, name, value): """Adds to the "used" metric for the given quota.""" value = value or 0 # Protection against None. # Start at 0 if this is the first value. if 'used' not in self.usages[name]: self.usages[name]['used'] = 0 # Increment our usage and updat...
[ "def", "tally", "(", "self", ",", "name", ",", "value", ")", ":", "value", "=", "value", "or", "0", "# Protection against None.", "# Start at 0 if this is the first value.", "if", "'used'", "not", "in", "self", ".", "usages", "[", "name", "]", ":", "self", "...
[ 152, 4 ]
[ 160, 35 ]
python
en
['en', 'en', 'en']
True
QuotaUsage.update_available
(self, name)
Updates the "available" metric for the given quota.
Updates the "available" metric for the given quota.
def update_available(self, name): """Updates the "available" metric for the given quota.""" quota = self.usages.get(name, {}).get('quota', float('inf')) available = quota - self.usages[name]['used'] if available < 0: available = 0 self.usages[name]['available'] = avai...
[ "def", "update_available", "(", "self", ",", "name", ")", ":", "quota", "=", "self", ".", "usages", ".", "get", "(", "name", ",", "{", "}", ")", ".", "get", "(", "'quota'", ",", "float", "(", "'inf'", ")", ")", "available", "=", "quota", "-", "se...
[ 162, 4 ]
[ 168, 50 ]
python
en
['en', 'en', 'en']
True
BaseFeature.data
(self)
To be overrode.
To be overrode.
def data(self): """To be overrode.""" raise NotImplemented
[ "def", "data", "(", "self", ")", ":", "raise", "NotImplemented" ]
[ 18, 4 ]
[ 20, 28 ]
python
en
['en', 'en', 'en']
True
BaseFeature.mapping
(self)
To be overrode.
To be overrode.
def mapping(self): """To be overrode.""" raise NotImplemented
[ "def", "mapping", "(", "self", ")", ":", "raise", "NotImplemented" ]
[ 22, 4 ]
[ 24, 28 ]
python
en
['en', 'en', 'en']
True
CategoricalFeature.__init__
(self, series, name, description, imputed_category, transformed=False, mapping=None)
Construct new CategoricalFeature object. Additionally create raw_mapping and mapped_series attributes. Args: series (pandas.Series): Series holding the data (copy) name (str): name of the Feature description (str): description of the Feature imputed_cate...
Construct new CategoricalFeature object.
def __init__(self, series, name, description, imputed_category, transformed=False, mapping=None): """Construct new CategoricalFeature object. Additionally create raw_mapping and mapped_series attributes. Args: series (pandas.Series): Series holding the data (copy) name ...
[ "def", "__init__", "(", "self", ",", "series", ",", "name", ",", "description", ",", "imputed_category", ",", "transformed", "=", "False", ",", "mapping", "=", "None", ")", ":", "self", ".", "series", "=", "series", ".", "copy", "(", ")", "self", ".", ...
[ 67, 4 ]
[ 91, 40 ]
python
en
['en', 'en', 'en']
True
CategoricalFeature.data
(self)
Return mapped_series property.
Return mapped_series property.
def data(self): """Return mapped_series property.""" return self.mapped_series
[ "def", "data", "(", "self", ")", ":", "return", "self", ".", "mapped_series" ]
[ 93, 4 ]
[ 95, 33 ]
python
en
['fr', 'en', 'en']
True
CategoricalFeature.original_data
(self)
Return original Series.
Return original Series.
def original_data(self): """Return original Series.""" return self.series
[ "def", "original_data", "(", "self", ")", ":", "return", "self", ".", "series" ]
[ 97, 4 ]
[ 99, 26 ]
python
en
['en', 'id', 'en']
True
CategoricalFeature.mapping
(self)
Return _descriptive_mapping attribute and if it's None, create it with _create_descriptive_mapping method.
Return _descriptive_mapping attribute and if it's None, create it with _create_descriptive_mapping method.
def mapping(self): """Return _descriptive_mapping attribute and if it's None, create it with _create_descriptive_mapping method.""" if not self._descriptive_mapping: self._descriptive_mapping = self._create_descriptive_mapping() return self._descriptive_mapping
[ "def", "mapping", "(", "self", ")", ":", "if", "not", "self", ".", "_descriptive_mapping", ":", "self", ".", "_descriptive_mapping", "=", "self", ".", "_create_descriptive_mapping", "(", ")", "return", "self", ".", "_descriptive_mapping" ]
[ 101, 4 ]
[ 106, 40 ]
python
en
['en', 'en', 'en']
True
CategoricalFeature._create_mapped_series
(self)
Return series property with it's content replaced with raw_mapping dictionary.
Return series property with it's content replaced with raw_mapping dictionary.
def _create_mapped_series(self): """Return series property with it's content replaced with raw_mapping dictionary.""" return self.series.replace(self.raw_mapping)
[ "def", "_create_mapped_series", "(", "self", ")", ":", "return", "self", ".", "series", ".", "replace", "(", "self", ".", "raw_mapping", ")" ]
[ 108, 4 ]
[ 110, 52 ]
python
en
['en', 'en', 'en']
True
CategoricalFeature._create_raw_mapping
(self)
Return dictionary of 'unique value': number pairs. Replace every categorical value with a number starting from 1 (sorted alphabetically). Starting with 1 to be consistent with "count" obtained with .describe() methods on dataframes. Returns: dict: 'unique value': number pairs dict....
Return dictionary of 'unique value': number pairs.
def _create_raw_mapping(self): """Return dictionary of 'unique value': number pairs. Replace every categorical value with a number starting from 1 (sorted alphabetically). Starting with 1 to be consistent with "count" obtained with .describe() methods on dataframes. Returns: ...
[ "def", "_create_raw_mapping", "(", "self", ")", ":", "values", "=", "sorted", "(", "self", ".", "series", ".", "unique", "(", ")", ",", "key", "=", "str", ")", "mapped", "=", "{", "value", ":", "number", "for", "number", ",", "value", "in", "enumerat...
[ 112, 4 ]
[ 123, 21 ]
python
en
['en', 'la', 'en']
True
CategoricalFeature._create_descriptive_mapping
(self)
Create and return dictionary mapping for unique values present in series. Key is the "new" value provided with enumerating unique values in raw_mapping. Value is either the description of the category taken from original descriptions or the original value (if description dict is None). Returns...
Create and return dictionary mapping for unique values present in series.
def _create_descriptive_mapping(self): """Create and return dictionary mapping for unique values present in series. Key is the "new" value provided with enumerating unique values in raw_mapping. Value is either the description of the category taken from original descriptions or the original val...
[ "def", "_create_descriptive_mapping", "(", "self", ")", ":", "if", "self", ".", "original_mapping", ":", "mapp", "=", "{", "}", "for", "key", ",", "item", "in", "self", ".", "raw_mapping", ".", "items", "(", ")", ":", "new_key", "=", "item", "# try/excep...
[ 125, 4 ]
[ 153, 19 ]
python
en
['en', 'en', 'en']
True
NumericalFeature.__init__
(self, series, name, description, imputed_category, transformed=False)
Construct new NumericalFeature object. Args: series (pandas.Series): Series holding the data (copy) name (str): name of the Feature description (str): description of the Feature imputed_category (bool): flag indicating if the category of the Feature was provided ...
Construct new NumericalFeature object.
def __init__(self, series, name, description, imputed_category, transformed=False): """Construct new NumericalFeature object. Args: series (pandas.Series): Series holding the data (copy) name (str): name of the Feature description (str): description of the Feature ...
[ "def", "__init__", "(", "self", ",", "series", ",", "name", ",", "description", ",", "imputed_category", ",", "transformed", "=", "False", ")", ":", "self", ".", "series", "=", "series", ".", "copy", "(", ")", "self", ".", "name", "=", "name", "self", ...
[ 175, 4 ]
[ 189, 38 ]
python
en
['en', 'en', 'en']
True
NumericalFeature.data
(self)
Return series attribute.
Return series attribute.
def data(self): """Return series attribute.""" return self.series
[ "def", "data", "(", "self", ")", ":", "return", "self", ".", "series" ]
[ 191, 4 ]
[ 193, 26 ]
python
en
['en', 'af', 'en']
True
NumericalFeature.mapping
(self)
Return None, as NumericalFeature has no mapping.
Return None, as NumericalFeature has no mapping.
def mapping(self): """Return None, as NumericalFeature has no mapping.""" return None
[ "def", "mapping", "(", "self", ")", ":", "return", "None" ]
[ 195, 4 ]
[ 197, 19 ]
python
en
['en', 'en', 'en']
True
Features.__init__
(self, X, y, descriptor=None, transformed_features=None)
Construct Features object from passed arguments. Automatically analyze provided DataFrame (X + y) and assess their types. Args: X (pandas.DataFrame): DataFrame of features (columns), from which Models will learn y (pandas.Series): Series of target variable data desc...
Construct Features object from passed arguments.
def __init__(self, X, y, descriptor=None, transformed_features=None): """Construct Features object from passed arguments. Automatically analyze provided DataFrame (X + y) and assess their types. Args: X (pandas.DataFrame): DataFrame of features (columns), from which Models will lea...
[ "def", "__init__", "(", "self", ",", "X", ",", "y", ",", "descriptor", "=", "None", ",", "transformed_features", "=", "None", ")", ":", "self", ".", "original_dataframe", "=", "pd", ".", "concat", "(", "[", "X", ",", "y", "]", ",", "axis", "=", "1"...
[ 234, 4 ]
[ 266, 59 ]
python
en
['en', 'en', 'en']
True
Features._analyze_features
(self, descriptor)
Analyze original_dataframe attribute and assess type of each column (Numerical or Categorical). Every column present in the original_dataframe will be checked and appropriate FeatureClass will be created for it. Every FeatureClass will also have mapping and description attributes specific to them. ...
Analyze original_dataframe attribute and assess type of each column (Numerical or Categorical).
def _analyze_features(self, descriptor): """Analyze original_dataframe attribute and assess type of each column (Numerical or Categorical). Every column present in the original_dataframe will be checked and appropriate FeatureClass will be created for it. Every FeatureClass will also have mappi...
[ "def", "_analyze_features", "(", "self", ",", "descriptor", ")", ":", "features", "=", "{", "}", "for", "column", "in", "self", ".", "original_dataframe", ".", "columns", ":", "try", ":", "description", "=", "None", "category", "=", "None", "mapping", "=",...
[ 268, 4 ]
[ 354, 23 ]
python
en
['en', 'en', 'en']
True
Features._impute_column_type
(self, series)
Impute column type based on the data included in provided series. Args: series (pandas.Series): Series which column type is checked Returns: str: one of _categorical, _numerical_ or _date str attributes Raises: Exception: raised when all conversions fail ...
Impute column type based on the data included in provided series.
def _impute_column_type(self, series): """Impute column type based on the data included in provided series. Args: series (pandas.Series): Series which column type is checked Returns: str: one of _categorical, _numerical_ or _date str attributes Raises: ...
[ "def", "_impute_column_type", "(", "self", ",", "series", ")", ":", "if", "series", ".", "dtype", "==", "bool", ":", "return", "self", ".", "_categorical", "else", ":", "try", ":", "_", "=", "series", ".", "astype", "(", "\"float64\"", ")", "if", "len"...
[ 356, 4 ]
[ 382, 21 ]
python
en
['en', 'en', 'en']
True
Features.features
(self, drop_target=False, exclude_transformed=False)
Return list of features names present in _all_features attribute. If _all_features attribute is None, feature list is first created and assigned to that attribute. Args: drop_target (bool, optional): flag indicating if returned list should exclude target name or not, defaults ...
Return list of features names present in _all_features attribute.
def features(self, drop_target=False, exclude_transformed=False): """Return list of features names present in _all_features attribute. If _all_features attribute is None, feature list is first created and assigned to that attribute. Args: drop_target (bool, optional): flag indicati...
[ "def", "features", "(", "self", ",", "drop_target", "=", "False", ",", "exclude_transformed", "=", "False", ")", ":", "if", "not", "self", ".", "_all_features", ":", "self", ".", "_all_features", "=", "self", ".", "_create_features", "(", ")", "features", ...
[ 384, 4 ]
[ 408, 23 ]
python
en
['en', 'en', 'en']
True
Features.categorical_features
(self, drop_target=False, exclude_transformed=False)
Return list of categorical features names present in _categorical_features attribute. If _categorical_features attribute is None, categorical feature list is first created and assigned to that attribute. Args: drop_target (bool, optional): flag indicating if returned list should ex...
Return list of categorical features names present in _categorical_features attribute.
def categorical_features(self, drop_target=False, exclude_transformed=False): """Return list of categorical features names present in _categorical_features attribute. If _categorical_features attribute is None, categorical feature list is first created and assigned to that attribute. A...
[ "def", "categorical_features", "(", "self", ",", "drop_target", "=", "False", ",", "exclude_transformed", "=", "False", ")", ":", "if", "not", "self", ".", "_categorical_features", ":", "self", ".", "_categorical_features", "=", "self", ".", "_create_categorical_f...
[ 410, 4 ]
[ 437, 35 ]
python
en
['en', 'en', 'en']
True
Features.numerical_features
(self, drop_target=False, exclude_transformed=False)
Return list of numerical features names present in _numerical_features attribute. If _numerical_features attribute is None, numerical feature list is first created and assigned to that attribute. Args: drop_target (bool, optional): flag indicating if returned list should exclude ta...
Return list of numerical features names present in _numerical_features attribute.
def numerical_features(self, drop_target=False, exclude_transformed=False): """Return list of numerical features names present in _numerical_features attribute. If _numerical_features attribute is None, numerical feature list is first created and assigned to that attribute. Args: ...
[ "def", "numerical_features", "(", "self", ",", "drop_target", "=", "False", ",", "exclude_transformed", "=", "False", ")", ":", "if", "not", "self", ".", "_numerical_features", ":", "self", ".", "_numerical_features", "=", "self", ".", "_create_numerical_features"...
[ 439, 4 ]
[ 464, 33 ]
python
en
['en', 'en', 'en']
True
Features.raw_data
(self, drop_target=False, exclude_transformed=False)
Return pandas DataFrame present in _raw_dataframe attribute. If _raw_dataframe attribute is None, raw DataFrame is first created and assigned to that attribute. Args: drop_target (bool, optional): flag indicating if returned DataFrame should exclude target from columns, def...
Return pandas DataFrame present in _raw_dataframe attribute.
def raw_data(self, drop_target=False, exclude_transformed=False): """Return pandas DataFrame present in _raw_dataframe attribute. If _raw_dataframe attribute is None, raw DataFrame is first created and assigned to that attribute. Args: drop_target (bool, optional): flag indicating ...
[ "def", "raw_data", "(", "self", ",", "drop_target", "=", "False", ",", "exclude_transformed", "=", "False", ")", ":", "if", "self", ".", "_raw_dataframe", "is", "None", ":", "self", ".", "_raw_dataframe", "=", "self", ".", "_create_raw_dataframe", "(", ")", ...
[ 466, 4 ]
[ 490, 21 ]
python
en
['en', 'id', 'en']
True
Features.data
(self, drop_target=False, exclude_transformed=False)
Return pandas DataFrame present in _mapped_dataframe attribute. If _mapped_dataframe attribute is None, mapped DataFrame is first created and assigned to that attribute. Args: drop_target (bool, optional): flag indicating if returned DataFrame should exclude target from columns, ...
Return pandas DataFrame present in _mapped_dataframe attribute.
def data(self, drop_target=False, exclude_transformed=False): """Return pandas DataFrame present in _mapped_dataframe attribute. If _mapped_dataframe attribute is None, mapped DataFrame is first created and assigned to that attribute. Args: drop_target (bool, optional): flag indica...
[ "def", "data", "(", "self", ",", "drop_target", "=", "False", ",", "exclude_transformed", "=", "False", ")", ":", "if", "self", ".", "_mapped_dataframe", "is", "None", ":", "self", ".", "_mapped_dataframe", "=", "self", ".", "_create_mapped_dataframe", "(", ...
[ 492, 4 ]
[ 517, 24 ]
python
en
['es', 'no', 'en']
False
Features.mapping
(self)
Return _mapping attribute and if it's None, create it. Returns: dict: 'feature name': mapping dict pairs
Return _mapping attribute and if it's None, create it.
def mapping(self): """Return _mapping attribute and if it's None, create it. Returns: dict: 'feature name': mapping dict pairs """ if self._mapping is None: self._mapping = self._create_mapping() return self._mapping
[ "def", "mapping", "(", "self", ")", ":", "if", "self", ".", "_mapping", "is", "None", ":", "self", ".", "_mapping", "=", "self", ".", "_create_mapping", "(", ")", "return", "self", ".", "_mapping" ]
[ 519, 4 ]
[ 527, 28 ]
python
en
['en', 'en', 'en']
True
Features.descriptions
(self)
Return _descriptions attribute and if it's None, create it. Returns: dict: 'feature name': description pairs
Return _descriptions attribute and if it's None, create it.
def descriptions(self): """Return _descriptions attribute and if it's None, create it. Returns: dict: 'feature name': description pairs """ if self._descriptions is None: self._descriptions = self._create_descriptions() return self._descriptions
[ "def", "descriptions", "(", "self", ")", ":", "if", "self", ".", "_descriptions", "is", "None", ":", "self", ".", "_descriptions", "=", "self", ".", "_create_descriptions", "(", ")", "return", "self", ".", "_descriptions" ]
[ 529, 4 ]
[ 537, 33 ]
python
en
['en', 'it', 'en']
True
Features.unused_features
(self)
Return _unused_columns attribute.
Return _unused_columns attribute.
def unused_features(self): """Return _unused_columns attribute.""" return self._unused_columns
[ "def", "unused_features", "(", "self", ")", ":", "return", "self", ".", "_unused_columns" ]
[ 539, 4 ]
[ 541, 35 ]
python
en
['en', 'et', 'en']
True
Features._create_features
(self)
Return list of names as taken from name attribute of every FeatureClass present in _features. Returns: list: list of features names
Return list of names as taken from name attribute of every FeatureClass present in _features.
def _create_features(self): """Return list of names as taken from name attribute of every FeatureClass present in _features. Returns: list: list of features names """ output = [] for feature in self._features.values(): output.append(feature.name) ...
[ "def", "_create_features", "(", "self", ")", ":", "output", "=", "[", "]", "for", "feature", "in", "self", ".", "_features", ".", "values", "(", ")", ":", "output", ".", "append", "(", "feature", ".", "name", ")", "output", "=", "sort_strings", "(", ...
[ 543, 4 ]
[ 553, 21 ]
python
en
['en', 'en', 'en']
True
Features._create_categorical_features
(self)
Return list of names of features (name attribute) if a given FeatureClass is an instance of CategoricalFeature. Returns: list: list of categorical features names
Return list of names of features (name attribute) if a given FeatureClass is an instance of CategoricalFeature.
def _create_categorical_features(self): """Return list of names of features (name attribute) if a given FeatureClass is an instance of CategoricalFeature. Returns: list: list of categorical features names """ output = [] for feature in self._features.values()...
[ "def", "_create_categorical_features", "(", "self", ")", ":", "output", "=", "[", "]", "for", "feature", "in", "self", ".", "_features", ".", "values", "(", ")", ":", "if", "isinstance", "(", "feature", ",", "CategoricalFeature", ")", ":", "output", ".", ...
[ 555, 4 ]
[ 567, 21 ]
python
en
['en', 'en', 'en']
True
Features._create_numerical_features
(self)
Return list of names of features (name attribute) if a given FeatureClass is an instance of NumericalFeature. Returns: list: list of numerical features names
Return list of names of features (name attribute) if a given FeatureClass is an instance of NumericalFeature.
def _create_numerical_features(self): """Return list of names of features (name attribute) if a given FeatureClass is an instance of NumericalFeature. Returns: list: list of numerical features names """ output = [] for feature in self._features.values(): ...
[ "def", "_create_numerical_features", "(", "self", ")", ":", "output", "=", "[", "]", "for", "feature", "in", "self", ".", "_features", ".", "values", "(", ")", ":", "if", "isinstance", "(", "feature", ",", "NumericalFeature", ")", ":", "output", ".", "ap...
[ 569, 4 ]
[ 581, 21 ]
python
en
['en', 'en', 'en']
True
Features._create_mapped_dataframe
(self)
Return pandas.Dataframe made from single mapped series (where appropriate) of every FeatureClass (data method). Returns: pandas.DataFrame: dataframe consisting of mapped series
Return pandas.Dataframe made from single mapped series (where appropriate) of every FeatureClass (data method).
def _create_mapped_dataframe(self): """Return pandas.Dataframe made from single mapped series (where appropriate) of every FeatureClass (data method). Returns: pandas.DataFrame: dataframe consisting of mapped series """ return pd.concat([self._features[feature].data(...
[ "def", "_create_mapped_dataframe", "(", "self", ")", ":", "return", "pd", ".", "concat", "(", "[", "self", ".", "_features", "[", "feature", "]", ".", "data", "(", ")", "for", "feature", "in", "self", ".", "_features", "]", ",", "axis", "=", "1", ")"...
[ 583, 4 ]
[ 590, 96 ]
python
en
['en', 'en', 'en']
True
Features._create_raw_dataframe
(self)
Return pandas.DataFrame made from original series data of every FeatureClass. Distinction is needed as NumericalFeature defines only data method, whereas CategoricalFeature has both data and original_data methods. Returns: pandas.DataFrame: original DataFrame constructed from serie...
Return pandas.DataFrame made from original series data of every FeatureClass.
def _create_raw_dataframe(self): """Return pandas.DataFrame made from original series data of every FeatureClass. Distinction is needed as NumericalFeature defines only data method, whereas CategoricalFeature has both data and original_data methods. Returns: pandas.DataFram...
[ "def", "_create_raw_dataframe", "(", "self", ")", ":", "# raw data needs to call .original_data(), as the default function returns already mapped data", "numeric", "=", "[", "feature", ".", "data", "(", ")", "for", "feature", "in", "self", ".", "_features", ".", "values",...
[ 592, 4 ]
[ 607, 17 ]
python
en
['en', 'lb', 'en']
True
Features._create_mapping
(self)
Create dictionary of 'feature name': mapping dict pairs, where mapping dict is taken from mapping method of every FeatureClass. Returns: dict: 'feature name': mapping dict pairs
Create dictionary of 'feature name': mapping dict pairs, where mapping dict is taken from mapping method of every FeatureClass.
def _create_mapping(self): """Create dictionary of 'feature name': mapping dict pairs, where mapping dict is taken from mapping method of every FeatureClass. Returns: dict: 'feature name': mapping dict pairs """ output = {} for feature in self.features(): ...
[ "def", "_create_mapping", "(", "self", ")", ":", "output", "=", "{", "}", "for", "feature", "in", "self", ".", "features", "(", ")", ":", "output", "[", "feature", "]", "=", "self", ".", "_features", "[", "feature", "]", ".", "mapping", "(", ")", "...
[ 609, 4 ]
[ 619, 21 ]
python
en
['en', 'en', 'en']
True
Features._create_descriptions
(self)
Create dictionary of 'feature name': description pairs, where description is taken from description attribute of every FeatureClass. Returns: dict: 'feature name': description pairs
Create dictionary of 'feature name': description pairs, where description is taken from description attribute of every FeatureClass.
def _create_descriptions(self): """Create dictionary of 'feature name': description pairs, where description is taken from description attribute of every FeatureClass. Returns: dict: 'feature name': description pairs """ output = {} for feature in self.featur...
[ "def", "_create_descriptions", "(", "self", ")", ":", "output", "=", "{", "}", "for", "feature", "in", "self", ".", "features", "(", ")", ":", "output", "[", "feature", "]", "=", "self", ".", "_features", "[", "feature", "]", ".", "description", "retur...
[ 621, 4 ]
[ 631, 21 ]
python
en
['en', 'en', 'en']
True
Features.__getitem__
(self, arg)
Return arg item from _features attribute dictionary. Args: arg (str, Hashable): str representing the name of the feature Returns: Feature: FeatureClass present in _features attribute dictionary Raises: KeyError: when arg is not in _features
Return arg item from _features attribute dictionary.
def __getitem__(self, arg): """Return arg item from _features attribute dictionary. Args: arg (str, Hashable): str representing the name of the feature Returns: Feature: FeatureClass present in _features attribute dictionary Raises: KeyError: when a...
[ "def", "__getitem__", "(", "self", ",", "arg", ")", ":", "if", "arg", "not", "in", "self", ".", "_features", ":", "raise", "KeyError", "return", "self", ".", "_features", "[", "arg", "]" ]
[ 633, 4 ]
[ 648, 34 ]
python
en
['en', 'en', 'en']
True
_cf_data_from_bytes
(bytestring)
Given a bytestring, create a CFData object from it. This CFData object must be CFReleased by the caller.
Given a bytestring, create a CFData object from it. This CFData object must be CFReleased by the caller.
def _cf_data_from_bytes(bytestring): """ Given a bytestring, create a CFData object from it. This CFData object must be CFReleased by the caller. """ return CoreFoundation.CFDataCreate( CoreFoundation.kCFAllocatorDefault, bytestring, len(bytestring) )
[ "def", "_cf_data_from_bytes", "(", "bytestring", ")", ":", "return", "CoreFoundation", ".", "CFDataCreate", "(", "CoreFoundation", ".", "kCFAllocatorDefault", ",", "bytestring", ",", "len", "(", "bytestring", ")", ")" ]
[ 26, 0 ]
[ 33, 5 ]
python
en
['en', 'error', 'th']
False
_cf_dictionary_from_tuples
(tuples)
Given a list of Python tuples, create an associated CFDictionary.
Given a list of Python tuples, create an associated CFDictionary.
def _cf_dictionary_from_tuples(tuples): """ Given a list of Python tuples, create an associated CFDictionary. """ dictionary_size = len(tuples) # We need to get the dictionary keys and values out in the same order. keys = (t[0] for t in tuples) values = (t[1] for t in tuples) cf_keys = ...
[ "def", "_cf_dictionary_from_tuples", "(", "tuples", ")", ":", "dictionary_size", "=", "len", "(", "tuples", ")", "# We need to get the dictionary keys and values out in the same order.", "keys", "=", "(", "t", "[", "0", "]", "for", "t", "in", "tuples", ")", "values"...
[ 36, 0 ]
[ 55, 5 ]
python
en
['en', 'error', 'th']
False
_cf_string_to_unicode
(value)
Creates a Unicode string from a CFString object. Used entirely for error reporting. Yes, it annoys me quite a lot that this function is this complex.
Creates a Unicode string from a CFString object. Used entirely for error reporting.
def _cf_string_to_unicode(value): """ Creates a Unicode string from a CFString object. Used entirely for error reporting. Yes, it annoys me quite a lot that this function is this complex. """ value_as_void_p = ctypes.cast(value, ctypes.POINTER(ctypes.c_void_p)) string = CoreFoundation.CFSt...
[ "def", "_cf_string_to_unicode", "(", "value", ")", ":", "value_as_void_p", "=", "ctypes", ".", "cast", "(", "value", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_void_p", ")", ")", "string", "=", "CoreFoundation", ".", "CFStringGetCStringPtr", "(", ...
[ 58, 0 ]
[ 80, 17 ]
python
en
['en', 'error', 'th']
False
_assert_no_error
(error, exception_class=None)
Checks the return code and throws an exception if there is an error to report
Checks the return code and throws an exception if there is an error to report
def _assert_no_error(error, exception_class=None): """ Checks the return code and throws an exception if there is an error to report """ if error == 0: return cf_error_string = Security.SecCopyErrorMessageString(error, None) output = _cf_string_to_unicode(cf_error_string) CoreFo...
[ "def", "_assert_no_error", "(", "error", ",", "exception_class", "=", "None", ")", ":", "if", "error", "==", "0", ":", "return", "cf_error_string", "=", "Security", ".", "SecCopyErrorMessageString", "(", "error", ",", "None", ")", "output", "=", "_cf_string_to...
[ 83, 0 ]
[ 101, 33 ]
python
en
['en', 'error', 'th']
False
_cert_array_from_pem
(pem_bundle)
Given a bundle of certs in PEM format, turns them into a CFArray of certs that can be used to validate a cert chain.
Given a bundle of certs in PEM format, turns them into a CFArray of certs that can be used to validate a cert chain.
def _cert_array_from_pem(pem_bundle): """ Given a bundle of certs in PEM format, turns them into a CFArray of certs that can be used to validate a cert chain. """ # Normalize the PEM bundle's line endings. pem_bundle = pem_bundle.replace(b"\r\n", b"\n") der_certs = [ base64.b64decod...
[ "def", "_cert_array_from_pem", "(", "pem_bundle", ")", ":", "# Normalize the PEM bundle's line endings.", "pem_bundle", "=", "pem_bundle", ".", "replace", "(", "b\"\\r\\n\"", ",", "b\"\\n\"", ")", "der_certs", "=", "[", "base64", ".", "b64decode", "(", "match", ".",...
[ 104, 0 ]
[ 146, 21 ]
python
en
['en', 'error', 'th']
False
_is_cert
(item)
Returns True if a given CFTypeRef is a certificate.
Returns True if a given CFTypeRef is a certificate.
def _is_cert(item): """ Returns True if a given CFTypeRef is a certificate. """ expected = Security.SecCertificateGetTypeID() return CoreFoundation.CFGetTypeID(item) == expected
[ "def", "_is_cert", "(", "item", ")", ":", "expected", "=", "Security", ".", "SecCertificateGetTypeID", "(", ")", "return", "CoreFoundation", ".", "CFGetTypeID", "(", "item", ")", "==", "expected" ]
[ 149, 0 ]
[ 154, 55 ]
python
en
['en', 'error', 'th']
False
_is_identity
(item)
Returns True if a given CFTypeRef is an identity.
Returns True if a given CFTypeRef is an identity.
def _is_identity(item): """ Returns True if a given CFTypeRef is an identity. """ expected = Security.SecIdentityGetTypeID() return CoreFoundation.CFGetTypeID(item) == expected
[ "def", "_is_identity", "(", "item", ")", ":", "expected", "=", "Security", ".", "SecIdentityGetTypeID", "(", ")", "return", "CoreFoundation", ".", "CFGetTypeID", "(", "item", ")", "==", "expected" ]
[ 157, 0 ]
[ 162, 55 ]
python
en
['en', 'error', 'th']
False
_temporary_keychain
()
This function creates a temporary Mac keychain that we can use to work with credentials. This keychain uses a one-time password and a temporary file to store the data. We expect to have one keychain per socket. The returned SecKeychainRef must be freed by the caller, including calling SecKeychainDe...
This function creates a temporary Mac keychain that we can use to work with credentials. This keychain uses a one-time password and a temporary file to store the data. We expect to have one keychain per socket. The returned SecKeychainRef must be freed by the caller, including calling SecKeychainDe...
def _temporary_keychain(): """ This function creates a temporary Mac keychain that we can use to work with credentials. This keychain uses a one-time password and a temporary file to store the data. We expect to have one keychain per socket. The returned SecKeychainRef must be freed by the caller, i...
[ "def", "_temporary_keychain", "(", ")", ":", "# Unfortunately, SecKeychainCreate requires a path to a keychain. This", "# means we cannot use mkstemp to use a generic temporary file. Instead,", "# we're going to create a temporary directory and a filename to use there.", "# This filename will be 8 r...
[ 165, 0 ]
[ 197, 34 ]
python
en
['en', 'error', 'th']
False
_load_items_from_file
(keychain, path)
Given a single file, loads all the trust objects from it into arrays and the keychain. Returns a tuple of lists: the first list is a list of identities, the second a list of certs.
Given a single file, loads all the trust objects from it into arrays and the keychain. Returns a tuple of lists: the first list is a list of identities, the second a list of certs.
def _load_items_from_file(keychain, path): """ Given a single file, loads all the trust objects from it into arrays and the keychain. Returns a tuple of lists: the first list is a list of identities, the second a list of certs. """ certificates = [] identities = [] result_array = Non...
[ "def", "_load_items_from_file", "(", "keychain", ",", "path", ")", ":", "certificates", "=", "[", "]", "identities", "=", "[", "]", "result_array", "=", "None", "with", "open", "(", "path", ",", "\"rb\"", ")", "as", "f", ":", "raw_filedata", "=", "f", ...
[ 200, 0 ]
[ 252, 37 ]
python
en
['en', 'error', 'th']
False
_load_client_cert_chain
(keychain, *paths)
Load certificates and maybe keys from a number of files. Has the end goal of returning a CFArray containing one SecIdentityRef, and then zero or more SecCertificateRef objects, suitable for use as a client certificate trust chain.
Load certificates and maybe keys from a number of files. Has the end goal of returning a CFArray containing one SecIdentityRef, and then zero or more SecCertificateRef objects, suitable for use as a client certificate trust chain.
def _load_client_cert_chain(keychain, *paths): """ Load certificates and maybe keys from a number of files. Has the end goal of returning a CFArray containing one SecIdentityRef, and then zero or more SecCertificateRef objects, suitable for use as a client certificate trust chain. """ # Ok, ...
[ "def", "_load_client_cert_chain", "(", "keychain", ",", "*", "paths", ")", ":", "# Ok, the strategy.", "#", "# This relies on knowing that macOS will not give you a SecIdentityRef", "# unless you have imported a key into a keychain. This is a somewhat", "# artificial limitation of macOS (f...
[ 255, 0 ]
[ 327, 41 ]
python
en
['en', 'error', 'th']
False
_fixup_find_links
(find_links)
Ensure find-links option end-up being a list of strings.
Ensure find-links option end-up being a list of strings.
def _fixup_find_links(find_links): """Ensure find-links option end-up being a list of strings.""" if isinstance(find_links, str): return find_links.split() assert isinstance(find_links, (tuple, list)) return find_links
[ "def", "_fixup_find_links", "(", "find_links", ")", ":", "if", "isinstance", "(", "find_links", ",", "str", ")", ":", "return", "find_links", ".", "split", "(", ")", "assert", "isinstance", "(", "find_links", ",", "(", "tuple", ",", "list", ")", ")", "re...
[ 13, 0 ]
[ 18, 21 ]
python
en
['en', 'en', 'en']
True
_legacy_fetch_build_egg
(dist, req)
Fetch an egg needed for building. Legacy path using EasyInstall.
Fetch an egg needed for building.
def _legacy_fetch_build_egg(dist, req): """Fetch an egg needed for building. Legacy path using EasyInstall. """ tmp_dist = dist.__class__({'script_args': ['easy_install']}) opts = tmp_dist.get_option_dict('easy_install') opts.clear() opts.update( (k, v) for k, v in dist.get_...
[ "def", "_legacy_fetch_build_egg", "(", "dist", ",", "req", ")", ":", "tmp_dist", "=", "dist", ".", "__class__", "(", "{", "'script_args'", ":", "[", "'easy_install'", "]", "}", ")", "opts", "=", "tmp_dist", ".", "get_option_dict", "(", "'easy_install'", ")",...
[ 21, 0 ]
[ 50, 32 ]
python
en
['en', 'en', 'en']
True
fetch_build_egg
(dist, req)
Fetch an egg needed for building. Use pip/wheel to fetch/build a wheel.
Fetch an egg needed for building.
def fetch_build_egg(dist, req): """Fetch an egg needed for building. Use pip/wheel to fetch/build a wheel.""" # Check pip is available. try: pkg_resources.get_distribution('pip') except pkg_resources.DistributionNotFound: dist.announce( 'WARNING: The pip package is not a...
[ "def", "fetch_build_egg", "(", "dist", ",", "req", ")", ":", "# Check pip is available.", "try", ":", "pkg_resources", ".", "get_distribution", "(", "'pip'", ")", "except", "pkg_resources", ".", "DistributionNotFound", ":", "dist", ".", "announce", "(", "'WARNING:...
[ 53, 0 ]
[ 135, 19 ]
python
en
['en', 'en', 'en']
True
strip_marker
(req)
Return a new requirement without the environment marker to avoid calling pip with something like `babel; extra == "i18n"`, which would always be ignored.
Return a new requirement without the environment marker to avoid calling pip with something like `babel; extra == "i18n"`, which would always be ignored.
def strip_marker(req): """ Return a new requirement without the environment marker to avoid calling pip with something like `babel; extra == "i18n"`, which would always be ignored. """ # create a copy to avoid mutating the input req = pkg_resources.Requirement.parse(str(req)) req.marker ...
[ "def", "strip_marker", "(", "req", ")", ":", "# create a copy to avoid mutating the input", "req", "=", "pkg_resources", ".", "Requirement", ".", "parse", "(", "str", "(", "req", ")", ")", "req", ".", "marker", "=", "None", "return", "req" ]
[ 138, 0 ]
[ 147, 14 ]
python
en
['en', 'error', 'th']
False
BotTest.test_bot_add_subscription
(self)
Calling POST /json/users/me/subscriptions should successfully add streams, and a stream to the list of subscriptions and confirm the right number of events are generated. When 'principals' has a bot, no notification message event or invitation email is sent when add_subs...
Calling POST /json/users/me/subscriptions should successfully add streams, and a stream to the list of subscriptions and confirm the right number of events are generated. When 'principals' has a bot, no notification message event or invitation email is sent when add_subs...
def test_bot_add_subscription(self) -> None: """ Calling POST /json/users/me/subscriptions should successfully add streams, and a stream to the list of subscriptions and confirm the right number of events are generated. When 'principals' has a bot, no notification message...
[ "def", "test_bot_add_subscription", "(", "self", ")", "->", "None", ":", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "iago", "=", "self", ".", "example_user", "(", "\"iago\"", ")", "self", ".", "login_user", "(", "hamlet", ")", "# N...
[ 375, 4 ]
[ 420, 45 ]
python
en
['en', 'error', 'th']
False
BotTest.test_deactivate_bogus_bot
(self)
Deleting a bogus bot will succeed silently.
Deleting a bogus bot will succeed silently.
def test_deactivate_bogus_bot(self) -> None: """Deleting a bogus bot will succeed silently.""" self.login("hamlet") self.assert_num_bots_equal(0) self.create_bot() self.assert_num_bots_equal(1) invalid_user_id = 1000 result = self.client_delete(f"/json/bots/{inval...
[ "def", "test_deactivate_bogus_bot", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "self", ".", "assert_num_bots_equal", "(", "0", ")", "self", ".", "create_bot", "(", ")", "self", ".", "assert_num_bots_equal", "(", "1", ...
[ 576, 4 ]
[ 585, 37 ]
python
en
['en', 'en', 'en']
True
BotTest.test_bot_deactivation_attacks
(self)
You cannot deactivate somebody else's bot.
You cannot deactivate somebody else's bot.
def test_bot_deactivation_attacks(self) -> None: """You cannot deactivate somebody else's bot.""" self.login("hamlet") self.assert_num_bots_equal(0) self.create_bot() self.assert_num_bots_equal(1) # Have Othello try to deactivate both Hamlet and # Hamlet's bot. ...
[ "def", "test_bot_deactivation_attacks", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "self", ".", "assert_num_bots_equal", "(", "0", ")", "self", ".", "create_bot", "(", ")", "self", ".", "assert_num_bots_equal", "(", "1...
[ 636, 4 ]
[ 662, 37 ]
python
en
['en', 'en', 'en']
True
BotTest.test_patch_bogus_bot
(self)
Deleting a bogus bot will succeed silently.
Deleting a bogus bot will succeed silently.
def test_patch_bogus_bot(self) -> None: """Deleting a bogus bot will succeed silently.""" self.login("hamlet") self.create_bot() bot_info = { "full_name": "Fred", } invalid_user_id = 1000 result = self.client_patch(f"/json/bots/{invalid_user_id}", bot_...
[ "def", "test_patch_bogus_bot", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "self", ".", "create_bot", "(", ")", "bot_info", "=", "{", "\"full_name\"", ":", "\"Fred\"", ",", "}", "invalid_user_id", "=", "1000", "result...
[ 1388, 4 ]
[ 1398, 37 ]
python
en
['en', 'en', 'en']
True
OptionsSpecParser.get_section_type
(line)
Example section header: [TableOptions/BlockBasedTable "default"] Here ConfigurationOptimizer returned would be 'TableOptions.BlockBasedTable'
Example section header: [TableOptions/BlockBasedTable "default"] Here ConfigurationOptimizer returned would be 'TableOptions.BlockBasedTable'
def get_section_type(line): ''' Example section header: [TableOptions/BlockBasedTable "default"] Here ConfigurationOptimizer returned would be 'TableOptions.BlockBasedTable' ''' section_path = line.strip()[1:-1].split()[0] section_type = '.'.join(section_path.spli...
[ "def", "get_section_type", "(", "line", ")", ":", "section_path", "=", "line", ".", "strip", "(", ")", "[", "1", ":", "-", "1", "]", ".", "split", "(", ")", "[", "0", "]", "section_type", "=", "'.'", ".", "join", "(", "section_path", ".", "split", ...
[ 17, 4 ]
[ 25, 27 ]
python
en
['en', 'error', 'th']
False
test_output_path_to_file
(output, output_directory, filename)
Testing if creating filepaths with provided output_directory works correctly.
Testing if creating filepaths with provided output_directory works correctly.
def test_output_path_to_file(output, output_directory, filename): """Testing if creating filepaths with provided output_directory works correctly.""" output.output_directory = output_directory actual = output._path_to_file(filename) expected = os.path.join(output_directory, filename) assert actual ...
[ "def", "test_output_path_to_file", "(", "output", ",", "output_directory", ",", "filename", ")", ":", "output", ".", "output_directory", "=", "output_directory", "actual", "=", "output", ".", "_path_to_file", "(", "filename", ")", "expected", "=", "os", ".", "pa...
[ 17, 0 ]
[ 23, 29 ]
python
en
['en', 'en', 'en']
True
test_output_write_html
(output, filename, template, tmpdir)
Testing if writing content to the file works correctly.
Testing if writing content to the file works correctly.
def test_output_write_html(output, filename, template, tmpdir): """Testing if writing content to the file works correctly.""" output._write_html(filename, template) created_file = os.path.join(tmpdir, filename) assert os.path.exists(created_file) with open(created_file) as f: assert f.read...
[ "def", "test_output_write_html", "(", "output", ",", "filename", ",", "template", ",", "tmpdir", ")", ":", "output", ".", "_write_html", "(", "filename", ",", "template", ")", "created_file", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "filena...
[ 34, 0 ]
[ 42, 35 ]
python
en
['en', 'en', 'en']
True
test_models_view_creator
(output, problem_type, expected_result)
Testing if output creates a correct ModelsView based on a provided problem type.
Testing if output creates a correct ModelsView based on a provided problem type.
def test_models_view_creator(output, problem_type, expected_result): """Testing if output creates a correct ModelsView based on a provided problem type.""" if problem_type == "classification": problem = output.model_finder._classification elif problem_type == "regression": problem = output.m...
[ "def", "test_models_view_creator", "(", "output", ",", "problem_type", ",", "expected_result", ")", ":", "if", "problem_type", "==", "\"classification\"", ":", "problem", "=", "output", ".", "model_finder", ".", "_classification", "elif", "problem_type", "==", "\"re...
[ 53, 0 ]
[ 63, 53 ]
python
en
['en', 'en', 'en']
True
test_models_view_creator_error
(output, incorrect_problem_type)
Testing if _models_view_creator raises an Exception when an incorrect problem type is provided.
Testing if _models_view_creator raises an Exception when an incorrect problem type is provided.
def test_models_view_creator_error(output, incorrect_problem_type): """Testing if _models_view_creator raises an Exception when an incorrect problem type is provided.""" with pytest.raises(ValueError) as excinfo: _ = output._models_view_creator(incorrect_problem_type) assert str(incorrect_problem_ty...
[ "def", "test_models_view_creator_error", "(", "output", ",", "incorrect_problem_type", ")", ":", "with", "pytest", ".", "raises", "(", "ValueError", ")", "as", "excinfo", ":", "_", "=", "output", ".", "_models_view_creator", "(", "incorrect_problem_type", ")", "as...
[ 77, 0 ]
[ 81, 60 ]
python
en
['en', 'en', 'en']
True
test_models_plot_output
( output, model_finder_classification_fitted, model_finder_regression_fitted, model_finder_multiclass_fitted, problem_type, expected_result, fixture_features_multiclass, output_multiclass )
Testing if output creates output of a correct type based on a provided problem type.
Testing if output creates output of a correct type based on a provided problem type.
def test_models_plot_output( output, model_finder_classification_fitted, model_finder_regression_fitted, model_finder_multiclass_fitted, problem_type, expected_result, fixture_features_multiclass, output_multiclass ): """Testing if output creates output of a correct type based on a provided problem ...
[ "def", "test_models_plot_output", "(", "output", ",", "model_finder_classification_fitted", ",", "model_finder_regression_fitted", ",", "model_finder_multiclass_fitted", ",", "problem_type", ",", "expected_result", ",", "fixture_features_multiclass", ",", "output_multiclass", ")"...
[ 92, 0 ]
[ 117, 70 ]
python
en
['en', 'en', 'en']
True
test_models_plot_output_error
(output, incorrect_problem_type)
Testing if _models_view_creator raises an Exception when an incorrect problem type is provided.
Testing if _models_view_creator raises an Exception when an incorrect problem type is provided.
def test_models_plot_output_error(output, incorrect_problem_type): """Testing if _models_view_creator raises an Exception when an incorrect problem type is provided.""" with pytest.raises(ValueError) as excinfo: _ = output._models_plot_output(incorrect_problem_type) assert str(incorrect_problem_type...
[ "def", "test_models_plot_output_error", "(", "output", ",", "incorrect_problem_type", ")", ":", "with", "pytest", ".", "raises", "(", "ValueError", ")", "as", "excinfo", ":", "_", "=", "output", ".", "_models_plot_output", "(", "incorrect_problem_type", ")", "asse...
[ 131, 0 ]
[ 135, 60 ]
python
en
['en', 'en', 'en']
True
test_output_static_path
(output, tmpdir)
Testing if static directory is created in the provided output_directory.
Testing if static directory is created in the provided output_directory.
def test_output_static_path(output, tmpdir): """Testing if static directory is created in the provided output_directory.""" assert output.static_path() == os.path.join(tmpdir, "static")
[ "def", "test_output_static_path", "(", "output", ",", "tmpdir", ")", ":", "assert", "output", ".", "static_path", "(", ")", "==", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "\"static\"", ")" ]
[ 138, 0 ]
[ 140, 65 ]
python
en
['en', 'en', 'en']
True
test_output_assets_path
(output, tmpdir)
Testing if assets directory is created in the provided output_directory.
Testing if assets directory is created in the provided output_directory.
def test_output_assets_path(output, tmpdir): """Testing if assets directory is created in the provided output_directory.""" assert output.assets_path() == os.path.join(tmpdir, "assets")
[ "def", "test_output_assets_path", "(", "output", ",", "tmpdir", ")", ":", "assert", "output", ".", "assets_path", "(", ")", "==", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "\"assets\"", ")" ]
[ 143, 0 ]
[ 145, 65 ]
python
en
['en', 'en', 'en']
True
test_output_logs_path
(output, tmpdir)
Testing if logs directory is created in the provided output_directory.
Testing if logs directory is created in the provided output_directory.
def test_output_logs_path(output, tmpdir): """Testing if logs directory is created in the provided output_directory.""" assert output.logs_path() == os.path.join(tmpdir, "logs")
[ "def", "test_output_logs_path", "(", "output", ",", "tmpdir", ")", ":", "assert", "output", ".", "logs_path", "(", ")", "==", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "\"logs\"", ")" ]
[ 148, 0 ]
[ 150, 61 ]
python
en
['en', 'en', 'en']
True
test_output_create_logs_directory
(output, tmpdir, input_time, expected_directory_name)
Testing if subdirectory in logs is created correctly and with a correct name based on a provided time.
Testing if subdirectory in logs is created correctly and with a correct name based on a provided time.
def test_output_create_logs_directory(output, tmpdir, input_time, expected_directory_name): """Testing if subdirectory in logs is created correctly and with a correct name based on a provided time.""" expected_result = os.path.join(tmpdir, "logs", expected_directory_name) actual_result = output._create_logs...
[ "def", "test_output_create_logs_directory", "(", "output", ",", "tmpdir", ",", "input_time", ",", "expected_directory_name", ")", ":", "expected_result", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "\"logs\"", ",", "expected_directory_name", ")", "act...
[ 161, 0 ]
[ 166, 41 ]
python
en
['en', 'en', 'en']
True
test_output_write_logs_files_created
(output, tmpdir)
Testing if writing log csv log files works correctly.
Testing if writing log csv log files works correctly.
def test_output_write_logs_files_created(output, tmpdir): """Testing if writing log csv log files works correctly.""" test_date = datetime.datetime(2020, 3, 1, 14, 0, 34) log_dir = "01032020140034" filenames = [output._search_results_csv, output._quicksearch_results_csv, output._gridsearch_results_csv] ...
[ "def", "test_output_write_logs_files_created", "(", "output", ",", "tmpdir", ")", ":", "test_date", "=", "datetime", ".", "datetime", "(", "2020", ",", "3", ",", "1", ",", "14", ",", "0", ",", "34", ")", "log_dir", "=", "\"01032020140034\"", "filenames", "...
[ 169, 0 ]
[ 182, 32 ]
python
en
['en', 'ceb', 'en']
True
test_output_write_logs_csv_content
(output, tmpdir, model_finder_classification_fitted)
Testing if csv files written as logs are the same as those in model_finder properties.
Testing if csv files written as logs are the same as those in model_finder properties.
def test_output_write_logs_csv_content(output, tmpdir, model_finder_classification_fitted): """Testing if csv files written as logs are the same as those in model_finder properties.""" test_date = datetime.datetime(2020, 3, 1, 14, 0, 34) log_dir = "01032020140034" filenames = [output._search_results_csv...
[ "def", "test_output_write_logs_csv_content", "(", "output", ",", "tmpdir", ",", "model_finder_classification_fitted", ")", ":", "test_date", "=", "datetime", ".", "datetime", "(", "2020", ",", "3", ",", "1", ",", "14", ",", "0", ",", "34", ")", "log_dir", "=...
[ 185, 0 ]
[ 199, 51 ]
python
en
['en', 'en', 'en']
True
test_output_write_logs_one_df_missing
(output, tmpdir, model_finder_classification_fitted)
Testing that csv files are not created when appropriate result df is None.
Testing that csv files are not created when appropriate result df is None.
def test_output_write_logs_one_df_missing(output, tmpdir, model_finder_classification_fitted): """Testing that csv files are not created when appropriate result df is None.""" test_date = datetime.datetime(2020, 3, 1, 14, 0, 34) log_dir = "01032020140034" filenames = [output._search_results_csv, output....
[ "def", "test_output_write_logs_one_df_missing", "(", "output", ",", "tmpdir", ",", "model_finder_classification_fitted", ")", ":", "test_date", "=", "datetime", ".", "datetime", "(", "2020", ",", "3", ",", "1", ",", "14", ",", "0", ",", "34", ")", "log_dir", ...
[ 202, 0 ]
[ 215, 32 ]
python
en
['en', 'en', 'en']
True
test_output_create_output_directory
(output, tmpdir, input_directory)
Testing if creating output_directory works in case it doesn't exist.
Testing if creating output_directory works in case it doesn't exist.
def test_output_create_output_directory(output, tmpdir, input_directory): """Testing if creating output_directory works in case it doesn't exist.""" directory = os.path.join(tmpdir, input_directory) output.output_directory = directory output._create_output_directory() assert os.path.isdir(directory)
[ "def", "test_output_create_output_directory", "(", "output", ",", "tmpdir", ",", "input_directory", ")", ":", "directory", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "input_directory", ")", "output", ".", "output_directory", "=", "directory", "outp...
[ 226, 0 ]
[ 231, 35 ]
python
en
['en', 'en', 'en']
True
test_dashboard_output_directory_exists
(output, tmpdir, input_directory)
Testing if create_output_directory does not interfere when the directory already exists.
Testing if create_output_directory does not interfere when the directory already exists.
def test_dashboard_output_directory_exists(output, tmpdir, input_directory): """Testing if create_output_directory does not interfere when the directory already exists.""" directory = os.path.join(tmpdir, input_directory) os.makedirs(directory) assert os.path.isdir(directory) output.output_directory...
[ "def", "test_dashboard_output_directory_exists", "(", "output", ",", "tmpdir", ",", "input_directory", ")", ":", "directory", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "input_directory", ")", "os", ".", "makedirs", "(", "directory", ")", "assert...
[ 241, 0 ]
[ 248, 35 ]
python
en
['en', 'en', 'en']
True
test_output_create_subdirectories
(output, tmpdir)
Testing if static and assets subdirectories are created correctly.
Testing if static and assets subdirectories are created correctly.
def test_output_create_subdirectories(output, tmpdir): """Testing if static and assets subdirectories are created correctly.""" directories = ["static", "assets"] expected_directories = [os.path.join(tmpdir, d) for d in directories] for d in expected_directories: assert not os.path.isdir(d) ...
[ "def", "test_output_create_subdirectories", "(", "output", ",", "tmpdir", ")", ":", "directories", "=", "[", "\"static\"", ",", "\"assets\"", "]", "expected_directories", "=", "[", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "d", ")", "for", "d", "...
[ 251, 0 ]
[ 262, 31 ]
python
en
['en', 'en', 'en']
True
test_output_copy_static
(output, tmpdir, root_path_to_package)
Testing if static files are copied correctly to the output_directory folder.
Testing if static files are copied correctly to the output_directory folder.
def test_output_copy_static(output, tmpdir, root_path_to_package): """Testing if static files are copied correctly to the output_directory folder.""" directory, pkg_name = root_path_to_package[0], root_path_to_package[1] base_files = [os.path.join(directory, pkg_name, "static", f) for f in output._static_fi...
[ "def", "test_output_copy_static", "(", "output", ",", "tmpdir", ",", "root_path_to_package", ")", ":", "directory", ",", "pkg_name", "=", "root_path_to_package", "[", "0", "]", ",", "root_path_to_package", "[", "1", "]", "base_files", "=", "[", "os", ".", "pat...
[ 265, 0 ]
[ 276, 89 ]
python
en
['en', 'en', 'en']
True
test_output_overview_path
(output, tmpdir)
Testing if overview HTML file path is created correctly.
Testing if overview HTML file path is created correctly.
def test_output_overview_path(output, tmpdir): """Testing if overview HTML file path is created correctly.""" expected_path = os.path.join(tmpdir, "overview.html") actual_path = output.overview_file() assert actual_path == expected_path
[ "def", "test_output_overview_path", "(", "output", ",", "tmpdir", ")", ":", "expected_path", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "\"overview.html\"", ")", "actual_path", "=", "output", ".", "overview_file", "(", ")", "assert", "actual_path...
[ 279, 0 ]
[ 283, 39 ]
python
en
['en', 'en', 'en']
True
test_output_features_path
(output, tmpdir)
Testing if features HTML file path is created correctly.
Testing if features HTML file path is created correctly.
def test_output_features_path(output, tmpdir): """Testing if features HTML file path is created correctly.""" expected_path = os.path.join(tmpdir, "features.html") actual_path = output.features_file() assert actual_path == expected_path
[ "def", "test_output_features_path", "(", "output", ",", "tmpdir", ")", ":", "expected_path", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "\"features.html\"", ")", "actual_path", "=", "output", ".", "features_file", "(", ")", "assert", "actual_path...
[ 286, 0 ]
[ 290, 39 ]
python
en
['en', 'en', 'en']
True
test_output_models_path
(output, tmpdir)
Testing if models HTML file path is created correctly.
Testing if models HTML file path is created correctly.
def test_output_models_path(output, tmpdir): """Testing if models HTML file path is created correctly.""" expected_path = os.path.join(tmpdir, "models.html") actual_path = output.models_file() assert actual_path == expected_path
[ "def", "test_output_models_path", "(", "output", ",", "tmpdir", ")", ":", "expected_path", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "\"models.html\"", ")", "actual_path", "=", "output", ".", "models_file", "(", ")", "assert", "actual_path", "...
[ 293, 0 ]
[ 297, 39 ]
python
en
['en', 'en', 'en']
True
user_passes_test
( test_func: Callable[[HttpResponse], bool], login_url: Optional[str] = None, redirect_field_name: str = REDIRECT_FIELD_NAME, )
Decorator for views that checks that the user passes the given test, redirecting to the log-in page if necessary. The test should be a callable that takes the user object and returns True if the user passes.
Decorator for views that checks that the user passes the given test, redirecting to the log-in page if necessary. The test should be a callable that takes the user object and returns True if the user passes.
def user_passes_test( test_func: Callable[[HttpResponse], bool], login_url: Optional[str] = None, redirect_field_name: str = REDIRECT_FIELD_NAME, ) -> Callable[[ViewFuncT], ViewFuncT]: """ Decorator for views that checks that the user passes the given test, redirecting to the log-in page if nece...
[ "def", "user_passes_test", "(", "test_func", ":", "Callable", "[", "[", "HttpResponse", "]", ",", "bool", "]", ",", "login_url", ":", "Optional", "[", "str", "]", "=", "None", ",", "redirect_field_name", ":", "str", "=", "REDIRECT_FIELD_NAME", ",", ")", "-...
[ 365, 0 ]
[ 401, 20 ]
python
en
['en', 'error', 'th']
False
do_login
(request: HttpRequest, user_profile: UserProfile)
Creates a session, logging in the user, using the Django method, and also adds helpful data needed by our server logs.
Creates a session, logging in the user, using the Django method, and also adds helpful data needed by our server logs.
def do_login(request: HttpRequest, user_profile: UserProfile) -> None: """Creates a session, logging in the user, using the Django method, and also adds helpful data needed by our server logs. """ django_login(request, user_profile) request._requestor_for_logs = user_profile.format_requestor_for_log...
[ "def", "do_login", "(", "request", ":", "HttpRequest", ",", "user_profile", ":", "UserProfile", ")", "->", "None", ":", "django_login", "(", "request", ",", "user_profile", ")", "request", ".", "_requestor_for_logs", "=", "user_profile", ".", "format_requestor_for...
[ 420, 0 ]
[ 429, 50 ]
python
en
['en', 'en', 'en']
True
web_public_view
( view_func: ViewFuncT, redirect_field_name: str = REDIRECT_FIELD_NAME, login_url: str = settings.HOME_NOT_LOGGED_IN, )
This wrapper adds client info for unauthenticated users but forces authenticated users to go through 2fa. NOTE: This function == zulip_login_required in a production environment as web_public_view path has only been enabled for development purposes currently.
This wrapper adds client info for unauthenticated users but forces authenticated users to go through 2fa.
def web_public_view( view_func: ViewFuncT, redirect_field_name: str = REDIRECT_FIELD_NAME, login_url: str = settings.HOME_NOT_LOGGED_IN, ) -> Union[Callable[[ViewFuncT], ViewFuncT], ViewFuncT]: """ This wrapper adds client info for unauthenticated users but forces authenticated users to go throu...
[ "def", "web_public_view", "(", "view_func", ":", "ViewFuncT", ",", "redirect_field_name", ":", "str", "=", "REDIRECT_FIELD_NAME", ",", "login_url", ":", "str", "=", "settings", ".", "HOME_NOT_LOGGED_IN", ",", ")", "->", "Union", "[", "Callable", "[", "[", "Vie...
[ 482, 0 ]
[ 503, 38 ]
python
en
['en', 'error', 'th']
False
internal_notify_view
(is_tornado_view: bool)
Used for situations where something running on the Zulip server needs to make a request to the (other) Django/Tornado processes running on the server.
Used for situations where something running on the Zulip server needs to make a request to the (other) Django/Tornado processes running on the server.
def internal_notify_view(is_tornado_view: bool) -> Callable[[ViewFuncT], ViewFuncT]: # The typing here could be improved by using the extended Callable types: # https://mypy.readthedocs.io/en/stable/additional_features.html#extended-callable-types """Used for situations where something running on the Zulip ...
[ "def", "internal_notify_view", "(", "is_tornado_view", ":", "bool", ")", "->", "Callable", "[", "[", "ViewFuncT", "]", ",", "ViewFuncT", "]", ":", "# The typing here could be improved by using the extended Callable types:", "# https://mypy.readthedocs.io/en/stable/additional_feat...
[ 785, 0 ]
[ 813, 29 ]
python
en
['en', 'en', 'en']
True
statsd_increment
(counter: str, val: int = 1)
Increments a statsd counter on completion of the decorated function. Pass the name of the counter to this decorator-returning function.
Increments a statsd counter on completion of the decorated function.
def statsd_increment(counter: str, val: int = 1) -> Callable[[FuncT], FuncT]: """Increments a statsd counter on completion of the decorated function. Pass the name of the counter to this decorator-returning function.""" def wrapper(func: FuncT) -> FuncT: @wraps(func) def wrapped_func(*...
[ "def", "statsd_increment", "(", "counter", ":", "str", ",", "val", ":", "int", "=", "1", ")", "->", "Callable", "[", "[", "FuncT", "]", ",", "FuncT", "]", ":", "def", "wrapper", "(", "func", ":", "FuncT", ")", "->", "FuncT", ":", "@", "wraps", "(...
[ 820, 0 ]
[ 835, 18 ]
python
en
['en', 'en', 'en']
True
rate_limit_user
(request: HttpRequest, user: UserProfile, domain: str)
Returns whether or not a user was rate limited. Will raise a RateLimited exception if the user has been rate limited, otherwise returns and modifies request to contain the rate limit information
Returns whether or not a user was rate limited. Will raise a RateLimited exception if the user has been rate limited, otherwise returns and modifies request to contain the rate limit information
def rate_limit_user(request: HttpRequest, user: UserProfile, domain: str) -> None: """Returns whether or not a user was rate limited. Will raise a RateLimited exception if the user has been rate limited, otherwise returns and modifies request to contain the rate limit information""" RateLimitedUser(use...
[ "def", "rate_limit_user", "(", "request", ":", "HttpRequest", ",", "user", ":", "UserProfile", ",", "domain", ":", "str", ")", "->", "None", ":", "RateLimitedUser", "(", "user", ",", "domain", "=", "domain", ")", ".", "rate_limit_request", "(", "request", ...
[ 838, 0 ]
[ 843, 68 ]
python
en
['en', 'en', 'en']
True
rate_limit
(domain: str = "api_by_user")
Rate-limits a view. Takes an optional 'domain' param if you wish to rate limit different types of API calls independently. Returns a decorator
Rate-limits a view. Takes an optional 'domain' param if you wish to rate limit different types of API calls independently.
def rate_limit(domain: str = "api_by_user") -> Callable[[ViewFuncT], ViewFuncT]: """Rate-limits a view. Takes an optional 'domain' param if you wish to rate limit different types of API calls independently. Returns a decorator""" def wrapper(func: ViewFuncT) -> ViewFuncT: @wraps(func) ...
[ "def", "rate_limit", "(", "domain", ":", "str", "=", "\"api_by_user\"", ")", "->", "Callable", "[", "[", "ViewFuncT", "]", ",", "ViewFuncT", "]", ":", "def", "wrapper", "(", "func", ":", "ViewFuncT", ")", "->", "ViewFuncT", ":", "@", "wraps", "(", "fun...
[ 846, 0 ]
[ 883, 18 ]
python
en
['en', 'en', 'en']
True
zulip_otp_required
( redirect_field_name: str = "next", login_url: str = settings.HOME_NOT_LOGGED_IN, )
The reason we need to create this function is that the stock otp_required decorator doesn't play well with tests. We cannot enable/disable if_configured parameter during tests since the decorator retains its value due to closure. Similar to :func:`~django.contrib.auth.decorators.login_required`, b...
The reason we need to create this function is that the stock otp_required decorator doesn't play well with tests. We cannot enable/disable if_configured parameter during tests since the decorator retains its value due to closure.
def zulip_otp_required( redirect_field_name: str = "next", login_url: str = settings.HOME_NOT_LOGGED_IN, ) -> Callable[[ViewFuncT], ViewFuncT]: """ The reason we need to create this function is that the stock otp_required decorator doesn't play well with tests. We cannot enable/disable if_config...
[ "def", "zulip_otp_required", "(", "redirect_field_name", ":", "str", "=", "\"next\"", ",", "login_url", ":", "str", "=", "settings", ".", "HOME_NOT_LOGGED_IN", ",", ")", "->", "Callable", "[", "[", "ViewFuncT", "]", ",", "ViewFuncT", "]", ":", "def", "test",...
[ 896, 0 ]
[ 945, 20 ]
python
en
['en', 'error', 'th']
False