repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
mayfield/shellish
shellish/rendering/html.py
htmlprint
def htmlprint(*values, plain=None, **options): """ Convert HTML to VTML and then print it. Follows same semantics as vtmlprint. """ print(*[htmlrender(x, plain=plain) for x in values], **options)
python
def htmlprint(*values, plain=None, **options): """ Convert HTML to VTML and then print it. Follows same semantics as vtmlprint. """ print(*[htmlrender(x, plain=plain) for x in values], **options)
[ "def", "htmlprint", "(", "*", "values", ",", "plain", "=", "None", ",", "*", "*", "options", ")", ":", "print", "(", "*", "[", "htmlrender", "(", "x", ",", "plain", "=", "plain", ")", "for", "x", "in", "values", "]", ",", "*", "*", "options", "...
Convert HTML to VTML and then print it. Follows same semantics as vtmlprint.
[ "Convert", "HTML", "to", "VTML", "and", "then", "print", "it", ".", "Follows", "same", "semantics", "as", "vtmlprint", "." ]
train
https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/rendering/html.py#L223-L226
OiNutter/lean
lean/template.py
Template.render
def render(self,scope=None,local_vars=None,block=None): ''' Render the template in the given scope with the locals specified. If a block is given, it is typically available within the template via +yield+. ''' if not scope: class Scope(object): pass scope = Scope() return self.evaluate(scope,...
python
def render(self,scope=None,local_vars=None,block=None): ''' Render the template in the given scope with the locals specified. If a block is given, it is typically available within the template via +yield+. ''' if not scope: class Scope(object): pass scope = Scope() return self.evaluate(scope,...
[ "def", "render", "(", "self", ",", "scope", "=", "None", ",", "local_vars", "=", "None", ",", "block", "=", "None", ")", ":", "if", "not", "scope", ":", "class", "Scope", "(", "object", ")", ":", "pass", "scope", "=", "Scope", "(", ")", "return", ...
Render the template in the given scope with the locals specified. If a block is given, it is typically available within the template via +yield+.
[ "Render", "the", "template", "in", "the", "given", "scope", "with", "the", "locals", "specified", ".", "If", "a", "block", "is", "given", "it", "is", "typically", "available", "within", "the", "template", "via", "+", "yield", "+", "." ]
train
https://github.com/OiNutter/lean/blob/5d251f923acd44265ed401de14a9ead6752c543f/lean/template.py#L66-L78
OiNutter/lean
lean/template.py
Template.basename
def basename(self, suffix=''): ''' The basename of the template file.''' return os.path.basename(self._file, suffix) if self._file else None
python
def basename(self, suffix=''): ''' The basename of the template file.''' return os.path.basename(self._file, suffix) if self._file else None
[ "def", "basename", "(", "self", ",", "suffix", "=", "''", ")", ":", "return", "os", ".", "path", ".", "basename", "(", "self", ".", "_file", ",", "suffix", ")", "if", "self", ".", "_file", "else", "None" ]
The basename of the template file.
[ "The", "basename", "of", "the", "template", "file", "." ]
train
https://github.com/OiNutter/lean/blob/5d251f923acd44265ed401de14a9ead6752c543f/lean/template.py#L80-L82
OiNutter/lean
lean/template.py
Template.evaluate
def evaluate(self,scope,local_vars,block=None): ''' Execute the compiled template and return the result string. Template evaluation is guaranteed to be performed in the scope object with the locals specified and with support for yielding to the block. This method is only used by source generating t...
python
def evaluate(self,scope,local_vars,block=None): ''' Execute the compiled template and return the result string. Template evaluation is guaranteed to be performed in the scope object with the locals specified and with support for yielding to the block. This method is only used by source generating t...
[ "def", "evaluate", "(", "self", ",", "scope", ",", "local_vars", ",", "block", "=", "None", ")", ":", "method", "=", "self", ".", "compiled_method", "(", "local_vars", ".", "keys", "(", ")", ")", "setattr", "(", "scope", ",", "'compiled'", ",", "method...
Execute the compiled template and return the result string. Template evaluation is guaranteed to be performed in the scope object with the locals specified and with support for yielding to the block. This method is only used by source generating templates. Subclasses that override render() may not...
[ "Execute", "the", "compiled", "template", "and", "return", "the", "result", "string", ".", "Template", "evaluation", "is", "guaranteed", "to", "be", "performed", "in", "the", "scope", "object", "with", "the", "locals", "specified", "and", "with", "support", "f...
train
https://github.com/OiNutter/lean/blob/5d251f923acd44265ed401de14a9ead6752c543f/lean/template.py#L108-L119
firstprayer/monsql
monsql/queryset.py
QuerySet.filter
def filter(self, filter): """ Add new filter to the query set. Note that since QuerySet is lazy, it would just combine this filter with the original filter with an 'AND' :Parameters: - filter: a dictionary :Return: a new QuerySet object """ new_query_set ...
python
def filter(self, filter): """ Add new filter to the query set. Note that since QuerySet is lazy, it would just combine this filter with the original filter with an 'AND' :Parameters: - filter: a dictionary :Return: a new QuerySet object """ new_query_set ...
[ "def", "filter", "(", "self", ",", "filter", ")", ":", "new_query_set", "=", "self", ".", "clone", "(", ")", "new_query_set", ".", "query", ".", "add_filter", "(", "filter", ")", "return", "new_query_set" ]
Add new filter to the query set. Note that since QuerySet is lazy, it would just combine this filter with the original filter with an 'AND' :Parameters: - filter: a dictionary :Return: a new QuerySet object
[ "Add", "new", "filter", "to", "the", "query", "set", ".", "Note", "that", "since", "QuerySet", "is", "lazy", "it", "would", "just", "combine", "this", "filter", "with", "the", "original", "filter", "with", "an", "AND", ":", "Parameters", ":", "-", "filte...
train
https://github.com/firstprayer/monsql/blob/6285c15b574c8664046eae2edfeb548c7b173efd/monsql/queryset.py#L77-L88
firstprayer/monsql
monsql/queryset.py
QuerySet.limit
def limit(self, n, skip=None): """ Limit the result set. However when the query set already has limit field before, this would raise an exception :Parameters: - n : The maximum number of rows returned - skip: how many rows to skip :Return: a new QuerySet object so...
python
def limit(self, n, skip=None): """ Limit the result set. However when the query set already has limit field before, this would raise an exception :Parameters: - n : The maximum number of rows returned - skip: how many rows to skip :Return: a new QuerySet object so...
[ "def", "limit", "(", "self", ",", "n", ",", "skip", "=", "None", ")", ":", "if", "self", ".", "query", ".", "limit", "is", "not", "None", ":", "raise", "MonSQLException", "(", "'LIMIT already defined'", ")", "new_query_set", "=", "self", ".", "clone", ...
Limit the result set. However when the query set already has limit field before, this would raise an exception :Parameters: - n : The maximum number of rows returned - skip: how many rows to skip :Return: a new QuerySet object so we can chain operations
[ "Limit", "the", "result", "set", ".", "However", "when", "the", "query", "set", "already", "has", "limit", "field", "before", "this", "would", "raise", "an", "exception", ":", "Parameters", ":", "-", "n", ":", "The", "maximum", "number", "of", "rows", "r...
train
https://github.com/firstprayer/monsql/blob/6285c15b574c8664046eae2edfeb548c7b173efd/monsql/queryset.py#L91-L107
firstprayer/monsql
monsql/queryset.py
QuerySet.distinct
def distinct(self): """ Only return distinct row. Return a new query set with distinct mark """ new_query_set = self.clone() new_query_set.query.distinct = True return new_query_set
python
def distinct(self): """ Only return distinct row. Return a new query set with distinct mark """ new_query_set = self.clone() new_query_set.query.distinct = True return new_query_set
[ "def", "distinct", "(", "self", ")", ":", "new_query_set", "=", "self", ".", "clone", "(", ")", "new_query_set", ".", "query", ".", "distinct", "=", "True", "return", "new_query_set" ]
Only return distinct row. Return a new query set with distinct mark
[ "Only", "return", "distinct", "row", ".", "Return", "a", "new", "query", "set", "with", "distinct", "mark" ]
train
https://github.com/firstprayer/monsql/blob/6285c15b574c8664046eae2edfeb548c7b173efd/monsql/queryset.py#L110-L117
uw-it-aca/uw-restclients-grad
uw_grad/degree.py
_process_json
def _process_json(json_data): """ return a list of GradDegree objects. """ requests = [] for item in json_data: degree = GradDegree() degree.degree_title = item["degreeTitle"] degree.exam_place = item["examPlace"] degree.exam_date = parse_datetime(item.get("examDate")...
python
def _process_json(json_data): """ return a list of GradDegree objects. """ requests = [] for item in json_data: degree = GradDegree() degree.degree_title = item["degreeTitle"] degree.exam_place = item["examPlace"] degree.exam_date = parse_datetime(item.get("examDate")...
[ "def", "_process_json", "(", "json_data", ")", ":", "requests", "=", "[", "]", "for", "item", "in", "json_data", ":", "degree", "=", "GradDegree", "(", ")", "degree", ".", "degree_title", "=", "item", "[", "\"degreeTitle\"", "]", "degree", ".", "exam_place...
return a list of GradDegree objects.
[ "return", "a", "list", "of", "GradDegree", "objects", "." ]
train
https://github.com/uw-it-aca/uw-restclients-grad/blob/ca06ed2f24f3683314a5690f6078e97d37fc8e52/uw_grad/degree.py#L23-L44
fr33jc/bang
bang/providers/aws.py
server_to_dict
def server_to_dict(server): """ Returns the :class:`dict` representation of a server object. The returned :class:`dict` is meant to be consumed by :class:`~bang.deployers.cloud.ServerDeployer` objects. """ return { A.server.ID: server.id, A.server.PUBLIC_IPS: [server.pu...
python
def server_to_dict(server): """ Returns the :class:`dict` representation of a server object. The returned :class:`dict` is meant to be consumed by :class:`~bang.deployers.cloud.ServerDeployer` objects. """ return { A.server.ID: server.id, A.server.PUBLIC_IPS: [server.pu...
[ "def", "server_to_dict", "(", "server", ")", ":", "return", "{", "A", ".", "server", ".", "ID", ":", "server", ".", "id", ",", "A", ".", "server", ".", "PUBLIC_IPS", ":", "[", "server", ".", "public_dns_name", "]", ",", "A", ".", "server", ".", "PR...
Returns the :class:`dict` representation of a server object. The returned :class:`dict` is meant to be consumed by :class:`~bang.deployers.cloud.ServerDeployer` objects.
[ "Returns", "the", ":", "class", ":", "dict", "representation", "of", "a", "server", "object", "." ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/aws.py#L30-L42
fr33jc/bang
bang/providers/aws.py
EC2.find_servers
def find_servers(self, tags, running=True): """ Returns any servers in the region that have tags that match the key-value pairs in :attr:`tags`. :param Mapping tags: A mapping object in which the keys are the tag names and the values are the tag values. :param bool...
python
def find_servers(self, tags, running=True): """ Returns any servers in the region that have tags that match the key-value pairs in :attr:`tags`. :param Mapping tags: A mapping object in which the keys are the tag names and the values are the tag values. :param bool...
[ "def", "find_servers", "(", "self", ",", "tags", ",", "running", "=", "True", ")", ":", "filters", "=", "dict", "(", "[", "(", "'tag:%s'", "%", "key", ",", "val", ")", "for", "key", ",", "val", "in", "tags", ".", "items", "(", ")", "]", ")", "i...
Returns any servers in the region that have tags that match the key-value pairs in :attr:`tags`. :param Mapping tags: A mapping object in which the keys are the tag names and the values are the tag values. :param bool running: A flag to limit server list to instances that are ...
[ "Returns", "any", "servers", "in", "the", "region", "that", "have", "tags", "that", "match", "the", "key", "-", "value", "pairs", "in", ":", "attr", ":", "tags", "." ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/aws.py#L133-L155
fr33jc/bang
bang/providers/aws.py
EC2.create_server
def create_server(self, basename, disk_image_id, instance_type, ssh_key_name, tags=None, availability_zone=None, timeout_s=DEFAULT_TIMEOUT_S, **provider_extras): """ Creates a new server instance. This call blocks until the server is created and available for normal use,...
python
def create_server(self, basename, disk_image_id, instance_type, ssh_key_name, tags=None, availability_zone=None, timeout_s=DEFAULT_TIMEOUT_S, **provider_extras): """ Creates a new server instance. This call blocks until the server is created and available for normal use,...
[ "def", "create_server", "(", "self", ",", "basename", ",", "disk_image_id", ",", "instance_type", ",", "ssh_key_name", ",", "tags", "=", "None", ",", "availability_zone", "=", "None", ",", "timeout_s", "=", "DEFAULT_TIMEOUT_S", ",", "*", "*", "provider_extras", ...
Creates a new server instance. This call blocks until the server is created and available for normal use, or :attr:`timeout_s` has elapsed. :param str basename: An identifier for the server. A random postfix will be appended to this basename to work around OpenStack Nova REST...
[ "Creates", "a", "new", "server", "instance", ".", "This", "call", "blocks", "until", "the", "server", "is", "created", "and", "available", "for", "normal", "use", "or", ":", "attr", ":", "timeout_s", "has", "elapsed", "." ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/aws.py#L160-L245
fr33jc/bang
bang/providers/aws.py
EC2.find_secgroup
def find_secgroup(self, name): """ Find a security group by name. Returns a :class:`EC2SecGroup` instance if found, otherwise returns None. """ res = self.ec2.get_all_security_groups(filters={'group-name': name}) if res: return EC2SecGroup(res[0])
python
def find_secgroup(self, name): """ Find a security group by name. Returns a :class:`EC2SecGroup` instance if found, otherwise returns None. """ res = self.ec2.get_all_security_groups(filters={'group-name': name}) if res: return EC2SecGroup(res[0])
[ "def", "find_secgroup", "(", "self", ",", "name", ")", ":", "res", "=", "self", ".", "ec2", ".", "get_all_security_groups", "(", "filters", "=", "{", "'group-name'", ":", "name", "}", ")", "if", "res", ":", "return", "EC2SecGroup", "(", "res", "[", "0"...
Find a security group by name. Returns a :class:`EC2SecGroup` instance if found, otherwise returns None.
[ "Find", "a", "security", "group", "by", "name", "." ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/aws.py#L247-L257
fr33jc/bang
bang/providers/aws.py
EC2.create_secgroup
def create_secgroup(self, name, description): """ Creates a new server security group. :param str name: The name of the security group to create. :param str description: A short description of the group. """ return self.ec2.create_security_group(name, description) ...
python
def create_secgroup(self, name, description): """ Creates a new server security group. :param str name: The name of the security group to create. :param str description: A short description of the group. """ return self.ec2.create_security_group(name, description) ...
[ "def", "create_secgroup", "(", "self", ",", "name", ",", "description", ")", ":", "return", "self", ".", "ec2", ".", "create_security_group", "(", "name", ",", "description", ")", "log", ".", "debug", "(", "\"... created group %s\"", "%", "name", ")" ]
Creates a new server security group. :param str name: The name of the security group to create. :param str description: A short description of the group.
[ "Creates", "a", "new", "server", "security", "group", "." ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/aws.py#L259-L268
fr33jc/bang
bang/providers/aws.py
EC2.create_secgroup_rule
def create_secgroup_rule(self, protocol, from_port, to_port, source, target): """ Creates a new server security group rule. :param str protocol: E.g. ``tcp``, ``icmp``, etc... :param int from_port: E.g. ``1`` :param int to_port: E.g. ``65535`` :param str s...
python
def create_secgroup_rule(self, protocol, from_port, to_port, source, target): """ Creates a new server security group rule. :param str protocol: E.g. ``tcp``, ``icmp``, etc... :param int from_port: E.g. ``1`` :param int to_port: E.g. ``65535`` :param str s...
[ "def", "create_secgroup_rule", "(", "self", ",", "protocol", ",", "from_port", ",", "to_port", ",", "source", ",", "target", ")", ":", "kwargs", "=", "{", "'ip_protocol'", ":", "protocol", ",", "'from_port'", ":", "from_port", ",", "'to_port'", ":", "to_port...
Creates a new server security group rule. :param str protocol: E.g. ``tcp``, ``icmp``, etc... :param int from_port: E.g. ``1`` :param int to_port: E.g. ``65535`` :param str source: :param str target: The target security group. I.e. the group in which this rule s...
[ "Creates", "a", "new", "server", "security", "group", "rule", "." ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/aws.py#L270-L296
fr33jc/bang
bang/providers/aws.py
S3.create_bucket
def create_bucket(self, name): """ Creates a new S3 bucket. :param str name: E.g. 'mybucket' """ log.info('Creating bucket %s...' % name) self.s3.create_bucket(name)
python
def create_bucket(self, name): """ Creates a new S3 bucket. :param str name: E.g. 'mybucket' """ log.info('Creating bucket %s...' % name) self.s3.create_bucket(name)
[ "def", "create_bucket", "(", "self", ",", "name", ")", ":", "log", ".", "info", "(", "'Creating bucket %s...'", "%", "name", ")", "self", ".", "s3", ".", "create_bucket", "(", "name", ")" ]
Creates a new S3 bucket. :param str name: E.g. 'mybucket'
[ "Creates", "a", "new", "S3", "bucket", ".", ":", "param", "str", "name", ":", "E", ".", "g", ".", "mybucket" ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/aws.py#L329-L335
ryanjdillon/pylleo
pylleo/lleoio.py
read_meta
def read_meta(path_dir, tag_model, tag_id): '''Read meta data from Little Leonardo data header rows Args ---- path_dir: str Parent directory containing lleo data files tag_model: str Little Leonardo tag model name tag_id: str, int Little Leonardo tag ID number Retur...
python
def read_meta(path_dir, tag_model, tag_id): '''Read meta data from Little Leonardo data header rows Args ---- path_dir: str Parent directory containing lleo data files tag_model: str Little Leonardo tag model name tag_id: str, int Little Leonardo tag ID number Retur...
[ "def", "read_meta", "(", "path_dir", ",", "tag_model", ",", "tag_id", ")", ":", "from", "collections", "import", "OrderedDict", "import", "os", "import", "yamlord", "from", ".", "import", "utils", "def", "_parse_meta_line", "(", "line", ")", ":", "'''Return ke...
Read meta data from Little Leonardo data header rows Args ---- path_dir: str Parent directory containing lleo data files tag_model: str Little Leonardo tag model name tag_id: str, int Little Leonardo tag ID number Returns ------- meta: dict dictionary wi...
[ "Read", "meta", "data", "from", "Little", "Leonardo", "data", "header", "rows" ]
train
https://github.com/ryanjdillon/pylleo/blob/b9b999fef19eaeccce4f207ab1b6198287c1bfec/pylleo/lleoio.py#L2-L103
ryanjdillon/pylleo
pylleo/lleoio.py
read_data
def read_data(meta, path_dir, sample_f=1, decimate=False, overwrite=False): '''Read accelerometry data from leonardo txt files Args ---- meta: dict Dictionary of meta data from header lines of lleo data files path_dir: str Parent directory containing lleo data files sample_f: in...
python
def read_data(meta, path_dir, sample_f=1, decimate=False, overwrite=False): '''Read accelerometry data from leonardo txt files Args ---- meta: dict Dictionary of meta data from header lines of lleo data files path_dir: str Parent directory containing lleo data files sample_f: in...
[ "def", "read_data", "(", "meta", ",", "path_dir", ",", "sample_f", "=", "1", ",", "decimate", "=", "False", ",", "overwrite", "=", "False", ")", ":", "import", "os", "import", "pandas", "from", ".", "import", "utils", "def", "_generate_datetimes", "(", "...
Read accelerometry data from leonardo txt files Args ---- meta: dict Dictionary of meta data from header lines of lleo data files path_dir: str Parent directory containing lleo data files sample_f: int Return every `sample_f` data points Returns ------- acc: pan...
[ "Read", "accelerometry", "data", "from", "leonardo", "txt", "files" ]
train
https://github.com/ryanjdillon/pylleo/blob/b9b999fef19eaeccce4f207ab1b6198287c1bfec/pylleo/lleoio.py#L106-L240
ikumen/flask-cfg
flask_cfg/core.py
AbstractConfig.process_loaded_configs
def process_loaded_configs(self, values): """Takes the loaded config values (from YAML files) and performs the following clean up steps: 1. remove all value keys that are not uppercase 2. resolve any keys with missing values Note: resolving missing values does not fail ...
python
def process_loaded_configs(self, values): """Takes the loaded config values (from YAML files) and performs the following clean up steps: 1. remove all value keys that are not uppercase 2. resolve any keys with missing values Note: resolving missing values does not fail ...
[ "def", "process_loaded_configs", "(", "self", ",", "values", ")", ":", "unresolved_value_keys", "=", "self", ".", "_process_config_values", "(", "[", "]", ",", "values", ",", "[", "]", ")", "if", "len", "(", "unresolved_value_keys", ")", ">", "0", ":", "ms...
Takes the loaded config values (from YAML files) and performs the following clean up steps: 1. remove all value keys that are not uppercase 2. resolve any keys with missing values Note: resolving missing values does not fail fast, we will collect all missing values and ...
[ "Takes", "the", "loaded", "config", "values", "(", "from", "YAML", "files", ")", "and", "performs", "the", "following", "clean", "up", "steps", ":", "1", ".", "remove", "all", "value", "keys", "that", "are", "not", "uppercase", "2", ".", "resolve", "any"...
train
https://github.com/ikumen/flask-cfg/blob/28f3370121419d22b6a5a3713ab3cb8bb2da6e43/flask_cfg/core.py#L48-L77
ikumen/flask-cfg
flask_cfg/core.py
AbstractConfig._process_config_values
def _process_config_values(self, dict_path, values, unresolved=[]): """Attempts to resolve any config value that is missing (e.g. None). @param dict_path our current path as we traverse the values dict @param values dictionary containing configs we want to resolve @param unresolved keep...
python
def _process_config_values(self, dict_path, values, unresolved=[]): """Attempts to resolve any config value that is missing (e.g. None). @param dict_path our current path as we traverse the values dict @param values dictionary containing configs we want to resolve @param unresolved keep...
[ "def", "_process_config_values", "(", "self", ",", "dict_path", ",", "values", ",", "unresolved", "=", "[", "]", ")", ":", "if", "isinstance", "(", "values", ",", "dict", ")", ":", "for", "k", ",", "v", "in", "values", ".", "items", "(", ")", ":", ...
Attempts to resolve any config value that is missing (e.g. None). @param dict_path our current path as we traverse the values dict @param values dictionary containing configs we want to resolve @param unresolved keep track of config values that are missing @returns list containing all u...
[ "Attempts", "to", "resolve", "any", "config", "value", "that", "is", "missing", "(", "e", ".", "g", ".", "None", ")", "." ]
train
https://github.com/ikumen/flask-cfg/blob/28f3370121419d22b6a5a3713ab3cb8bb2da6e43/flask_cfg/core.py#L79-L111
ikumen/flask-cfg
flask_cfg/core.py
AbstractConfig._load_all_configs
def _load_all_configs(self, paths, values={}): """Loads configuration values for each of the files (from given paths), merging duplicate values (e.g. latter values with same keys override earlier values). @param paths list of config file paths to load @param values dictionary to...
python
def _load_all_configs(self, paths, values={}): """Loads configuration values for each of the files (from given paths), merging duplicate values (e.g. latter values with same keys override earlier values). @param paths list of config file paths to load @param values dictionary to...
[ "def", "_load_all_configs", "(", "self", ",", "paths", ",", "values", "=", "{", "}", ")", ":", "if", "not", "isinstance", "(", "values", ",", "dict", ")", ":", "raise", "TypeError", "(", "'values must be a dictionary!'", ")", "for", "p", "in", "paths", "...
Loads configuration values for each of the files (from given paths), merging duplicate values (e.g. latter values with same keys override earlier values). @param paths list of config file paths to load @param values dictionary to store the loaded values
[ "Loads", "configuration", "values", "for", "each", "of", "the", "files", "(", "from", "given", "paths", ")", "merging", "duplicate", "values", "(", "e", ".", "g", ".", "latter", "values", "with", "same", "keys", "override", "earlier", "values", ")", "." ]
train
https://github.com/ikumen/flask-cfg/blob/28f3370121419d22b6a5a3713ab3cb8bb2da6e43/flask_cfg/core.py#L145-L157
ikumen/flask-cfg
flask_cfg/core.py
AbstractConfig._merge_values
def _merge_values(self, to_values, from_values): """Merges two dictionaries of values recursively. This is a very naive implementation that expects the two dictionaries to be fairly similar in structure. @param to_values destination dictionary @param from_values dictionary with...
python
def _merge_values(self, to_values, from_values): """Merges two dictionaries of values recursively. This is a very naive implementation that expects the two dictionaries to be fairly similar in structure. @param to_values destination dictionary @param from_values dictionary with...
[ "def", "_merge_values", "(", "self", ",", "to_values", ",", "from_values", ")", ":", "if", "from_values", "is", "not", "None", ":", "for", "k", ",", "v", "in", "from_values", ".", "items", "(", ")", ":", "if", "k", "in", "to_values", "and", "isinstance...
Merges two dictionaries of values recursively. This is a very naive implementation that expects the two dictionaries to be fairly similar in structure. @param to_values destination dictionary @param from_values dictionary with values to copy
[ "Merges", "two", "dictionaries", "of", "values", "recursively", ".", "This", "is", "a", "very", "naive", "implementation", "that", "expects", "the", "two", "dictionaries", "to", "be", "fairly", "similar", "in", "structure", "." ]
train
https://github.com/ikumen/flask-cfg/blob/28f3370121419d22b6a5a3713ab3cb8bb2da6e43/flask_cfg/core.py#L160-L174
ikumen/flask-cfg
flask_cfg/core.py
AbstractConfig._load_config
def _load_config(self, path): """Return YAML values from given config file. @param path file to load """ try: with open(path) as f: values = yaml.safe_load(f) if isinstance(values, dict): return values else:...
python
def _load_config(self, path): """Return YAML values from given config file. @param path file to load """ try: with open(path) as f: values = yaml.safe_load(f) if isinstance(values, dict): return values else:...
[ "def", "_load_config", "(", "self", ",", "path", ")", ":", "try", ":", "with", "open", "(", "path", ")", "as", "f", ":", "values", "=", "yaml", ".", "safe_load", "(", "f", ")", "if", "isinstance", "(", "values", ",", "dict", ")", ":", "return", "...
Return YAML values from given config file. @param path file to load
[ "Return", "YAML", "values", "from", "given", "config", "file", "." ]
train
https://github.com/ikumen/flask-cfg/blob/28f3370121419d22b6a5a3713ab3cb8bb2da6e43/flask_cfg/core.py#L177-L193
ikumen/flask-cfg
flask_cfg/core.py
AbstractConfig._normalize_file_paths
def _normalize_file_paths(self, *args): """Returns all given configuration file paths as one list.""" paths = [] for arg in args: if arg is None: continue elif self._is_valid_file(arg): paths.append(arg) elif isinstance(arg, lis...
python
def _normalize_file_paths(self, *args): """Returns all given configuration file paths as one list.""" paths = [] for arg in args: if arg is None: continue elif self._is_valid_file(arg): paths.append(arg) elif isinstance(arg, lis...
[ "def", "_normalize_file_paths", "(", "self", ",", "*", "args", ")", ":", "paths", "=", "[", "]", "for", "arg", "in", "args", ":", "if", "arg", "is", "None", ":", "continue", "elif", "self", ".", "_is_valid_file", "(", "arg", ")", ":", "paths", ".", ...
Returns all given configuration file paths as one list.
[ "Returns", "all", "given", "configuration", "file", "paths", "as", "one", "list", "." ]
train
https://github.com/ikumen/flask-cfg/blob/28f3370121419d22b6a5a3713ab3cb8bb2da6e43/flask_cfg/core.py#L196-L208
ikumen/flask-cfg
flask_cfg/core.py
AbstractConfig._is_valid_file
def _is_valid_file(self, path): """Simple check to see if file path exists. Does not check for valid YAML format.""" return isinstance(path, basestring) and os.path.isfile(path)
python
def _is_valid_file(self, path): """Simple check to see if file path exists. Does not check for valid YAML format.""" return isinstance(path, basestring) and os.path.isfile(path)
[ "def", "_is_valid_file", "(", "self", ",", "path", ")", ":", "return", "isinstance", "(", "path", ",", "basestring", ")", "and", "os", ".", "path", ".", "isfile", "(", "path", ")" ]
Simple check to see if file path exists. Does not check for valid YAML format.
[ "Simple", "check", "to", "see", "if", "file", "path", "exists", ".", "Does", "not", "check", "for", "valid", "YAML", "format", "." ]
train
https://github.com/ikumen/flask-cfg/blob/28f3370121419d22b6a5a3713ab3cb8bb2da6e43/flask_cfg/core.py#L211-L213
shi-cong/PYSTUDY
PYSTUDY/threadinglib.py
create_thread
def create_thread(daemon, callback, *callbackParams): """创建一个线程 :param daemon: True表示线程随着主线程关闭而关闭,False表示主线程必须等待子线程结束 :param callback: 线程的回调函数 :param callbackParams: 回调函数的形式参数 :return: 一个线程类,初始状态为未启动,已经创建 """ task = Thread(target=callback, args=callbackParams) task.setDaemon(daemon) ...
python
def create_thread(daemon, callback, *callbackParams): """创建一个线程 :param daemon: True表示线程随着主线程关闭而关闭,False表示主线程必须等待子线程结束 :param callback: 线程的回调函数 :param callbackParams: 回调函数的形式参数 :return: 一个线程类,初始状态为未启动,已经创建 """ task = Thread(target=callback, args=callbackParams) task.setDaemon(daemon) ...
[ "def", "create_thread", "(", "daemon", ",", "callback", ",", "*", "callbackParams", ")", ":", "task", "=", "Thread", "(", "target", "=", "callback", ",", "args", "=", "callbackParams", ")", "task", ".", "setDaemon", "(", "daemon", ")", "return", "task" ]
创建一个线程 :param daemon: True表示线程随着主线程关闭而关闭,False表示主线程必须等待子线程结束 :param callback: 线程的回调函数 :param callbackParams: 回调函数的形式参数 :return: 一个线程类,初始状态为未启动,已经创建
[ "创建一个线程", ":", "param", "daemon", ":", "True表示线程随着主线程关闭而关闭,False表示主线程必须等待子线程结束", ":", "param", "callback", ":", "线程的回调函数", ":", "param", "callbackParams", ":", "回调函数的形式参数", ":", "return", ":", "一个线程类,初始状态为未启动,已经创建" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/threadinglib.py#L17-L26
almcc/cinder-data
docs/conf.py
run_apidoc
def run_apidoc(_): """Heler function for run apidoc as part of the build.""" current_directory = os.path.abspath(os.path.dirname(__file__)) output_path = os.path.join(current_directory, 'source') cmd_path = 'sphinx-apidoc' if hasattr(sys, 'real_prefix'): # Check to see if we are in a virtualenv ...
python
def run_apidoc(_): """Heler function for run apidoc as part of the build.""" current_directory = os.path.abspath(os.path.dirname(__file__)) output_path = os.path.join(current_directory, 'source') cmd_path = 'sphinx-apidoc' if hasattr(sys, 'real_prefix'): # Check to see if we are in a virtualenv ...
[ "def", "run_apidoc", "(", "_", ")", ":", "current_directory", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "output_path", "=", "os", ".", "path", ".", "join", "(", "current_directory", ",", ...
Heler function for run apidoc as part of the build.
[ "Heler", "function", "for", "run", "apidoc", "as", "part", "of", "the", "build", "." ]
train
https://github.com/almcc/cinder-data/blob/4159a5186c4b4fc32354749892e86130530f6ec5/docs/conf.py#L23-L31
mayfield/shellish
shellish/layout/column.py
columnize
def columnize(items, width=None, file=sys.stdout): """ Smart display width handling when showing a list of stuff. """ if not items: return if width is None: width = shutil.get_terminal_size()[0] if file is sys.stdout else 80 items = [rendering.vtmlrender(x) for x in items] maxcol = m...
python
def columnize(items, width=None, file=sys.stdout): """ Smart display width handling when showing a list of stuff. """ if not items: return if width is None: width = shutil.get_terminal_size()[0] if file is sys.stdout else 80 items = [rendering.vtmlrender(x) for x in items] maxcol = m...
[ "def", "columnize", "(", "items", ",", "width", "=", "None", ",", "file", "=", "sys", ".", "stdout", ")", ":", "if", "not", "items", ":", "return", "if", "width", "is", "None", ":", "width", "=", "shutil", ".", "get_terminal_size", "(", ")", "[", "...
Smart display width handling when showing a list of stuff.
[ "Smart", "display", "width", "handling", "when", "showing", "a", "list", "of", "stuff", "." ]
train
https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/column.py#L11-L28
armenzg/pulse_replay
scripts/empty_queue.py
parse_args
def parse_args(argv=None): """Parse command line options.""" parser = ArgumentParser() parser.add_argument('--password', dest="password", type=str) parser.add_argument('--user', dest="user", type=str) parser.add_argument('--config-file', dest="config_file", type=str) options = parser.parse_args...
python
def parse_args(argv=None): """Parse command line options.""" parser = ArgumentParser() parser.add_argument('--password', dest="password", type=str) parser.add_argument('--user', dest="user", type=str) parser.add_argument('--config-file', dest="config_file", type=str) options = parser.parse_args...
[ "def", "parse_args", "(", "argv", "=", "None", ")", ":", "parser", "=", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'--password'", ",", "dest", "=", "\"password\"", ",", "type", "=", "str", ")", "parser", ".", "add_argument", "(", "'...
Parse command line options.
[ "Parse", "command", "line", "options", "." ]
train
https://github.com/armenzg/pulse_replay/blob/d3fae9f445aaaeb58d17898a597524375e9bf3ce/scripts/empty_queue.py#L31-L39
drongo-framework/drongo
drongo/managers/url.py
UrlManager.add
def add(self, pattern, method=None, call=None, name=None): """Add a url pattern. Args: pattern (:obj:`str`): URL pattern to add. This is usually '/' separated path. Parts of the URL can be parameterised using curly braces. Examples: "/", "/pat...
python
def add(self, pattern, method=None, call=None, name=None): """Add a url pattern. Args: pattern (:obj:`str`): URL pattern to add. This is usually '/' separated path. Parts of the URL can be parameterised using curly braces. Examples: "/", "/pat...
[ "def", "add", "(", "self", ",", "pattern", ",", "method", "=", "None", ",", "call", "=", "None", ",", "name", "=", "None", ")", ":", "if", "not", "pattern", ".", "endswith", "(", "'/'", ")", ":", "pattern", "+=", "'/'", "parts", "=", "tuple", "("...
Add a url pattern. Args: pattern (:obj:`str`): URL pattern to add. This is usually '/' separated path. Parts of the URL can be parameterised using curly braces. Examples: "/", "/path/to/resource", "/resoures/{param}" method (:obj:`str`, :o...
[ "Add", "a", "url", "pattern", "." ]
train
https://github.com/drongo-framework/drongo/blob/487edb370ae329f370bcf3b433ed3f28ba4c1d8c/drongo/managers/url.py#L13-L48
drongo-framework/drongo
drongo/managers/url.py
UrlManager.find_call
def find_call(self, path, method): """Find callable for the specified URL path and HTTP method. Args: path (:obj:`str`): URL path to match method (:obj:`str`): HTTP method Note: A trailing '/' is always assumed in the path. """ if not path.en...
python
def find_call(self, path, method): """Find callable for the specified URL path and HTTP method. Args: path (:obj:`str`): URL path to match method (:obj:`str`): HTTP method Note: A trailing '/' is always assumed in the path. """ if not path.en...
[ "def", "find_call", "(", "self", ",", "path", ",", "method", ")", ":", "if", "not", "path", ".", "endswith", "(", "'/'", ")", ":", "path", "+=", "'/'", "path", "=", "path", ".", "split", "(", "'/'", ")", "[", "1", ":", "]", "return", "self", "....
Find callable for the specified URL path and HTTP method. Args: path (:obj:`str`): URL path to match method (:obj:`str`): HTTP method Note: A trailing '/' is always assumed in the path.
[ "Find", "callable", "for", "the", "specified", "URL", "path", "and", "HTTP", "method", "." ]
train
https://github.com/drongo-framework/drongo/blob/487edb370ae329f370bcf3b433ed3f28ba4c1d8c/drongo/managers/url.py#L50-L63
edwards-lab/libGWAS
libgwas/standardizer.py
StandardizedVariable.get_variables
def get_variables(self, missing_in_geno=None): """Extract the complete set of data based on missingness over all for the current locus. :param missing_in_geno: mask associated with missingness in genotype :return: (phenotypes, covariates, nonmissing used for this set of vars) ""...
python
def get_variables(self, missing_in_geno=None): """Extract the complete set of data based on missingness over all for the current locus. :param missing_in_geno: mask associated with missingness in genotype :return: (phenotypes, covariates, nonmissing used for this set of vars) ""...
[ "def", "get_variables", "(", "self", ",", "missing_in_geno", "=", "None", ")", ":", "count", "=", "0", "mismatch", "=", "0", "if", "missing_in_geno", "is", "None", ":", "nonmissing", "=", "numpy", ".", "invert", "(", "self", ".", "missing", "[", "self", ...
Extract the complete set of data based on missingness over all for the current locus. :param missing_in_geno: mask associated with missingness in genotype :return: (phenotypes, covariates, nonmissing used for this set of vars)
[ "Extract", "the", "complete", "set", "of", "data", "based", "on", "missingness", "over", "all", "for", "the", "current", "locus", "." ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/standardizer.py#L65-L92
edwards-lab/libGWAS
libgwas/standardizer.py
NoStandardization.standardize
def standardize(self): """Standardize the variables within a range [-1.0 and 1.0] This replaces the local copies of this data. When it's time to scale back, use destandardize from the datasource for that. """ self.covariates = self.datasource.covariate_data self.phenoty...
python
def standardize(self): """Standardize the variables within a range [-1.0 and 1.0] This replaces the local copies of this data. When it's time to scale back, use destandardize from the datasource for that. """ self.covariates = self.datasource.covariate_data self.phenoty...
[ "def", "standardize", "(", "self", ")", ":", "self", ".", "covariates", "=", "self", ".", "datasource", ".", "covariate_data", "self", ".", "phenotypes", "=", "self", ".", "datasource", ".", "phenotype_data" ]
Standardize the variables within a range [-1.0 and 1.0] This replaces the local copies of this data. When it's time to scale back, use destandardize from the datasource for that.
[ "Standardize", "the", "variables", "within", "a", "range", "[", "-", "1", ".", "0", "and", "1", ".", "0", "]" ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/standardizer.py#L137-L145
gambogi/CSHLDAP
CSHLDAP.py
dateFromLDAPTimestamp
def dateFromLDAPTimestamp(timestamp): """ Takes an LDAP date (In the form YYYYmmdd with whatever is after that) and returns a datetime.date object. """ # only check the first 8 characters: YYYYmmdd numberOfCharacters = len("YYYYmmdd") timestamp = timestamp[:numberOfCharacters] tr...
python
def dateFromLDAPTimestamp(timestamp): """ Takes an LDAP date (In the form YYYYmmdd with whatever is after that) and returns a datetime.date object. """ # only check the first 8 characters: YYYYmmdd numberOfCharacters = len("YYYYmmdd") timestamp = timestamp[:numberOfCharacters] tr...
[ "def", "dateFromLDAPTimestamp", "(", "timestamp", ")", ":", "# only check the first 8 characters: YYYYmmdd", "numberOfCharacters", "=", "len", "(", "\"YYYYmmdd\"", ")", "timestamp", "=", "timestamp", "[", ":", "numberOfCharacters", "]", "try", ":", "day", "=", "dateti...
Takes an LDAP date (In the form YYYYmmdd with whatever is after that) and returns a datetime.date object.
[ "Takes", "an", "LDAP", "date", "(", "In", "the", "form", "YYYYmmdd", "with", "whatever", "is", "after", "that", ")", "and", "returns", "a", "datetime", ".", "date", "object", "." ]
train
https://github.com/gambogi/CSHLDAP/blob/09cb754b1e72437834e0d8cb4c7ac1830cfa6829/CSHLDAP.py#L336-L348
gambogi/CSHLDAP
CSHLDAP.py
CSHLDAP.members
def members(self, uid="*", objects=False): """ members() issues an ldap query for all users, and returns a dict for each matching entry. This can be quite slow, and takes roughly 3s to complete. You may optionally restrict the scope by specifying a uid, which is roughly equiv...
python
def members(self, uid="*", objects=False): """ members() issues an ldap query for all users, and returns a dict for each matching entry. This can be quite slow, and takes roughly 3s to complete. You may optionally restrict the scope by specifying a uid, which is roughly equiv...
[ "def", "members", "(", "self", ",", "uid", "=", "\"*\"", ",", "objects", "=", "False", ")", ":", "entries", "=", "self", ".", "search", "(", "uid", "=", "'*'", ")", "if", "objects", ":", "return", "self", ".", "memberObjects", "(", "entries", ")", ...
members() issues an ldap query for all users, and returns a dict for each matching entry. This can be quite slow, and takes roughly 3s to complete. You may optionally restrict the scope by specifying a uid, which is roughly equivalent to a search(uid='foo')
[ "members", "()", "issues", "an", "ldap", "query", "for", "all", "users", "and", "returns", "a", "dict", "for", "each", "matching", "entry", ".", "This", "can", "be", "quite", "slow", "and", "takes", "roughly", "3s", "to", "complete", ".", "You", "may", ...
train
https://github.com/gambogi/CSHLDAP/blob/09cb754b1e72437834e0d8cb4c7ac1830cfa6829/CSHLDAP.py#L35-L47
gambogi/CSHLDAP
CSHLDAP.py
CSHLDAP.member
def member(self, user, objects=False): """ Returns a user as a dict of attributes """ try: member = self.search(uid=user, objects=objects)[0] except IndexError: return None if objects: return member return member[1]
python
def member(self, user, objects=False): """ Returns a user as a dict of attributes """ try: member = self.search(uid=user, objects=objects)[0] except IndexError: return None if objects: return member return member[1]
[ "def", "member", "(", "self", ",", "user", ",", "objects", "=", "False", ")", ":", "try", ":", "member", "=", "self", ".", "search", "(", "uid", "=", "user", ",", "objects", "=", "objects", ")", "[", "0", "]", "except", "IndexError", ":", "return",...
Returns a user as a dict of attributes
[ "Returns", "a", "user", "as", "a", "dict", "of", "attributes" ]
train
https://github.com/gambogi/CSHLDAP/blob/09cb754b1e72437834e0d8cb4c7ac1830cfa6829/CSHLDAP.py#L49-L58
gambogi/CSHLDAP
CSHLDAP.py
CSHLDAP.eboard
def eboard(self, objects=False): """ Returns a list of eboard members formatted as a search inserts an extra ['commmittee'] attribute """ # self.committee used as base because that's where eboard # info is kept committees = self.search(base = self.committees, cn='*') ...
python
def eboard(self, objects=False): """ Returns a list of eboard members formatted as a search inserts an extra ['commmittee'] attribute """ # self.committee used as base because that's where eboard # info is kept committees = self.search(base = self.committees, cn='*') ...
[ "def", "eboard", "(", "self", ",", "objects", "=", "False", ")", ":", "# self.committee used as base because that's where eboard", "# info is kept", "committees", "=", "self", ".", "search", "(", "base", "=", "self", ".", "committees", ",", "cn", "=", "'*'", ")"...
Returns a list of eboard members formatted as a search inserts an extra ['commmittee'] attribute
[ "Returns", "a", "list", "of", "eboard", "members", "formatted", "as", "a", "search", "inserts", "an", "extra", "[", "commmittee", "]", "attribute" ]
train
https://github.com/gambogi/CSHLDAP/blob/09cb754b1e72437834e0d8cb4c7ac1830cfa6829/CSHLDAP.py#L60-L75
gambogi/CSHLDAP
CSHLDAP.py
CSHLDAP.drinkAdmins
def drinkAdmins(self, objects=False): """ Returns a list of drink admins uids """ admins = self.group('drink', objects=objects) return admins
python
def drinkAdmins(self, objects=False): """ Returns a list of drink admins uids """ admins = self.group('drink', objects=objects) return admins
[ "def", "drinkAdmins", "(", "self", ",", "objects", "=", "False", ")", ":", "admins", "=", "self", ".", "group", "(", "'drink'", ",", "objects", "=", "objects", ")", "return", "admins" ]
Returns a list of drink admins uids
[ "Returns", "a", "list", "of", "drink", "admins", "uids" ]
train
https://github.com/gambogi/CSHLDAP/blob/09cb754b1e72437834e0d8cb4c7ac1830cfa6829/CSHLDAP.py#L99-L103
gambogi/CSHLDAP
CSHLDAP.py
CSHLDAP.search
def search( self, base=False, trim=False, objects=False, **kwargs ): """ Returns matching entries for search in ldap structured as [(dn, {attributes})] UNLESS searching by dn, in which case the first match is returned """ scope = pyldap.SCOPE_SUBTREE i...
python
def search( self, base=False, trim=False, objects=False, **kwargs ): """ Returns matching entries for search in ldap structured as [(dn, {attributes})] UNLESS searching by dn, in which case the first match is returned """ scope = pyldap.SCOPE_SUBTREE i...
[ "def", "search", "(", "self", ",", "base", "=", "False", ",", "trim", "=", "False", ",", "objects", "=", "False", ",", "*", "*", "kwargs", ")", ":", "scope", "=", "pyldap", ".", "SCOPE_SUBTREE", "if", "not", "base", ":", "base", "=", "self", ".", ...
Returns matching entries for search in ldap structured as [(dn, {attributes})] UNLESS searching by dn, in which case the first match is returned
[ "Returns", "matching", "entries", "for", "search", "in", "ldap", "structured", "as", "[", "(", "dn", "{", "attributes", "}", ")", "]", "UNLESS", "searching", "by", "dn", "in", "which", "case", "the", "first", "match", "is", "returned" ]
train
https://github.com/gambogi/CSHLDAP/blob/09cb754b1e72437834e0d8cb4c7ac1830cfa6829/CSHLDAP.py#L112-L145
gambogi/CSHLDAP
CSHLDAP.py
Member.isBirthday
def isBirthday(self): """ Is it the user's birthday today? """ if not self.birthday: return False birthday = self.birthdate() today = date.today() return (birthday.month == today.month and birthday.day == today.day)
python
def isBirthday(self): """ Is it the user's birthday today? """ if not self.birthday: return False birthday = self.birthdate() today = date.today() return (birthday.month == today.month and birthday.day == today.day)
[ "def", "isBirthday", "(", "self", ")", ":", "if", "not", "self", ".", "birthday", ":", "return", "False", "birthday", "=", "self", ".", "birthdate", "(", ")", "today", "=", "date", ".", "today", "(", ")", "return", "(", "birthday", ".", "month", "=="...
Is it the user's birthday today?
[ "Is", "it", "the", "user", "s", "birthday", "today?" ]
train
https://github.com/gambogi/CSHLDAP/blob/09cb754b1e72437834e0d8cb4c7ac1830cfa6829/CSHLDAP.py#L263-L271
gambogi/CSHLDAP
CSHLDAP.py
Member.age
def age(self): """ Returns the user's age, determined by their birthdate() """ if not self.birthdate(): return -1 adjuster = 0 today = date.today() birthday = self.birthdate() if today.month == birthday.month: if today.day < birthday.day: ...
python
def age(self): """ Returns the user's age, determined by their birthdate() """ if not self.birthdate(): return -1 adjuster = 0 today = date.today() birthday = self.birthdate() if today.month == birthday.month: if today.day < birthday.day: ...
[ "def", "age", "(", "self", ")", ":", "if", "not", "self", ".", "birthdate", "(", ")", ":", "return", "-", "1", "adjuster", "=", "0", "today", "=", "date", ".", "today", "(", ")", "birthday", "=", "self", ".", "birthdate", "(", ")", "if", "today",...
Returns the user's age, determined by their birthdate()
[ "Returns", "the", "user", "s", "age", "determined", "by", "their", "birthdate", "()" ]
train
https://github.com/gambogi/CSHLDAP/blob/09cb754b1e72437834e0d8cb4c7ac1830cfa6829/CSHLDAP.py#L290-L303
gambogi/CSHLDAP
CSHLDAP.py
Member.reload
def reload(self): """ If there is an LDAP connection, query it for another instance of this member and set its internal dictionary to that result. """ if not self.ldap: return self.memberDict = self.ldap.member(self.uid)
python
def reload(self): """ If there is an LDAP connection, query it for another instance of this member and set its internal dictionary to that result. """ if not self.ldap: return self.memberDict = self.ldap.member(self.uid)
[ "def", "reload", "(", "self", ")", ":", "if", "not", "self", ".", "ldap", ":", "return", "self", ".", "memberDict", "=", "self", ".", "ldap", ".", "member", "(", "self", ".", "uid", ")" ]
If there is an LDAP connection, query it for another instance of this member and set its internal dictionary to that result.
[ "If", "there", "is", "an", "LDAP", "connection", "query", "it", "for", "another", "instance", "of", "this", "member", "and", "set", "its", "internal", "dictionary", "to", "that", "result", "." ]
train
https://github.com/gambogi/CSHLDAP/blob/09cb754b1e72437834e0d8cb4c7ac1830cfa6829/CSHLDAP.py#L305-L312
gambogi/CSHLDAP
CSHLDAP.py
Member.fullName
def fullName(self): """ Returns a reliable full name (firstName lastName) for every member (as of the writing of this comment.) """ if self.givenName and self.sn: return "{0} {1}".format(self.givenName, self.sn) if self.givenName: return self.givenName...
python
def fullName(self): """ Returns a reliable full name (firstName lastName) for every member (as of the writing of this comment.) """ if self.givenName and self.sn: return "{0} {1}".format(self.givenName, self.sn) if self.givenName: return self.givenName...
[ "def", "fullName", "(", "self", ")", ":", "if", "self", ".", "givenName", "and", "self", ".", "sn", ":", "return", "\"{0} {1}\"", ".", "format", "(", "self", ".", "givenName", ",", "self", ".", "sn", ")", "if", "self", ".", "givenName", ":", "return"...
Returns a reliable full name (firstName lastName) for every member (as of the writing of this comment.)
[ "Returns", "a", "reliable", "full", "name", "(", "firstName", "lastName", ")", "for", "every", "member", "(", "as", "of", "the", "writing", "of", "this", "comment", ".", ")" ]
train
https://github.com/gambogi/CSHLDAP/blob/09cb754b1e72437834e0d8cb4c7ac1830cfa6829/CSHLDAP.py#L314-L324
skitazaki/python-clitool
clitool/processor.py
Streamer.consume
def consume(self, stream, source=None, chunksize=1): """ Consuming given strem object and returns processing stats. :param stream: streaming object to consume :type stream: iterable :param source: source of stream to consume :type source: string :param chunksize: chunk s...
python
def consume(self, stream, source=None, chunksize=1): """ Consuming given strem object and returns processing stats. :param stream: streaming object to consume :type stream: iterable :param source: source of stream to consume :type source: string :param chunksize: chunk s...
[ "def", "consume", "(", "self", ",", "stream", ",", "source", "=", "None", ",", "chunksize", "=", "1", ")", ":", "stats", "=", "{", "PROCESSING_TOTAL", ":", "0", ",", "PROCESSING_SKIPPED", ":", "0", ",", "PROCESSING_SUCCESS", ":", "0", ",", "PROCESSING_ER...
Consuming given strem object and returns processing stats. :param stream: streaming object to consume :type stream: iterable :param source: source of stream to consume :type source: string :param chunksize: chunk size for multiprocessing :type chunksize: integer ...
[ "Consuming", "given", "strem", "object", "and", "returns", "processing", "stats", "." ]
train
https://github.com/skitazaki/python-clitool/blob/4971f8d093d51c6fd0e6cc536bbb597f78b570ab/clitool/processor.py#L169-L240
skitazaki/python-clitool
clitool/processor.py
CliHandler.reader
def reader(self, fp, encoding): """ Simple `open` wrapper for several file types. This supports ``.gz`` and ``.json``. :param fp: opened file :type fp: file pointer :param encoding: encoding of opened file :type encoding: string :rtype: file pointer """ ...
python
def reader(self, fp, encoding): """ Simple `open` wrapper for several file types. This supports ``.gz`` and ``.json``. :param fp: opened file :type fp: file pointer :param encoding: encoding of opened file :type encoding: string :rtype: file pointer """ ...
[ "def", "reader", "(", "self", ",", "fp", ",", "encoding", ")", ":", "_", ",", "suffix", "=", "os", ".", "path", ".", "splitext", "(", "fp", ".", "name", ")", "if", "suffix", "==", "'.gz'", ":", "fp", ".", "close", "(", ")", "return", "gzip", "....
Simple `open` wrapper for several file types. This supports ``.gz`` and ``.json``. :param fp: opened file :type fp: file pointer :param encoding: encoding of opened file :type encoding: string :rtype: file pointer
[ "Simple", "open", "wrapper", "for", "several", "file", "types", ".", "This", "supports", ".", "gz", "and", ".", "json", "." ]
train
https://github.com/skitazaki/python-clitool/blob/4971f8d093d51c6fd0e6cc536bbb597f78b570ab/clitool/processor.py#L257-L277
skitazaki/python-clitool
clitool/processor.py
CliHandler.handle
def handle(self, files, encoding, chunksize=1): """ Handle given files with given encoding. :param files: opened files. :type files: list :param encoding: encoding of opened file :type encoding: string :param chunksize: a number of chunk :type chunksize: int ...
python
def handle(self, files, encoding, chunksize=1): """ Handle given files with given encoding. :param files: opened files. :type files: list :param encoding: encoding of opened file :type encoding: string :param chunksize: a number of chunk :type chunksize: int ...
[ "def", "handle", "(", "self", ",", "files", ",", "encoding", ",", "chunksize", "=", "1", ")", ":", "stats", "=", "[", "]", "if", "files", ":", "logging", ".", "info", "(", "\"Input file count: %d\"", ",", "len", "(", "files", ")", ")", "for", "fp", ...
Handle given files with given encoding. :param files: opened files. :type files: list :param encoding: encoding of opened file :type encoding: string :param chunksize: a number of chunk :type chunksize: int :rtype: list
[ "Handle", "given", "files", "with", "given", "encoding", "." ]
train
https://github.com/skitazaki/python-clitool/blob/4971f8d093d51c6fd0e6cc536bbb597f78b570ab/clitool/processor.py#L279-L306
vivainio/argp
argp.py
init
def init(parser = None): """ module needs to be initialized by 'init'. Can be called with parser to use a pre-built parser, otherwise a simple default parser is created """ global p,subparsers if parser is None: p = argparse.ArgumentParser() else: p = parser arg = p.ad...
python
def init(parser = None): """ module needs to be initialized by 'init'. Can be called with parser to use a pre-built parser, otherwise a simple default parser is created """ global p,subparsers if parser is None: p = argparse.ArgumentParser() else: p = parser arg = p.ad...
[ "def", "init", "(", "parser", "=", "None", ")", ":", "global", "p", ",", "subparsers", "if", "parser", "is", "None", ":", "p", "=", "argparse", ".", "ArgumentParser", "(", ")", "else", ":", "p", "=", "parser", "arg", "=", "p", ".", "add_argument", ...
module needs to be initialized by 'init'. Can be called with parser to use a pre-built parser, otherwise a simple default parser is created
[ "module", "needs", "to", "be", "initialized", "by", "init", "." ]
train
https://github.com/vivainio/argp/blob/ad90edbecd5f84d7dce09a2bd98e1e9d98140f1e/argp.py#L21-L36
vivainio/argp
argp.py
sub
def sub(name, func,**kwarg): """ Add subparser """ sp = subparsers.add_parser(name, **kwarg) sp.set_defaults(func=func) sp.arg = sp.add_argument return sp
python
def sub(name, func,**kwarg): """ Add subparser """ sp = subparsers.add_parser(name, **kwarg) sp.set_defaults(func=func) sp.arg = sp.add_argument return sp
[ "def", "sub", "(", "name", ",", "func", ",", "*", "*", "kwarg", ")", ":", "sp", "=", "subparsers", ".", "add_parser", "(", "name", ",", "*", "*", "kwarg", ")", "sp", ".", "set_defaults", "(", "func", "=", "func", ")", "sp", ".", "arg", "=", "sp...
Add subparser
[ "Add", "subparser" ]
train
https://github.com/vivainio/argp/blob/ad90edbecd5f84d7dce09a2bd98e1e9d98140f1e/argp.py#L51-L58
ncc-tools/python-pa-api
paapi/paapi.py
PaAuth.authenticate
def authenticate(self): """ Authenticates with the PA Oauth system """ if self._auth_token is None or self._token_expiry < time.time(): self._perform_auth() yield self._auth_token
python
def authenticate(self): """ Authenticates with the PA Oauth system """ if self._auth_token is None or self._token_expiry < time.time(): self._perform_auth() yield self._auth_token
[ "def", "authenticate", "(", "self", ")", ":", "if", "self", ".", "_auth_token", "is", "None", "or", "self", ".", "_token_expiry", "<", "time", ".", "time", "(", ")", ":", "self", ".", "_perform_auth", "(", ")", "yield", "self", ".", "_auth_token" ]
Authenticates with the PA Oauth system
[ "Authenticates", "with", "the", "PA", "Oauth", "system" ]
train
https://github.com/ncc-tools/python-pa-api/blob/a27481dd323d282d0f4457586198d9faec896f11/paapi/paapi.py#L65-L72
ncc-tools/python-pa-api
paapi/paapi.py
PaApi._query_api
def _query_api(self, method, url, fields=None, extra_headers=None, req_body=None): """ Abstracts http queries to the API """ with self.auth.authenticate() as token: logging.debug('PA Authentication returned token %s', token) headers = { 'Authorizat...
python
def _query_api(self, method, url, fields=None, extra_headers=None, req_body=None): """ Abstracts http queries to the API """ with self.auth.authenticate() as token: logging.debug('PA Authentication returned token %s', token) headers = { 'Authorizat...
[ "def", "_query_api", "(", "self", ",", "method", ",", "url", ",", "fields", "=", "None", ",", "extra_headers", "=", "None", ",", "req_body", "=", "None", ")", ":", "with", "self", ".", "auth", ".", "authenticate", "(", ")", "as", "token", ":", "loggi...
Abstracts http queries to the API
[ "Abstracts", "http", "queries", "to", "the", "API" ]
train
https://github.com/ncc-tools/python-pa-api/blob/a27481dd323d282d0f4457586198d9faec896f11/paapi/paapi.py#L121-L143
ncc-tools/python-pa-api
paapi/paapi.py
PaApi.get_all_jobtemplates
def get_all_jobtemplates(self): """ Retrieves the list of jobTemplates for the current realm. """ endpoint = self._build_url('jobTemplates', { 'paginationPageSize': self.PAGE_SIZE }) data = self._query_api('GET', endpoint) return data['results']
python
def get_all_jobtemplates(self): """ Retrieves the list of jobTemplates for the current realm. """ endpoint = self._build_url('jobTemplates', { 'paginationPageSize': self.PAGE_SIZE }) data = self._query_api('GET', endpoint) return data['results']
[ "def", "get_all_jobtemplates", "(", "self", ")", ":", "endpoint", "=", "self", ".", "_build_url", "(", "'jobTemplates'", ",", "{", "'paginationPageSize'", ":", "self", ".", "PAGE_SIZE", "}", ")", "data", "=", "self", ".", "_query_api", "(", "'GET'", ",", "...
Retrieves the list of jobTemplates for the current realm.
[ "Retrieves", "the", "list", "of", "jobTemplates", "for", "the", "current", "realm", "." ]
train
https://github.com/ncc-tools/python-pa-api/blob/a27481dd323d282d0f4457586198d9faec896f11/paapi/paapi.py#L151-L159
ncc-tools/python-pa-api
paapi/paapi.py
PaApi.create_job_template
def create_job_template(self, template): """ Creates a job template """ endpoint = self._build_url('jobTemplates') data = self._query_api('POST', endpoint, None, {'Content-Type': 'applica...
python
def create_job_template(self, template): """ Creates a job template """ endpoint = self._build_url('jobTemplates') data = self._query_api('POST', endpoint, None, {'Content-Type': 'applica...
[ "def", "create_job_template", "(", "self", ",", "template", ")", ":", "endpoint", "=", "self", ".", "_build_url", "(", "'jobTemplates'", ")", "data", "=", "self", ".", "_query_api", "(", "'POST'", ",", "endpoint", ",", "None", ",", "{", "'Content-Type'", "...
Creates a job template
[ "Creates", "a", "job", "template" ]
train
https://github.com/ncc-tools/python-pa-api/blob/a27481dd323d282d0f4457586198d9faec896f11/paapi/paapi.py#L182-L192
ncc-tools/python-pa-api
paapi/paapi.py
PaApi.create_job
def create_job(self, job_template_uri): """ Creates a job """ endpoint = self._build_url('jobs') data = self._query_api('POST', endpoint, None, {'Content-Type': 'application/json'}, ...
python
def create_job(self, job_template_uri): """ Creates a job """ endpoint = self._build_url('jobs') data = self._query_api('POST', endpoint, None, {'Content-Type': 'application/json'}, ...
[ "def", "create_job", "(", "self", ",", "job_template_uri", ")", ":", "endpoint", "=", "self", ".", "_build_url", "(", "'jobs'", ")", "data", "=", "self", ".", "_query_api", "(", "'POST'", ",", "endpoint", ",", "None", ",", "{", "'Content-Type'", ":", "'a...
Creates a job
[ "Creates", "a", "job" ]
train
https://github.com/ncc-tools/python-pa-api/blob/a27481dd323d282d0f4457586198d9faec896f11/paapi/paapi.py#L193-L203
wdbm/datavision
datavision.py
normalize_to_range
def normalize_to_range( values, minimum = 0.0, maximum = 1.0 ): """ This function normalizes values of a list to a specified range and returns the original object if the values are not of the types integer or float. """ normalized_values = [] minimum_value = min(values) max...
python
def normalize_to_range( values, minimum = 0.0, maximum = 1.0 ): """ This function normalizes values of a list to a specified range and returns the original object if the values are not of the types integer or float. """ normalized_values = [] minimum_value = min(values) max...
[ "def", "normalize_to_range", "(", "values", ",", "minimum", "=", "0.0", ",", "maximum", "=", "1.0", ")", ":", "normalized_values", "=", "[", "]", "minimum_value", "=", "min", "(", "values", ")", "maximum_value", "=", "max", "(", "values", ")", "for", "va...
This function normalizes values of a list to a specified range and returns the original object if the values are not of the types integer or float.
[ "This", "function", "normalizes", "values", "of", "a", "list", "to", "a", "specified", "range", "and", "returns", "the", "original", "object", "if", "the", "values", "are", "not", "of", "the", "types", "integer", "or", "float", "." ]
train
https://github.com/wdbm/datavision/blob/b6f26287264632d6f8c9f8911aaf3a8e4fc4dcf5/datavision.py#L1206-L1225
wdbm/datavision
datavision.py
list_element_combinations_variadic
def list_element_combinations_variadic( elements_specification ): """ This function accepts a specification of lists of elements for each place in lists in the form of a list, the elements of which are lists of possible elements and returns a list of lists corresponding to the combinations of ...
python
def list_element_combinations_variadic( elements_specification ): """ This function accepts a specification of lists of elements for each place in lists in the form of a list, the elements of which are lists of possible elements and returns a list of lists corresponding to the combinations of ...
[ "def", "list_element_combinations_variadic", "(", "elements_specification", ")", ":", "lists", "=", "[", "list", "(", "list_generated", ")", "for", "index", ",", "element_specification", "in", "enumerate", "(", "elements_specification", ")", "for", "list_generated", "...
This function accepts a specification of lists of elements for each place in lists in the form of a list, the elements of which are lists of possible elements and returns a list of lists corresponding to the combinations of elements of the specification with varying numbers of elements. For example, th...
[ "This", "function", "accepts", "a", "specification", "of", "lists", "of", "elements", "for", "each", "place", "in", "lists", "in", "the", "form", "of", "a", "list", "the", "elements", "of", "which", "are", "lists", "of", "possible", "elements", "and", "ret...
train
https://github.com/wdbm/datavision/blob/b6f26287264632d6f8c9f8911aaf3a8e4fc4dcf5/datavision.py#L1263-L1293
wdbm/datavision
datavision.py
correlation_linear
def correlation_linear( values_1, values_2, printout = None ): """ This function calculates the Pearson product-moment correlation coefficient. This is a measure of the linear collelation of two variables. The value can be between +1 and -1 inclusive, where 1 is total positive correlati...
python
def correlation_linear( values_1, values_2, printout = None ): """ This function calculates the Pearson product-moment correlation coefficient. This is a measure of the linear collelation of two variables. The value can be between +1 and -1 inclusive, where 1 is total positive correlati...
[ "def", "correlation_linear", "(", "values_1", ",", "values_2", ",", "printout", "=", "None", ")", ":", "r", ",", "p_value", "=", "scipy", ".", "stats", ".", "pearsonr", "(", "values_1", ",", "values_2", ")", "if", "printout", "is", "not", "True", ":", ...
This function calculates the Pearson product-moment correlation coefficient. This is a measure of the linear collelation of two variables. The value can be between +1 and -1 inclusive, where 1 is total positive correlation, 0 is no correlation and -1 is total negative correlation. It is a measure of the ...
[ "This", "function", "calculates", "the", "Pearson", "product", "-", "moment", "correlation", "coefficient", ".", "This", "is", "a", "measure", "of", "the", "linear", "collelation", "of", "two", "variables", ".", "The", "value", "can", "be", "between", "+", "...
train
https://github.com/wdbm/datavision/blob/b6f26287264632d6f8c9f8911aaf3a8e4fc4dcf5/datavision.py#L1295-L1323
wdbm/datavision
datavision.py
propose_number_of_bins
def propose_number_of_bins( values, binning_logic_system = None, ): """ This function returns a proposal for binning for a histogram of a specified list using an optional specified binning logic system. Freedman-Diaconis: bin width is proportional to the interquartile range of ...
python
def propose_number_of_bins( values, binning_logic_system = None, ): """ This function returns a proposal for binning for a histogram of a specified list using an optional specified binning logic system. Freedman-Diaconis: bin width is proportional to the interquartile range of ...
[ "def", "propose_number_of_bins", "(", "values", ",", "binning_logic_system", "=", "None", ",", ")", ":", "# Set the default binning logic system.", "if", "binning_logic_system", "is", "None", ":", "binning_logic_system", "=", "\"Scott\"", "# Engage the requested logic system....
This function returns a proposal for binning for a histogram of a specified list using an optional specified binning logic system. Freedman-Diaconis: bin width is proportional to the interquartile range of the data divided by the cube root of the size of the data Scott: ...
[ "This", "function", "returns", "a", "proposal", "for", "binning", "for", "a", "histogram", "of", "a", "specified", "list", "using", "an", "optional", "specified", "binning", "logic", "system", "." ]
train
https://github.com/wdbm/datavision/blob/b6f26287264632d6f8c9f8911aaf3a8e4fc4dcf5/datavision.py#L1401-L1442
wdbm/datavision
datavision.py
steppify
def steppify(x, y): """ Steppify a curve (x, y). This is useful for filling histograms manually. """ dx = 0.5 * (x[1:] + x[:-1]) xx = numpy.zeros(2 * len(dx), dtype=float) yy = numpy.zeros(2 * len(y), dtype=float) xx[0::2], xx[1::2] = dx, dx yy[0::2], yy[1::2] = y, y xx = numpy.con...
python
def steppify(x, y): """ Steppify a curve (x, y). This is useful for filling histograms manually. """ dx = 0.5 * (x[1:] + x[:-1]) xx = numpy.zeros(2 * len(dx), dtype=float) yy = numpy.zeros(2 * len(y), dtype=float) xx[0::2], xx[1::2] = dx, dx yy[0::2], yy[1::2] = y, y xx = numpy.con...
[ "def", "steppify", "(", "x", ",", "y", ")", ":", "dx", "=", "0.5", "*", "(", "x", "[", "1", ":", "]", "+", "x", "[", ":", "-", "1", "]", ")", "xx", "=", "numpy", ".", "zeros", "(", "2", "*", "len", "(", "dx", ")", ",", "dtype", "=", "...
Steppify a curve (x, y). This is useful for filling histograms manually.
[ "Steppify", "a", "curve", "(", "x", "y", ")", ".", "This", "is", "useful", "for", "filling", "histograms", "manually", "." ]
train
https://github.com/wdbm/datavision/blob/b6f26287264632d6f8c9f8911aaf3a8e4fc4dcf5/datavision.py#L2800-L2816
wdbm/datavision
datavision.py
stemify
def stemify(x, y): """ Stemify a curve (x, y). This is useful for filling histograms manually. """ xx = numpy.zeros(3 * len(x), dtype=float) yy = numpy.zeros(3 * len(y), dtype=float) xx[0::3], xx[1::3], xx[2::3] = x, x, x yy[1::3] = y return xx, yy
python
def stemify(x, y): """ Stemify a curve (x, y). This is useful for filling histograms manually. """ xx = numpy.zeros(3 * len(x), dtype=float) yy = numpy.zeros(3 * len(y), dtype=float) xx[0::3], xx[1::3], xx[2::3] = x, x, x yy[1::3] = y return xx, yy
[ "def", "stemify", "(", "x", ",", "y", ")", ":", "xx", "=", "numpy", ".", "zeros", "(", "3", "*", "len", "(", "x", ")", ",", "dtype", "=", "float", ")", "yy", "=", "numpy", ".", "zeros", "(", "3", "*", "len", "(", "y", ")", ",", "dtype", "...
Stemify a curve (x, y). This is useful for filling histograms manually.
[ "Stemify", "a", "curve", "(", "x", "y", ")", ".", "This", "is", "useful", "for", "filling", "histograms", "manually", "." ]
train
https://github.com/wdbm/datavision/blob/b6f26287264632d6f8c9f8911aaf3a8e4fc4dcf5/datavision.py#L2818-L2828
wdbm/datavision
datavision.py
transpose
def transpose(matrix): """ transpose 2D matrix (list) """ return [[x[i] for x in matrix] for i in range(len(matrix[0]))]
python
def transpose(matrix): """ transpose 2D matrix (list) """ return [[x[i] for x in matrix] for i in range(len(matrix[0]))]
[ "def", "transpose", "(", "matrix", ")", ":", "return", "[", "[", "x", "[", "i", "]", "for", "x", "in", "matrix", "]", "for", "i", "in", "range", "(", "len", "(", "matrix", "[", "0", "]", ")", ")", "]" ]
transpose 2D matrix (list)
[ "transpose", "2D", "matrix", "(", "list", ")" ]
train
https://github.com/wdbm/datavision/blob/b6f26287264632d6f8c9f8911aaf3a8e4fc4dcf5/datavision.py#L3067-L3073
wdbm/datavision
datavision.py
TTYFigureData.extent
def extent(self): """ return range of 2D data """ return [min(self.x), max(self.x), min(self.y), max(self.y)]
python
def extent(self): """ return range of 2D data """ return [min(self.x), max(self.x), min(self.y), max(self.y)]
[ "def", "extent", "(", "self", ")", ":", "return", "[", "min", "(", "self", ".", "x", ")", ",", "max", "(", "self", ".", "x", ")", ",", "min", "(", "self", ".", "y", ")", ",", "max", "(", "self", ".", "y", ")", "]" ]
return range of 2D data
[ "return", "range", "of", "2D", "data" ]
train
https://github.com/wdbm/datavision/blob/b6f26287264632d6f8c9f8911aaf3a8e4fc4dcf5/datavision.py#L2030-L2036
wdbm/datavision
datavision.py
TTYFigure._get_symbol_by_slope
def _get_symbol_by_slope( self, slope, default_symbol ): """ return line oriented approximatively along the slope value """ if slope > math.tan(3 * math.pi / 8): draw_symbol = "|" elif math.tan(math.pi / 8) < slope < math.tan(3 * math...
python
def _get_symbol_by_slope( self, slope, default_symbol ): """ return line oriented approximatively along the slope value """ if slope > math.tan(3 * math.pi / 8): draw_symbol = "|" elif math.tan(math.pi / 8) < slope < math.tan(3 * math...
[ "def", "_get_symbol_by_slope", "(", "self", ",", "slope", ",", "default_symbol", ")", ":", "if", "slope", ">", "math", ".", "tan", "(", "3", "*", "math", ".", "pi", "/", "8", ")", ":", "draw_symbol", "=", "\"|\"", "elif", "math", ".", "tan", "(", "...
return line oriented approximatively along the slope value
[ "return", "line", "oriented", "approximatively", "along", "the", "slope", "value" ]
train
https://github.com/wdbm/datavision/blob/b6f26287264632d6f8c9f8911aaf3a8e4fc4dcf5/datavision.py#L2124-L2147
wdbm/datavision
datavision.py
TTYFigure._plot_line
def _plot_line( self, start, end, data ): """ plot line from start = (x0, y0) to end = (x1, y1) """ clipped_line = self.canvas._clip_line(start, end) if clipped_line is None: return False start, end = clipped_line ...
python
def _plot_line( self, start, end, data ): """ plot line from start = (x0, y0) to end = (x1, y1) """ clipped_line = self.canvas._clip_line(start, end) if clipped_line is None: return False start, end = clipped_line ...
[ "def", "_plot_line", "(", "self", ",", "start", ",", "end", ",", "data", ")", ":", "clipped_line", "=", "self", ".", "canvas", ".", "_clip_line", "(", "start", ",", "end", ")", "if", "clipped_line", "is", "None", ":", "return", "False", "start", ",", ...
plot line from start = (x0, y0) to end = (x1, y1)
[ "plot", "line", "from", "start", "=", "(", "x0", "y0", ")", "to", "end", "=", "(", "x1", "y1", ")" ]
train
https://github.com/wdbm/datavision/blob/b6f26287264632d6f8c9f8911aaf3a8e4fc4dcf5/datavision.py#L2229-L2325
wdbm/datavision
datavision.py
TTYCanvas.limit_x
def limit_x( self, limit_lower = None, # float limit_upper = None # float ): """ get or set x limits of the current axes x_min, x_max = limit_x() # return the current limit_x limit_x(x_min, x_max) # set the limit_x to x_min, x_max """ ...
python
def limit_x( self, limit_lower = None, # float limit_upper = None # float ): """ get or set x limits of the current axes x_min, x_max = limit_x() # return the current limit_x limit_x(x_min, x_max) # set the limit_x to x_min, x_max """ ...
[ "def", "limit_x", "(", "self", ",", "limit_lower", "=", "None", ",", "# float", "limit_upper", "=", "None", "# float", ")", ":", "if", "limit_lower", "is", "None", "and", "limit_upper", "is", "None", ":", "return", "self", ".", "_limit_x", "elif", "hasattr...
get or set x limits of the current axes x_min, x_max = limit_x() # return the current limit_x limit_x(x_min, x_max) # set the limit_x to x_min, x_max
[ "get", "or", "set", "x", "limits", "of", "the", "current", "axes" ]
train
https://github.com/wdbm/datavision/blob/b6f26287264632d6f8c9f8911aaf3a8e4fc4dcf5/datavision.py#L2538-L2560
wdbm/datavision
datavision.py
TTYCanvas.limit_y
def limit_y( self, limit_lower = None, limit_upper = None ): """ get or set y limits of the current axes y_min, y_max = limit_x() # return the current limit_y limit_y(y_min, y_max) # set the limit_y to y_min, y_max """ if limit_lower ...
python
def limit_y( self, limit_lower = None, limit_upper = None ): """ get or set y limits of the current axes y_min, y_max = limit_x() # return the current limit_y limit_y(y_min, y_max) # set the limit_y to y_min, y_max """ if limit_lower ...
[ "def", "limit_y", "(", "self", ",", "limit_lower", "=", "None", ",", "limit_upper", "=", "None", ")", ":", "if", "limit_lower", "is", "None", "and", "limit_upper", "is", "None", ":", "return", "self", ".", "_limit_y", "elif", "hasattr", "(", "limit_lower",...
get or set y limits of the current axes y_min, y_max = limit_x() # return the current limit_y limit_y(y_min, y_max) # set the limit_y to y_min, y_max
[ "get", "or", "set", "y", "limits", "of", "the", "current", "axes" ]
train
https://github.com/wdbm/datavision/blob/b6f26287264632d6f8c9f8911aaf3a8e4fc4dcf5/datavision.py#L2562-L2584
wdbm/datavision
datavision.py
TTYCanvas.coordinates_inside_data
def coordinates_inside_data( self, x, y ): """ return Boolean to check if coördinate (x, y) is in the data box """ return (self.min_x <= x < self.max_x) and (self.min_y <= y < self.max_y)
python
def coordinates_inside_data( self, x, y ): """ return Boolean to check if coördinate (x, y) is in the data box """ return (self.min_x <= x < self.max_x) and (self.min_y <= y < self.max_y)
[ "def", "coordinates_inside_data", "(", "self", ",", "x", ",", "y", ")", ":", "return", "(", "self", ".", "min_x", "<=", "x", "<", "self", ".", "max_x", ")", "and", "(", "self", ".", "min_y", "<=", "y", "<", "self", ".", "max_y", ")" ]
return Boolean to check if coördinate (x, y) is in the data box
[ "return", "Boolean", "to", "check", "if", "coördinate", "(", "x", "y", ")", "is", "in", "the", "data", "box" ]
train
https://github.com/wdbm/datavision/blob/b6f26287264632d6f8c9f8911aaf3a8e4fc4dcf5/datavision.py#L2698-L2708
wdbm/datavision
datavision.py
TTYCanvas._clip_line
def _clip_line( self, line_pt_1, line_pt_2 ): """ clip line to canvas """ x_min = min(line_pt_1[0], line_pt_2[0]) x_max = max(line_pt_1[0], line_pt_2[0]) y_min = min(line_pt_1[1], line_pt_2[1]) y_max = max(line_pt_1[1], line_pt_2[...
python
def _clip_line( self, line_pt_1, line_pt_2 ): """ clip line to canvas """ x_min = min(line_pt_1[0], line_pt_2[0]) x_max = max(line_pt_1[0], line_pt_2[0]) y_min = min(line_pt_1[1], line_pt_2[1]) y_max = max(line_pt_1[1], line_pt_2[...
[ "def", "_clip_line", "(", "self", ",", "line_pt_1", ",", "line_pt_2", ")", ":", "x_min", "=", "min", "(", "line_pt_1", "[", "0", "]", ",", "line_pt_2", "[", "0", "]", ")", "x_max", "=", "max", "(", "line_pt_1", "[", "0", "]", ",", "line_pt_2", "[",...
clip line to canvas
[ "clip", "line", "to", "canvas" ]
train
https://github.com/wdbm/datavision/blob/b6f26287264632d6f8c9f8911aaf3a8e4fc4dcf5/datavision.py#L2710-L2762
flashmeow/pycent
pycent/__init__.py
percent_of
def percent_of(percent, whole): """Calculates the value of a percent of a number ie: 5% of 20 is what --> 1 Args: percent (float): The percent of a number whole (float): The whole of the number Returns: float: The value of a percent Example: >>> per...
python
def percent_of(percent, whole): """Calculates the value of a percent of a number ie: 5% of 20 is what --> 1 Args: percent (float): The percent of a number whole (float): The whole of the number Returns: float: The value of a percent Example: >>> per...
[ "def", "percent_of", "(", "percent", ",", "whole", ")", ":", "percent", "=", "float", "(", "percent", ")", "whole", "=", "float", "(", "whole", ")", "return", "(", "percent", "*", "whole", ")", "/", "100" ]
Calculates the value of a percent of a number ie: 5% of 20 is what --> 1 Args: percent (float): The percent of a number whole (float): The whole of the number Returns: float: The value of a percent Example: >>> percent_of(25, 100) 25.0 >>> perce...
[ "Calculates", "the", "value", "of", "a", "percent", "of", "a", "number", "ie", ":", "5%", "of", "20", "is", "what", "--", ">", "1", "Args", ":", "percent", "(", "float", ")", ":", "The", "percent", "of", "a", "number", "whole", "(", "float", ")", ...
train
https://github.com/flashmeow/pycent/blob/43efcc1d84dd9d801285a641f9be80bb4ecceabd/pycent/__init__.py#L1-L21
flashmeow/pycent
pycent/__init__.py
percentage
def percentage(part, whole, resolution=2): """Calculates the percentage of a number, given a part and a whole ie: 10 is what percent of 25 --> 40% Args: part (float): The part of a number whole (float): The whole of a number resolution (int): Number of decimal places (Default is 2) ...
python
def percentage(part, whole, resolution=2): """Calculates the percentage of a number, given a part and a whole ie: 10 is what percent of 25 --> 40% Args: part (float): The part of a number whole (float): The whole of a number resolution (int): Number of decimal places (Default is 2) ...
[ "def", "percentage", "(", "part", ",", "whole", ",", "resolution", "=", "2", ")", ":", "if", "whole", "==", "0", ":", "raise", "ZeroDivisionError", "percent", "=", "100", "*", "float", "(", "part", ")", "/", "float", "(", "whole", ")", "return", "rou...
Calculates the percentage of a number, given a part and a whole ie: 10 is what percent of 25 --> 40% Args: part (float): The part of a number whole (float): The whole of a number resolution (int): Number of decimal places (Default is 2) Returns: float: The percentage of a n...
[ "Calculates", "the", "percentage", "of", "a", "number", "given", "a", "part", "and", "a", "whole", "ie", ":", "10", "is", "what", "percent", "of", "25", "--", ">", "40%" ]
train
https://github.com/flashmeow/pycent/blob/43efcc1d84dd9d801285a641f9be80bb4ecceabd/pycent/__init__.py#L23-L49
atdt/afraid
afraid/__init__.py
get_dyndns_records
def get_dyndns_records(login, password): """Gets the set of dynamic DNS records associated with this account""" params = dict(action='getdyndns', sha=get_auth_key(login, password)) response = requests.get('http://freedns.afraid.org/api/', params=params, timeout=timeout) raw_records = (line.split('|') fo...
python
def get_dyndns_records(login, password): """Gets the set of dynamic DNS records associated with this account""" params = dict(action='getdyndns', sha=get_auth_key(login, password)) response = requests.get('http://freedns.afraid.org/api/', params=params, timeout=timeout) raw_records = (line.split('|') fo...
[ "def", "get_dyndns_records", "(", "login", ",", "password", ")", ":", "params", "=", "dict", "(", "action", "=", "'getdyndns'", ",", "sha", "=", "get_auth_key", "(", "login", ",", "password", ")", ")", "response", "=", "requests", ".", "get", "(", "'http...
Gets the set of dynamic DNS records associated with this account
[ "Gets", "the", "set", "of", "dynamic", "DNS", "records", "associated", "with", "this", "account" ]
train
https://github.com/atdt/afraid/blob/d74b2d4e41ed14e420da2793a89bef5d9b26ea26/afraid/__init__.py#L91-L103
atdt/afraid
afraid/__init__.py
update_continuously
def update_continuously(records, update_interval=600): """Update `records` every `update_interval` seconds""" while True: for record in records: try: record.update() except (ApiError, RequestException): pass time.sleep(update_interval)
python
def update_continuously(records, update_interval=600): """Update `records` every `update_interval` seconds""" while True: for record in records: try: record.update() except (ApiError, RequestException): pass time.sleep(update_interval)
[ "def", "update_continuously", "(", "records", ",", "update_interval", "=", "600", ")", ":", "while", "True", ":", "for", "record", "in", "records", ":", "try", ":", "record", ".", "update", "(", ")", "except", "(", "ApiError", ",", "RequestException", ")",...
Update `records` every `update_interval` seconds
[ "Update", "records", "every", "update_interval", "seconds" ]
train
https://github.com/atdt/afraid/blob/d74b2d4e41ed14e420da2793a89bef5d9b26ea26/afraid/__init__.py#L106-L114
atdt/afraid
afraid/__init__.py
parse_args
def parse_args(args=None): """Parse command-line arguments""" parser = argparse.ArgumentParser(description='afraid.org dyndns client') ## positional arguments parser.add_argument('user') parser.add_argument('password') parser.add_argument('hosts', nargs='*', help='(deaf...
python
def parse_args(args=None): """Parse command-line arguments""" parser = argparse.ArgumentParser(description='afraid.org dyndns client') ## positional arguments parser.add_argument('user') parser.add_argument('password') parser.add_argument('hosts', nargs='*', help='(deaf...
[ "def", "parse_args", "(", "args", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'afraid.org dyndns client'", ")", "## positional arguments", "parser", ".", "add_argument", "(", "'user'", ")", "parser", ".", "a...
Parse command-line arguments
[ "Parse", "command", "-", "line", "arguments" ]
train
https://github.com/atdt/afraid/blob/d74b2d4e41ed14e420da2793a89bef5d9b26ea26/afraid/__init__.py#L117-L156
atdt/afraid
afraid/__init__.py
DnsRecord.update
def update(self): """Updates remote DNS record by requesting its special endpoint URL""" response = requests.get(self.update_url, timeout=timeout) match = ip_pattern.search(response.content) # response must contain an ip address, or else we can't parse it if not match: ...
python
def update(self): """Updates remote DNS record by requesting its special endpoint URL""" response = requests.get(self.update_url, timeout=timeout) match = ip_pattern.search(response.content) # response must contain an ip address, or else we can't parse it if not match: ...
[ "def", "update", "(", "self", ")", ":", "response", "=", "requests", ".", "get", "(", "self", ".", "update_url", ",", "timeout", "=", "timeout", ")", "match", "=", "ip_pattern", ".", "search", "(", "response", ".", "content", ")", "# response must contain ...
Updates remote DNS record by requesting its special endpoint URL
[ "Updates", "remote", "DNS", "record", "by", "requesting", "its", "special", "endpoint", "URL" ]
train
https://github.com/atdt/afraid/blob/d74b2d4e41ed14e420da2793a89bef5d9b26ea26/afraid/__init__.py#L72-L82
casebeer/factual
factual/v3/requests.py
Read.within
def within(self, lat, lon, radius): ''' Apply a geo=$circle/$center filter. Radius is in meters. Subsequent within() calls replace earlier geo filters on this query. ''' self._geo = { "$circle": { "$center": [ factual.common.shared_filter_helpers.GeoScalar(lat), factual.common.shared_fi...
python
def within(self, lat, lon, radius): ''' Apply a geo=$circle/$center filter. Radius is in meters. Subsequent within() calls replace earlier geo filters on this query. ''' self._geo = { "$circle": { "$center": [ factual.common.shared_filter_helpers.GeoScalar(lat), factual.common.shared_fi...
[ "def", "within", "(", "self", ",", "lat", ",", "lon", ",", "radius", ")", ":", "self", ".", "_geo", "=", "{", "\"$circle\"", ":", "{", "\"$center\"", ":", "[", "factual", ".", "common", ".", "shared_filter_helpers", ".", "GeoScalar", "(", "lat", ")", ...
Apply a geo=$circle/$center filter. Radius is in meters. Subsequent within() calls replace earlier geo filters on this query.
[ "Apply", "a", "geo", "=", "$circle", "/", "$center", "filter", ".", "Radius", "is", "in", "meters", ".", "Subsequent", "within", "()", "calls", "replace", "earlier", "geo", "filters", "on", "this", "query", "." ]
train
https://github.com/casebeer/factual/blob/f2795a8c9fd447c5d62887ae0f960481ce13be84/factual/v3/requests.py#L26-L39
ArabellaTech/aa-intercom
aa_intercom/tasks.py
push_account_task
def push_account_task(obj_id): """ Async: push_account_task.delay(Account.id) """ lock_id = "%s-push-account-%s" % (settings.ENV_PREFIX, obj_id) acquire_lock = lambda: cache.add(lock_id, "true", LOCK_EXPIRE) # noqa: E731 release_lock = lambda: cache.delete(lock_id) # noqa: E731 if acquire_...
python
def push_account_task(obj_id): """ Async: push_account_task.delay(Account.id) """ lock_id = "%s-push-account-%s" % (settings.ENV_PREFIX, obj_id) acquire_lock = lambda: cache.add(lock_id, "true", LOCK_EXPIRE) # noqa: E731 release_lock = lambda: cache.delete(lock_id) # noqa: E731 if acquire_...
[ "def", "push_account_task", "(", "obj_id", ")", ":", "lock_id", "=", "\"%s-push-account-%s\"", "%", "(", "settings", ".", "ENV_PREFIX", ",", "obj_id", ")", "acquire_lock", "=", "lambda", ":", "cache", ".", "add", "(", "lock_id", ",", "\"true\"", ",", "LOCK_E...
Async: push_account_task.delay(Account.id)
[ "Async", ":", "push_account_task", ".", "delay", "(", "Account", ".", "id", ")" ]
train
https://github.com/ArabellaTech/aa-intercom/blob/f7e2ab63967529660f9c2fe4f1d0bf3cec1502c2/aa_intercom/tasks.py#L21-L36
ArabellaTech/aa-intercom
aa_intercom/tasks.py
push_intercom_event_task
def push_intercom_event_task(obj_id): """ Async: push_intercom_event_task.delay(event.id) """ lock_id = "%s-push-intercom_event-%s" % (settings.ENV_PREFIX, obj_id) acquire_lock = lambda: cache.add(lock_id, "true", LOCK_EXPIRE) # noqa: E731 release_lock = lambda: cache.delete(lock_id) # noqa: E...
python
def push_intercom_event_task(obj_id): """ Async: push_intercom_event_task.delay(event.id) """ lock_id = "%s-push-intercom_event-%s" % (settings.ENV_PREFIX, obj_id) acquire_lock = lambda: cache.add(lock_id, "true", LOCK_EXPIRE) # noqa: E731 release_lock = lambda: cache.delete(lock_id) # noqa: E...
[ "def", "push_intercom_event_task", "(", "obj_id", ")", ":", "lock_id", "=", "\"%s-push-intercom_event-%s\"", "%", "(", "settings", ".", "ENV_PREFIX", ",", "obj_id", ")", "acquire_lock", "=", "lambda", ":", "cache", ".", "add", "(", "lock_id", ",", "\"true\"", ...
Async: push_intercom_event_task.delay(event.id)
[ "Async", ":", "push_intercom_event_task", ".", "delay", "(", "event", ".", "id", ")" ]
train
https://github.com/ArabellaTech/aa-intercom/blob/f7e2ab63967529660f9c2fe4f1d0bf3cec1502c2/aa_intercom/tasks.py#L40-L76
ArabellaTech/aa-intercom
aa_intercom/tasks.py
push_account_last_seen_task
def push_account_last_seen_task(obj_id): """ Async: push_account_last_seen_task.apply_async(args=[Account.id], countdown=100) """ lock_id = "%s-push-account-last-seen-%s" % (settings.ENV_PREFIX, obj_id) # noqa: E731 acquire_lock = lambda: cache.add(lock_id, "true", LOCK_EXPIRE) # noqa: E731 # ...
python
def push_account_last_seen_task(obj_id): """ Async: push_account_last_seen_task.apply_async(args=[Account.id], countdown=100) """ lock_id = "%s-push-account-last-seen-%s" % (settings.ENV_PREFIX, obj_id) # noqa: E731 acquire_lock = lambda: cache.add(lock_id, "true", LOCK_EXPIRE) # noqa: E731 # ...
[ "def", "push_account_last_seen_task", "(", "obj_id", ")", ":", "lock_id", "=", "\"%s-push-account-last-seen-%s\"", "%", "(", "settings", ".", "ENV_PREFIX", ",", "obj_id", ")", "# noqa: E731", "acquire_lock", "=", "lambda", ":", "cache", ".", "add", "(", "lock_id",...
Async: push_account_last_seen_task.apply_async(args=[Account.id], countdown=100)
[ "Async", ":", "push_account_last_seen_task", ".", "apply_async", "(", "args", "=", "[", "Account", ".", "id", "]", "countdown", "=", "100", ")" ]
train
https://github.com/ArabellaTech/aa-intercom/blob/f7e2ab63967529660f9c2fe4f1d0bf3cec1502c2/aa_intercom/tasks.py#L80-L109
ArabellaTech/aa-intercom
aa_intercom/tasks.py
push_not_registered_user_data_task
def push_not_registered_user_data_task(data): """ Async: push_not_registered_user_data_task.apply_async(args=[data], countdown=100) """ lock_id = "%s-push-not-registered-user-data-task-%s" % (settings.ENV_PREFIX, data["email"]) acquire_lock = lambda: cache.add(lock_id, "true", LOCK_EXPIRE) # noqa: ...
python
def push_not_registered_user_data_task(data): """ Async: push_not_registered_user_data_task.apply_async(args=[data], countdown=100) """ lock_id = "%s-push-not-registered-user-data-task-%s" % (settings.ENV_PREFIX, data["email"]) acquire_lock = lambda: cache.add(lock_id, "true", LOCK_EXPIRE) # noqa: ...
[ "def", "push_not_registered_user_data_task", "(", "data", ")", ":", "lock_id", "=", "\"%s-push-not-registered-user-data-task-%s\"", "%", "(", "settings", ".", "ENV_PREFIX", ",", "data", "[", "\"email\"", "]", ")", "acquire_lock", "=", "lambda", ":", "cache", ".", ...
Async: push_not_registered_user_data_task.apply_async(args=[data], countdown=100)
[ "Async", ":", "push_not_registered_user_data_task", ".", "apply_async", "(", "args", "=", "[", "data", "]", "countdown", "=", "100", ")" ]
train
https://github.com/ArabellaTech/aa-intercom/blob/f7e2ab63967529660f9c2fe4f1d0bf3cec1502c2/aa_intercom/tasks.py#L113-L127
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/restful.py
error_handler
def error_handler(f): """Handle exceptions.""" @wraps(f) def inner(*args, **kwargs): try: return f(*args, **kwargs) except NoResultFound: abort(404) except IntegrityError: abort(500) return inner
python
def error_handler(f): """Handle exceptions.""" @wraps(f) def inner(*args, **kwargs): try: return f(*args, **kwargs) except NoResultFound: abort(404) except IntegrityError: abort(500) return inner
[ "def", "error_handler", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "NoResultFound", ...
Handle exceptions.
[ "Handle", "exceptions", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/restful.py#L35-L45
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/restful.py
setup_app
def setup_app(app, api): """setup the resources urls.""" api.add_resource( KnwKBAllResource, '/api/knowledge' ) api.add_resource( KnwKBResource, '/api/knowledge/<string:slug>' ) api.add_resource( KnwKBMappingsResource, '/api/knowledge/<string:slug>...
python
def setup_app(app, api): """setup the resources urls.""" api.add_resource( KnwKBAllResource, '/api/knowledge' ) api.add_resource( KnwKBResource, '/api/knowledge/<string:slug>' ) api.add_resource( KnwKBMappingsResource, '/api/knowledge/<string:slug>...
[ "def", "setup_app", "(", "app", ",", "api", ")", ":", "api", ".", "add_resource", "(", "KnwKBAllResource", ",", "'/api/knowledge'", ")", "api", ".", "add_resource", "(", "KnwKBResource", ",", "'/api/knowledge/<string:slug>'", ")", "api", ".", "add_resource", "("...
setup the resources urls.
[ "setup", "the", "resources", "urls", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/restful.py#L487-L514
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/restful.py
KnwKBResource.get
def get(self, slug): """Get KnwKB. Url parameters: - from: filter "mappings from" - to: filter "mappings to" - page - per_page - match_type: s=substring, e=exact, sw=startswith - sortby: 'from' or 'to' """ kb = api....
python
def get(self, slug): """Get KnwKB. Url parameters: - from: filter "mappings from" - to: filter "mappings to" - page - per_page - match_type: s=substring, e=exact, sw=startswith - sortby: 'from' or 'to' """ kb = api....
[ "def", "get", "(", "self", ",", "slug", ")", ":", "kb", "=", "api", ".", "get_kb_by_slug", "(", "slug", ")", "# check if is accessible from api", "check_knowledge_access", "(", "kb", ")", "parser", "=", "reqparse", ".", "RequestParser", "(", ")", "parser", "...
Get KnwKB. Url parameters: - from: filter "mappings from" - to: filter "mappings to" - page - per_page - match_type: s=substring, e=exact, sw=startswith - sortby: 'from' or 'to'
[ "Get", "KnwKB", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/restful.py#L106-L144
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/restful.py
KnwKBMappingsResource.search_mappings
def search_mappings(kb, key=None, value=None, match_type=None, sortby=None, page=None, per_page=None): """Search tags for knowledge.""" if kb.kbtype == models.KnwKB.KNWKB_TYPES['written_as']: return pagination.RestfulSQLAlchemyPagination( api.query_kb_...
python
def search_mappings(kb, key=None, value=None, match_type=None, sortby=None, page=None, per_page=None): """Search tags for knowledge.""" if kb.kbtype == models.KnwKB.KNWKB_TYPES['written_as']: return pagination.RestfulSQLAlchemyPagination( api.query_kb_...
[ "def", "search_mappings", "(", "kb", ",", "key", "=", "None", ",", "value", "=", "None", ",", "match_type", "=", "None", ",", "sortby", "=", "None", ",", "page", "=", "None", ",", "per_page", "=", "None", ")", ":", "if", "kb", ".", "kbtype", "==", ...
Search tags for knowledge.
[ "Search", "tags", "for", "knowledge", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/restful.py#L185-L198
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/restful.py
KnwKBMappingsResource.get
def get(self, slug): """Get list of mappings. Url parameters: - from: filter "mappings from" - to: filter "mappings to" - page - per_page - match_type: s=substring, e=exact, sw=startswith - sortby: 'from' or 'to' """ ...
python
def get(self, slug): """Get list of mappings. Url parameters: - from: filter "mappings from" - to: filter "mappings to" - page - per_page - match_type: s=substring, e=exact, sw=startswith - sortby: 'from' or 'to' """ ...
[ "def", "get", "(", "self", ",", "slug", ")", ":", "kb", "=", "api", ".", "get_kb_by_slug", "(", "slug", ")", "# check if is accessible from api", "check_knowledge_access", "(", "kb", ")", "parser", "=", "reqparse", ".", "RequestParser", "(", ")", "parser", "...
Get list of mappings. Url parameters: - from: filter "mappings from" - to: filter "mappings to" - page - per_page - match_type: s=substring, e=exact, sw=startswith - sortby: 'from' or 'to'
[ "Get", "list", "of", "mappings", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/restful.py#L201-L236
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/restful.py
KnwKBMappingsToResource.search_list
def search_list(kb, value=None, match_type=None, page=None, per_page=None, unique=False): """Search "mappings to" for knowledge.""" # init page = page or 1 per_page = per_page or 10 if kb.kbtype == models.KnwKB.KNWKB_TYPES['written_as']: # get the...
python
def search_list(kb, value=None, match_type=None, page=None, per_page=None, unique=False): """Search "mappings to" for knowledge.""" # init page = page or 1 per_page = per_page or 10 if kb.kbtype == models.KnwKB.KNWKB_TYPES['written_as']: # get the...
[ "def", "search_list", "(", "kb", ",", "value", "=", "None", ",", "match_type", "=", "None", ",", "page", "=", "None", ",", "per_page", "=", "None", ",", "unique", "=", "False", ")", ":", "# init", "page", "=", "page", "or", "1", "per_page", "=", "p...
Search "mappings to" for knowledge.
[ "Search", "mappings", "to", "for", "knowledge", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/restful.py#L277-L306
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/restful.py
KnwKBMappingsFromResource.search_list
def search_list(kb, from_=None, match_type=None, page=None, per_page=None, unique=False): """Search "mapping from" for knowledge.""" # init page = page or 1 per_page = per_page or 10 if kb.kbtype == models.KnwKB.KNWKB_TYPES['written_as']: # get th...
python
def search_list(kb, from_=None, match_type=None, page=None, per_page=None, unique=False): """Search "mapping from" for knowledge.""" # init page = page or 1 per_page = per_page or 10 if kb.kbtype == models.KnwKB.KNWKB_TYPES['written_as']: # get th...
[ "def", "search_list", "(", "kb", ",", "from_", "=", "None", ",", "match_type", "=", "None", ",", "page", "=", "None", ",", "per_page", "=", "None", ",", "unique", "=", "False", ")", ":", "# init", "page", "=", "page", "or", "1", "per_page", "=", "p...
Search "mapping from" for knowledge.
[ "Search", "mapping", "from", "for", "knowledge", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/restful.py#L382-L405
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/restful.py
KnwKBMappingsFromResource.get
def get(self, slug): """Get list of "mappings from". Url parameters - unique: if set, return a unique list - filter: filter "mappings from" - page - per_page - match_type: s=substring, e=exact, sw=startswith """ kb = api.get_kb...
python
def get(self, slug): """Get list of "mappings from". Url parameters - unique: if set, return a unique list - filter: filter "mappings from" - page - per_page - match_type: s=substring, e=exact, sw=startswith """ kb = api.get_kb...
[ "def", "get", "(", "self", ",", "slug", ")", ":", "kb", "=", "api", ".", "get_kb_by_slug", "(", "slug", ")", "# check if is accessible from api", "check_knowledge_access", "(", "kb", ")", "parser", "=", "reqparse", ".", "RequestParser", "(", ")", "parser", "...
Get list of "mappings from". Url parameters - unique: if set, return a unique list - filter: filter "mappings from" - page - per_page - match_type: s=substring, e=exact, sw=startswith
[ "Get", "list", "of", "mappings", "from", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/restful.py#L407-L439
political-memory/django-representatives
representatives/contrib/parltrack/import_representatives.py
ParltrackImporter.manage_mep
def manage_mep(self, mep_json): ''' Import a mep as a representative from the json dict fetched from parltrack ''' # Some versions of memopol will connect to this and skip inactive meps. responses = representative_pre_import.send(sender=self, representati...
python
def manage_mep(self, mep_json): ''' Import a mep as a representative from the json dict fetched from parltrack ''' # Some versions of memopol will connect to this and skip inactive meps. responses = representative_pre_import.send(sender=self, representati...
[ "def", "manage_mep", "(", "self", ",", "mep_json", ")", ":", "# Some versions of memopol will connect to this and skip inactive meps.", "responses", "=", "representative_pre_import", ".", "send", "(", "sender", "=", "self", ",", "representative_data", "=", "mep_json", ")"...
Import a mep as a representative from the json dict fetched from parltrack
[ "Import", "a", "mep", "as", "a", "representative", "from", "the", "json", "dict", "fetched", "from", "parltrack" ]
train
https://github.com/political-memory/django-representatives/blob/811c90d0250149e913e6196f0ab11c97d396be39/representatives/contrib/parltrack/import_representatives.py#L77-L114
edeposit/edeposit.amqp.ltp
src/edeposit/amqp/ltp/info_composer.py
_path_to_id
def _path_to_id(path): """ Name of the root directory is used as ``<packageid>`` in ``info.xml``. This function makes sure, that :func:`os.path.basename` doesn't return blank string in case that there is `/` at the end of the `path`. Args: path (str): Path to the root directory. Retur...
python
def _path_to_id(path): """ Name of the root directory is used as ``<packageid>`` in ``info.xml``. This function makes sure, that :func:`os.path.basename` doesn't return blank string in case that there is `/` at the end of the `path`. Args: path (str): Path to the root directory. Retur...
[ "def", "_path_to_id", "(", "path", ")", ":", "if", "path", ".", "endswith", "(", "\"/\"", ")", ":", "path", "=", "path", "[", ":", "-", "1", "]", "return", "os", ".", "path", ".", "basename", "(", "path", ")" ]
Name of the root directory is used as ``<packageid>`` in ``info.xml``. This function makes sure, that :func:`os.path.basename` doesn't return blank string in case that there is `/` at the end of the `path`. Args: path (str): Path to the root directory. Returns: str: Basename of the `p...
[ "Name", "of", "the", "root", "directory", "is", "used", "as", "<packageid", ">", "in", "info", ".", "xml", "." ]
train
https://github.com/edeposit/edeposit.amqp.ltp/blob/df9ac7ec6cbdbeaaeed438ca66df75ea967b6d8e/src/edeposit/amqp/ltp/info_composer.py#L19-L35
edeposit/edeposit.amqp.ltp
src/edeposit/amqp/ltp/info_composer.py
_calc_dir_size
def _calc_dir_size(path): """ Calculate size of all files in `path`. Args: path (str): Path to the directory. Returns: int: Size of the directory in bytes. """ dir_size = 0 for (root, dirs, files) in os.walk(path): for fn in files: full_fn = os.path.join...
python
def _calc_dir_size(path): """ Calculate size of all files in `path`. Args: path (str): Path to the directory. Returns: int: Size of the directory in bytes. """ dir_size = 0 for (root, dirs, files) in os.walk(path): for fn in files: full_fn = os.path.join...
[ "def", "_calc_dir_size", "(", "path", ")", ":", "dir_size", "=", "0", "for", "(", "root", ",", "dirs", ",", "files", ")", "in", "os", ".", "walk", "(", "path", ")", ":", "for", "fn", "in", "files", ":", "full_fn", "=", "os", ".", "path", ".", "...
Calculate size of all files in `path`. Args: path (str): Path to the directory. Returns: int: Size of the directory in bytes.
[ "Calculate", "size", "of", "all", "files", "in", "path", "." ]
train
https://github.com/edeposit/edeposit.amqp.ltp/blob/df9ac7ec6cbdbeaaeed438ca66df75ea967b6d8e/src/edeposit/amqp/ltp/info_composer.py#L38-L54
edeposit/edeposit.amqp.ltp
src/edeposit/amqp/ltp/info_composer.py
_get_localized_fn
def _get_localized_fn(path, root_dir): """ Return absolute `path` relative to `root_dir`. When `path` == ``/home/xex/somefile.txt`` and `root_dir` == ``/home``, returned path will be ``/xex/somefile.txt``. Args: path (str): Absolute path beginning in `root_dir`. root_dir (str): Abs...
python
def _get_localized_fn(path, root_dir): """ Return absolute `path` relative to `root_dir`. When `path` == ``/home/xex/somefile.txt`` and `root_dir` == ``/home``, returned path will be ``/xex/somefile.txt``. Args: path (str): Absolute path beginning in `root_dir`. root_dir (str): Abs...
[ "def", "_get_localized_fn", "(", "path", ",", "root_dir", ")", ":", "local_fn", "=", "path", "if", "path", ".", "startswith", "(", "root_dir", ")", ":", "local_fn", "=", "path", ".", "replace", "(", "root_dir", ",", "\"\"", ",", "1", ")", "if", "not", ...
Return absolute `path` relative to `root_dir`. When `path` == ``/home/xex/somefile.txt`` and `root_dir` == ``/home``, returned path will be ``/xex/somefile.txt``. Args: path (str): Absolute path beginning in `root_dir`. root_dir (str): Absolute path containing `path` argument. Returns...
[ "Return", "absolute", "path", "relative", "to", "root_dir", "." ]
train
https://github.com/edeposit/edeposit.amqp.ltp/blob/df9ac7ec6cbdbeaaeed438ca66df75ea967b6d8e/src/edeposit/amqp/ltp/info_composer.py#L57-L78
edeposit/edeposit.amqp.ltp
src/edeposit/amqp/ltp/info_composer.py
compose_info
def compose_info(root_dir, files, hash_fn, aleph_record, urn_nbn=None): """ Compose `info` XML file. Info example:: <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <info> <created>2014-07-31T10:58:53</created> <metadataversion>1.0</metadataversion> ...
python
def compose_info(root_dir, files, hash_fn, aleph_record, urn_nbn=None): """ Compose `info` XML file. Info example:: <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <info> <created>2014-07-31T10:58:53</created> <metadataversion>1.0</metadataversion> ...
[ "def", "compose_info", "(", "root_dir", ",", "files", ",", "hash_fn", ",", "aleph_record", ",", "urn_nbn", "=", "None", ")", ":", "# compute hash for hashfile", "with", "open", "(", "hash_fn", ")", "as", "f", ":", "hash_file_md5", "=", "hashlib", ".", "md5",...
Compose `info` XML file. Info example:: <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <info> <created>2014-07-31T10:58:53</created> <metadataversion>1.0</metadataversion> <packageid>c88f5a50-7b34-11e2-b930-005056827e51</packageid> <mainmet...
[ "Compose", "info", "XML", "file", "." ]
train
https://github.com/edeposit/edeposit.amqp.ltp/blob/df9ac7ec6cbdbeaaeed438ca66df75ea967b6d8e/src/edeposit/amqp/ltp/info_composer.py#L81-L210
1and1/infrascope
src/infrascope/cli.py
run
def run(argv=None): """Main CLI entry point.""" cli = InfrascopeCLI() return cli.run(sys.argv[1:] if argv is None else argv)
python
def run(argv=None): """Main CLI entry point.""" cli = InfrascopeCLI() return cli.run(sys.argv[1:] if argv is None else argv)
[ "def", "run", "(", "argv", "=", "None", ")", ":", "cli", "=", "InfrascopeCLI", "(", ")", "return", "cli", ".", "run", "(", "sys", ".", "argv", "[", "1", ":", "]", "if", "argv", "is", "None", "else", "argv", ")" ]
Main CLI entry point.
[ "Main", "CLI", "entry", "point", "." ]
train
https://github.com/1and1/infrascope/blob/d7e291917e618a0a3cd6d5bfc20c6b5defd7550c/src/infrascope/cli.py#L58-L61
donovan-duplessis/pwnurl
pwnurl/app.py
create_app
def create_app(configobj=ProdConfig): """ Create and configure Flask Application """ app = Flask(__name__) app.config.from_object(configobj) configure_blueprints(app) configure_extensions(app) configure_callbacks(app) configure_filters(app) configure_error_handlers(app) return app
python
def create_app(configobj=ProdConfig): """ Create and configure Flask Application """ app = Flask(__name__) app.config.from_object(configobj) configure_blueprints(app) configure_extensions(app) configure_callbacks(app) configure_filters(app) configure_error_handlers(app) return app
[ "def", "create_app", "(", "configobj", "=", "ProdConfig", ")", ":", "app", "=", "Flask", "(", "__name__", ")", "app", ".", "config", ".", "from_object", "(", "configobj", ")", "configure_blueprints", "(", "app", ")", "configure_extensions", "(", "app", ")", ...
Create and configure Flask Application
[ "Create", "and", "configure", "Flask", "Application" ]
train
https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/app.py#L21-L31
donovan-duplessis/pwnurl
pwnurl/app.py
configure_filters
def configure_filters(app): """ Configure application filters (jinja2) """ for (name, filter) in _filters.iteritems(): app.jinja_env.filters[name] = filter
python
def configure_filters(app): """ Configure application filters (jinja2) """ for (name, filter) in _filters.iteritems(): app.jinja_env.filters[name] = filter
[ "def", "configure_filters", "(", "app", ")", ":", "for", "(", "name", ",", "filter", ")", "in", "_filters", ".", "iteritems", "(", ")", ":", "app", ".", "jinja_env", ".", "filters", "[", "name", "]", "=", "filter" ]
Configure application filters (jinja2)
[ "Configure", "application", "filters", "(", "jinja2", ")" ]
train
https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/app.py#L41-L45
donovan-duplessis/pwnurl
pwnurl/app.py
configure_extensions
def configure_extensions(app): """ Configure application extensions """ db.init_app(app) app.wsgi_app = ProxyFix(app.wsgi_app) assets.init_app(app) for asset in bundles: for (name, bundle) in asset.iteritems(): assets.register(name, bundle) login_manager.login_view = 'fro...
python
def configure_extensions(app): """ Configure application extensions """ db.init_app(app) app.wsgi_app = ProxyFix(app.wsgi_app) assets.init_app(app) for asset in bundles: for (name, bundle) in asset.iteritems(): assets.register(name, bundle) login_manager.login_view = 'fro...
[ "def", "configure_extensions", "(", "app", ")", ":", "db", ".", "init_app", "(", "app", ")", "app", ".", "wsgi_app", "=", "ProxyFix", "(", "app", ".", "wsgi_app", ")", "assets", ".", "init_app", "(", "app", ")", "for", "asset", "in", "bundles", ":", ...
Configure application extensions
[ "Configure", "application", "extensions" ]
train
https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/app.py#L48-L71
donovan-duplessis/pwnurl
pwnurl/app.py
configure_callbacks
def configure_callbacks(app): """ Configure application callbacks """ @app.before_request def before_request(): """ Retrieve menu configuration before every request (this will return cached version if possible, else reload from database. """ from flask import session #...
python
def configure_callbacks(app): """ Configure application callbacks """ @app.before_request def before_request(): """ Retrieve menu configuration before every request (this will return cached version if possible, else reload from database. """ from flask import session #...
[ "def", "configure_callbacks", "(", "app", ")", ":", "@", "app", ".", "before_request", "def", "before_request", "(", ")", ":", "\"\"\" Retrieve menu configuration before every request (this will return\n cached version if possible, else reload from database. \"\"\"", "from...
Configure application callbacks
[ "Configure", "application", "callbacks" ]
train
https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/app.py#L74-L86
donovan-duplessis/pwnurl
pwnurl/app.py
configure_error_handlers
def configure_error_handlers(app): """ Configure application error handlers """ def render_error(error): return (render_template('errors/%s.html' % error.code, title=error_messages[error.code], code=error.code), error.code) for (errcode, title) in error_messages.iteritems(): ...
python
def configure_error_handlers(app): """ Configure application error handlers """ def render_error(error): return (render_template('errors/%s.html' % error.code, title=error_messages[error.code], code=error.code), error.code) for (errcode, title) in error_messages.iteritems(): ...
[ "def", "configure_error_handlers", "(", "app", ")", ":", "def", "render_error", "(", "error", ")", ":", "return", "(", "render_template", "(", "'errors/%s.html'", "%", "error", ".", "code", ",", "title", "=", "error_messages", "[", "error", ".", "code", "]",...
Configure application error handlers
[ "Configure", "application", "error", "handlers" ]
train
https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/app.py#L89-L97
pablorecio/Cobaya
src/cobaya/hamster_task.py
_elapsed_time
def _elapsed_time(begin_time, end_time): """Assuming format YYYY-MM-DD hh:mm:ss Returns the elapsed time in seconds """ bt = _str2datetime(begin_time) et = _str2datetime(end_time) return float((et - bt).seconds)
python
def _elapsed_time(begin_time, end_time): """Assuming format YYYY-MM-DD hh:mm:ss Returns the elapsed time in seconds """ bt = _str2datetime(begin_time) et = _str2datetime(end_time) return float((et - bt).seconds)
[ "def", "_elapsed_time", "(", "begin_time", ",", "end_time", ")", ":", "bt", "=", "_str2datetime", "(", "begin_time", ")", "et", "=", "_str2datetime", "(", "end_time", ")", "return", "float", "(", "(", "et", "-", "bt", ")", ".", "seconds", ")" ]
Assuming format YYYY-MM-DD hh:mm:ss Returns the elapsed time in seconds
[ "Assuming", "format", "YYYY", "-", "MM", "-", "DD", "hh", ":", "mm", ":", "ss" ]
train
https://github.com/pablorecio/Cobaya/blob/70b107dea5f31f51e7b6738da3c2a1df5b9f3f20/src/cobaya/hamster_task.py#L97-L106
krinj/k-util
k_util/logger.py
Logger._special
def _special(self, message: str, with_gap: bool=True): """ Logs a special (colored) message at the indent level. """ if with_gap: self._line_break() self._log(self._set_color(message, self.GREEN))
python
def _special(self, message: str, with_gap: bool=True): """ Logs a special (colored) message at the indent level. """ if with_gap: self._line_break() self._log(self._set_color(message, self.GREEN))
[ "def", "_special", "(", "self", ",", "message", ":", "str", ",", "with_gap", ":", "bool", "=", "True", ")", ":", "if", "with_gap", ":", "self", ".", "_line_break", "(", ")", "self", ".", "_log", "(", "self", ".", "_set_color", "(", "message", ",", ...
Logs a special (colored) message at the indent level.
[ "Logs", "a", "special", "(", "colored", ")", "message", "at", "the", "indent", "level", "." ]
train
https://github.com/krinj/k-util/blob/b118826b1d6f49ca4e1ca7327d5b171db332ac23/k_util/logger.py#L146-L150
krinj/k-util
k_util/logger.py
Logger._header
def _header(self, message: str, with_gap=True): """ Logs a special (colored) message at the indent level. """ if with_gap: self._line_break() self._log(self._set_color(message, self.YELLOW))
python
def _header(self, message: str, with_gap=True): """ Logs a special (colored) message at the indent level. """ if with_gap: self._line_break() self._log(self._set_color(message, self.YELLOW))
[ "def", "_header", "(", "self", ",", "message", ":", "str", ",", "with_gap", "=", "True", ")", ":", "if", "with_gap", ":", "self", ".", "_line_break", "(", ")", "self", ".", "_log", "(", "self", ".", "_set_color", "(", "message", ",", "self", ".", "...
Logs a special (colored) message at the indent level.
[ "Logs", "a", "special", "(", "colored", ")", "message", "at", "the", "indent", "level", "." ]
train
https://github.com/krinj/k-util/blob/b118826b1d6f49ca4e1ca7327d5b171db332ac23/k_util/logger.py#L152-L156
krinj/k-util
k_util/logger.py
Logger._strip_colors
def _strip_colors(self, message: str) -> str: """ Remove all of the color tags from this message. """ for c in self.COLORS: message = message.replace(c, "") return message
python
def _strip_colors(self, message: str) -> str: """ Remove all of the color tags from this message. """ for c in self.COLORS: message = message.replace(c, "") return message
[ "def", "_strip_colors", "(", "self", ",", "message", ":", "str", ")", "->", "str", ":", "for", "c", "in", "self", ".", "COLORS", ":", "message", "=", "message", ".", "replace", "(", "c", ",", "\"\"", ")", "return", "message" ]
Remove all of the color tags from this message.
[ "Remove", "all", "of", "the", "color", "tags", "from", "this", "message", "." ]
train
https://github.com/krinj/k-util/blob/b118826b1d6f49ca4e1ca7327d5b171db332ac23/k_util/logger.py#L305-L309