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
mweb/appconfig
appconfig/appconfig.py
AppConfig.get
def get(self, section, key): ''' Get the value of a key in the given section. It will automatically translate the paramter type if the parameter has a type specified with the description. @param section: the section where the key can be found. @param key: the key...
python
def get(self, section, key): ''' Get the value of a key in the given section. It will automatically translate the paramter type if the parameter has a type specified with the description. @param section: the section where the key can be found. @param key: the key...
[ "def", "get", "(", "self", ",", "section", ",", "key", ")", ":", "section", "=", "section", ".", "lower", "(", ")", "key", "=", "key", ".", "lower", "(", ")", "descr", ",", "value_type", ",", "default", "=", "self", ".", "get_description", "(", "se...
Get the value of a key in the given section. It will automatically translate the paramter type if the parameter has a type specified with the description. @param section: the section where the key can be found. @param key: the key the value is stored under. @...
[ "Get", "the", "value", "of", "a", "key", "in", "the", "given", "section", ".", "It", "will", "automatically", "translate", "the", "paramter", "type", "if", "the", "parameter", "has", "a", "type", "specified", "with", "the", "description", "." ]
train
https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L168-L196
mweb/appconfig
appconfig/appconfig.py
AppConfig.set
def set(self, section, key, value): ''' Set the value for a key in the given section. It will check the type of the value if it is available. If the value is not from the given type it will be transformed to the type. An exception will be thrown if there is a problem with the...
python
def set(self, section, key, value): ''' Set the value for a key in the given section. It will check the type of the value if it is available. If the value is not from the given type it will be transformed to the type. An exception will be thrown if there is a problem with the...
[ "def", "set", "(", "self", ",", "section", ",", "key", ",", "value", ")", ":", "value_type", "=", "str", "if", "self", ".", "has_option", "(", "section", ",", "key", ")", ":", "descr", ",", "value_type", ",", "default", "=", "self", ".", "get_descrip...
Set the value for a key in the given section. It will check the type of the value if it is available. If the value is not from the given type it will be transformed to the type. An exception will be thrown if there is a problem with the conversion. @param sec...
[ "Set", "the", "value", "for", "a", "key", "in", "the", "given", "section", ".", "It", "will", "check", "the", "type", "of", "the", "value", "if", "it", "is", "available", ".", "If", "the", "value", "is", "not", "from", "the", "given", "type", "it", ...
train
https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L198-L234
mweb/appconfig
appconfig/appconfig.py
AppConfig.save
def save(self, filename=None, verbose=False): ''' Save the config to the given file or to given default location. @param filename: the file to write the config @param verbose: If set to true the config file will have all values and all descriptions ''' ...
python
def save(self, filename=None, verbose=False): ''' Save the config to the given file or to given default location. @param filename: the file to write the config @param verbose: If set to true the config file will have all values and all descriptions ''' ...
[ "def", "save", "(", "self", ",", "filename", "=", "None", ",", "verbose", "=", "False", ")", ":", "if", "filename", "is", "None", ":", "if", "(", "not", "self", ".", "has_section", "(", "self", ".", "application_name", ")", "or", "not", "self", ".", ...
Save the config to the given file or to given default location. @param filename: the file to write the config @param verbose: If set to true the config file will have all values and all descriptions
[ "Save", "the", "config", "to", "the", "given", "file", "or", "to", "given", "default", "location", "." ]
train
https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L236-L282
mweb/appconfig
appconfig/appconfig.py
AppConfig._write_config
def _write_config(self, filedesc, verbose=False): ''' Write the current config to the given filedescriptor which has must be opened for writing. Only the config values different from the default value are written If the verbose switch is turned on the config file generated w...
python
def _write_config(self, filedesc, verbose=False): ''' Write the current config to the given filedescriptor which has must be opened for writing. Only the config values different from the default value are written If the verbose switch is turned on the config file generated w...
[ "def", "_write_config", "(", "self", ",", "filedesc", ",", "verbose", "=", "False", ")", ":", "desc", "=", "[", "]", "for", "section", "in", "self", ".", "sections", "(", ")", ":", "if", "section", ".", "lower", "(", ")", "in", "(", "''", ",", "'...
Write the current config to the given filedescriptor which has must be opened for writing. Only the config values different from the default value are written If the verbose switch is turned on the config file generated will have all values including the default values s...
[ "Write", "the", "current", "config", "to", "the", "given", "filedescriptor", "which", "has", "must", "be", "opened", "for", "writing", ".", "Only", "the", "config", "values", "different", "from", "the", "default", "value", "are", "written" ]
train
https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L284-L316
mweb/appconfig
appconfig/appconfig.py
AppConfig._add_section_default
def _add_section_default(self, section, parameters): ''' Add the given section with the given paramters to the config. The parameters must be a dictionary with all the keys to add. Each key must be specified as an other dictionary with the following parameters: default, descr...
python
def _add_section_default(self, section, parameters): ''' Add the given section with the given paramters to the config. The parameters must be a dictionary with all the keys to add. Each key must be specified as an other dictionary with the following parameters: default, descr...
[ "def", "_add_section_default", "(", "self", ",", "section", ",", "parameters", ")", ":", "section", "=", "section", ".", "lower", "(", ")", "if", "not", "self", ".", "has_section", "(", "section", ")", ":", "self", ".", "add_section", "(", "section", ")"...
Add the given section with the given paramters to the config. The parameters must be a dictionary with all the keys to add. Each key must be specified as an other dictionary with the following parameters: default, description, type @param section: The section to add ...
[ "Add", "the", "given", "section", "with", "the", "given", "paramters", "to", "the", "config", ".", "The", "parameters", "must", "be", "a", "dictionary", "with", "all", "the", "keys", "to", "add", ".", "Each", "key", "must", "be", "specified", "as", "an",...
train
https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L318-L344
sassoo/goldman
goldman/serializers/json_7159.py
Serializer.serialize
def serialize(self, data): """ Call json.dumps & let it rip """ super(Serializer, self).serialize(data) self.resp.body = json.dumps(data)
python
def serialize(self, data): """ Call json.dumps & let it rip """ super(Serializer, self).serialize(data) self.resp.body = json.dumps(data)
[ "def", "serialize", "(", "self", ",", "data", ")", ":", "super", "(", "Serializer", ",", "self", ")", ".", "serialize", "(", "data", ")", "self", ".", "resp", ".", "body", "=", "json", ".", "dumps", "(", "data", ")" ]
Call json.dumps & let it rip
[ "Call", "json", ".", "dumps", "&", "let", "it", "rip" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/json_7159.py#L21-L25
evfredericksen/pynacea
pynhost/pynhost/ruleparser.py
surround_previous_word
def surround_previous_word(input_str): ''' Surround last word in string with parentheses. If last non-whitespace character is delimiter, do nothing ''' start = None end = None for i, char in enumerate(reversed(input_str)): if start is None: if char in '{}()[]<>?|': ...
python
def surround_previous_word(input_str): ''' Surround last word in string with parentheses. If last non-whitespace character is delimiter, do nothing ''' start = None end = None for i, char in enumerate(reversed(input_str)): if start is None: if char in '{}()[]<>?|': ...
[ "def", "surround_previous_word", "(", "input_str", ")", ":", "start", "=", "None", "end", "=", "None", "for", "i", ",", "char", "in", "enumerate", "(", "reversed", "(", "input_str", ")", ")", ":", "if", "start", "is", "None", ":", "if", "char", "in", ...
Surround last word in string with parentheses. If last non-whitespace character is delimiter, do nothing
[ "Surround", "last", "word", "in", "string", "with", "parentheses", ".", "If", "last", "non", "-", "whitespace", "character", "is", "delimiter", "do", "nothing" ]
train
https://github.com/evfredericksen/pynacea/blob/63ee0e6695209048bf2571aa2c3770f502e29b0a/pynhost/pynhost/ruleparser.py#L118-L150
anoroozian/pyvt
pyvt/__init__.py
API._grouped
def _grouped(iterable, n): """ take a list of items and return a list of groups of size n. :param n: the size of the groups to return """ args = [iter(iterable)] * n return [[e for e in t if not e is None] for t in zip_longest(*args, fillvalue=None)]
python
def _grouped(iterable, n): """ take a list of items and return a list of groups of size n. :param n: the size of the groups to return """ args = [iter(iterable)] * n return [[e for e in t if not e is None] for t in zip_longest(*args, fillvalue=None)]
[ "def", "_grouped", "(", "iterable", ",", "n", ")", ":", "args", "=", "[", "iter", "(", "iterable", ")", "]", "*", "n", "return", "[", "[", "e", "for", "e", "in", "t", "if", "not", "e", "is", "None", "]", "for", "t", "in", "zip_longest", "(", ...
take a list of items and return a list of groups of size n. :param n: the size of the groups to return
[ "take", "a", "list", "of", "items", "and", "return", "a", "list", "of", "groups", "of", "size", "n", ".", ":", "param", "n", ":", "the", "size", "of", "the", "groups", "to", "return" ]
train
https://github.com/anoroozian/pyvt/blob/bf36f833f1f1b7d93169fd9ad451e06b7d46afc1/pyvt/__init__.py#L47-L53
anoroozian/pyvt
pyvt/__init__.py
API._limit_call_handler
def _limit_call_handler(self): """ Ensure we don't exceed the N requests a minute limit by leveraging a thread lock """ # acquire a lock on our threading.Lock() object with self.limit_lock: # if we have no configured limit, exit. the lock releases based on scope ...
python
def _limit_call_handler(self): """ Ensure we don't exceed the N requests a minute limit by leveraging a thread lock """ # acquire a lock on our threading.Lock() object with self.limit_lock: # if we have no configured limit, exit. the lock releases based on scope ...
[ "def", "_limit_call_handler", "(", "self", ")", ":", "# acquire a lock on our threading.Lock() object", "with", "self", ".", "limit_lock", ":", "# if we have no configured limit, exit. the lock releases based on scope", "if", "self", ".", "limit_per_min", "<=", "0", ":", "re...
Ensure we don't exceed the N requests a minute limit by leveraging a thread lock
[ "Ensure", "we", "don", "t", "exceed", "the", "N", "requests", "a", "minute", "limit", "by", "leveraging", "a", "thread", "lock" ]
train
https://github.com/anoroozian/pyvt/blob/bf36f833f1f1b7d93169fd9ad451e06b7d46afc1/pyvt/__init__.py#L55-L79
anoroozian/pyvt
pyvt/__init__.py
API._whatis
def _whatis(self, thing): """ Categorizes the thing it gets passed into one of the items VT supports Returns a sting representation of the type of parameter passed in. \n :param thing: a parameter to identify. this can be a list of string or a string :return: a string representin...
python
def _whatis(self, thing): """ Categorizes the thing it gets passed into one of the items VT supports Returns a sting representation of the type of parameter passed in. \n :param thing: a parameter to identify. this can be a list of string or a string :return: a string representin...
[ "def", "_whatis", "(", "self", ",", "thing", ")", ":", "# per the API, bulk requests must be of the same type", "# ignore that you can intersperse scan IDs and hashes for now", "# ...although, does that actually matter given the API semantics?", "if", "isinstance", "(", "thing", ",", ...
Categorizes the thing it gets passed into one of the items VT supports Returns a sting representation of the type of parameter passed in. \n :param thing: a parameter to identify. this can be a list of string or a string :return: a string representing the identified type of the input thing. If t...
[ "Categorizes", "the", "thing", "it", "gets", "passed", "into", "one", "of", "the", "items", "VT", "supports", "Returns", "a", "sting", "representation", "of", "the", "type", "of", "parameter", "passed", "in", ".", "\\", "n", ":", "param", "thing", ":", "...
train
https://github.com/anoroozian/pyvt/blob/bf36f833f1f1b7d93169fd9ad451e06b7d46afc1/pyvt/__init__.py#L81-L121
anoroozian/pyvt
pyvt/__init__.py
API._get_query
def _get_query(self, query, params): """ Submit a GET request to the VT API :param query: The query (see https://www.virustotal.com/en/documentation/private-api/ for types of queries) :param params: parameters of the query :return: JSON formatted response from the API """...
python
def _get_query(self, query, params): """ Submit a GET request to the VT API :param query: The query (see https://www.virustotal.com/en/documentation/private-api/ for types of queries) :param params: parameters of the query :return: JSON formatted response from the API """...
[ "def", "_get_query", "(", "self", ",", "query", ",", "params", ")", ":", "if", "\"apikey\"", "not", "in", "params", ":", "params", "[", "\"apikey\"", "]", "=", "self", ".", "api_key", "response", "=", "requests", ".", "get", "(", "query", ",", "params"...
Submit a GET request to the VT API :param query: The query (see https://www.virustotal.com/en/documentation/private-api/ for types of queries) :param params: parameters of the query :return: JSON formatted response from the API
[ "Submit", "a", "GET", "request", "to", "the", "VT", "API", ":", "param", "query", ":", "The", "query", "(", "see", "https", ":", "//", "www", ".", "virustotal", ".", "com", "/", "en", "/", "documentation", "/", "private", "-", "api", "/", "for", "t...
train
https://github.com/anoroozian/pyvt/blob/bf36f833f1f1b7d93169fd9ad451e06b7d46afc1/pyvt/__init__.py#L123-L134
anoroozian/pyvt
pyvt/__init__.py
API._post_query
def _post_query(self, query, params): """ Submit a POST request to the VT API :param query: The query (see https://www.virustotal.com/en/documentation/private-api/ for types of queries) :param params: parameters of the query :return: JSON formatted response from the API "...
python
def _post_query(self, query, params): """ Submit a POST request to the VT API :param query: The query (see https://www.virustotal.com/en/documentation/private-api/ for types of queries) :param params: parameters of the query :return: JSON formatted response from the API "...
[ "def", "_post_query", "(", "self", ",", "query", ",", "params", ")", ":", "if", "\"apikey\"", "not", "in", "params", ":", "params", "[", "\"apikey\"", "]", "=", "self", ".", "api_key", "response", "=", "requests", ".", "post", "(", "query", ",", "data"...
Submit a POST request to the VT API :param query: The query (see https://www.virustotal.com/en/documentation/private-api/ for types of queries) :param params: parameters of the query :return: JSON formatted response from the API
[ "Submit", "a", "POST", "request", "to", "the", "VT", "API", ":", "param", "query", ":", "The", "query", "(", "see", "https", ":", "//", "www", ".", "virustotal", ".", "com", "/", "en", "/", "documentation", "/", "private", "-", "api", "/", "for", "...
train
https://github.com/anoroozian/pyvt/blob/bf36f833f1f1b7d93169fd9ad451e06b7d46afc1/pyvt/__init__.py#L136-L147
anoroozian/pyvt
pyvt/__init__.py
API.retrieve
def retrieve(self, thing, thing_type=None): """ Retrieve a report from VirusTotal based on a hash, IP, domain, file or URL or ScanID. NOTE: URLs must include the scheme (e.g. http://)\n :param thing: a file name on the local system, a URL or list of URLs, an IP o...
python
def retrieve(self, thing, thing_type=None): """ Retrieve a report from VirusTotal based on a hash, IP, domain, file or URL or ScanID. NOTE: URLs must include the scheme (e.g. http://)\n :param thing: a file name on the local system, a URL or list of URLs, an IP o...
[ "def", "retrieve", "(", "self", ",", "thing", ",", "thing_type", "=", "None", ")", ":", "# trust the user-supplied type over the automatic identification", "thing_id", "=", "self", ".", "_whatis", "(", "thing", ")", "if", "thing_type", "is", "None", ":", "thing_ty...
Retrieve a report from VirusTotal based on a hash, IP, domain, file or URL or ScanID. NOTE: URLs must include the scheme (e.g. http://)\n :param thing: a file name on the local system, a URL or list of URLs, an IP or list of IPs, a domain or list of domains, a hash or list of ha...
[ "Retrieve", "a", "report", "from", "VirusTotal", "based", "on", "a", "hash", "IP", "domain", "file", "or", "URL", "or", "ScanID", ".", "NOTE", ":", "URLs", "must", "include", "the", "scheme", "(", "e", ".", "g", ".", "http", ":", "//", ")", "\\", "...
train
https://github.com/anoroozian/pyvt/blob/bf36f833f1f1b7d93169fd9ad451e06b7d46afc1/pyvt/__init__.py#L149-L269
anoroozian/pyvt
pyvt/__init__.py
API.scan
def scan(self, thing, thing_type=None, blocking=False): """ \nScan a single or list of URLs, or Domains\n NOTE: URLs must include the scheme (http:// or https://)\n NOTE: For a single domain or list of domains this method will automatically append an 'http://' to the \n beginning...
python
def scan(self, thing, thing_type=None, blocking=False): """ \nScan a single or list of URLs, or Domains\n NOTE: URLs must include the scheme (http:// or https://)\n NOTE: For a single domain or list of domains this method will automatically append an 'http://' to the \n beginning...
[ "def", "scan", "(", "self", ",", "thing", ",", "thing_type", "=", "None", ",", "blocking", "=", "False", ")", ":", "thing_id", "=", "self", ".", "_whatis", "(", "thing", ")", "if", "thing_type", "is", "None", ":", "thing_type", "=", "thing_id", "query_...
\nScan a single or list of URLs, or Domains\n NOTE: URLs must include the scheme (http:// or https://)\n NOTE: For a single domain or list of domains this method will automatically append an 'http://' to the \n beginningof the domain(s)\n :param thing: a URL or list of URLs, ...
[ "\\", "nScan", "a", "single", "or", "list", "of", "URLs", "or", "Domains", "\\", "n", "NOTE", ":", "URLs", "must", "include", "the", "scheme", "(", "http", ":", "//", "or", "https", ":", "//", ")", "\\", "n", "NOTE", ":", "For", "a", "single", "d...
train
https://github.com/anoroozian/pyvt/blob/bf36f833f1f1b7d93169fd9ad451e06b7d46afc1/pyvt/__init__.py#L271-L360
lambdalisue/django-roughpages
src/roughpages/views.py
roughpage
def roughpage(request, url): """ Public interface to the rough page view. """ if settings.APPEND_SLASH and not url.endswith('/'): # redirect to the url which have end slash return redirect(url + '/', permanent=True) # get base filename from url filename = url_to_filename(url) ...
python
def roughpage(request, url): """ Public interface to the rough page view. """ if settings.APPEND_SLASH and not url.endswith('/'): # redirect to the url which have end slash return redirect(url + '/', permanent=True) # get base filename from url filename = url_to_filename(url) ...
[ "def", "roughpage", "(", "request", ",", "url", ")", ":", "if", "settings", ".", "APPEND_SLASH", "and", "not", "url", ".", "endswith", "(", "'/'", ")", ":", "# redirect to the url which have end slash", "return", "redirect", "(", "url", "+", "'/'", ",", "per...
Public interface to the rough page view.
[ "Public", "interface", "to", "the", "rough", "page", "view", "." ]
train
https://github.com/lambdalisue/django-roughpages/blob/f6a2724ece729c5deced2c2546d172561ef785ec/src/roughpages/views.py#L25-L46
lambdalisue/django-roughpages
src/roughpages/views.py
render_roughpage
def render_roughpage(request, t): """ Internal interface to the rough page view. """ import django if django.VERSION >= (1, 8): c = {} response = HttpResponse(t.render(c, request)) else: c = RequestContext(request) response = HttpResponse(t.render(c)) return r...
python
def render_roughpage(request, t): """ Internal interface to the rough page view. """ import django if django.VERSION >= (1, 8): c = {} response = HttpResponse(t.render(c, request)) else: c = RequestContext(request) response = HttpResponse(t.render(c)) return r...
[ "def", "render_roughpage", "(", "request", ",", "t", ")", ":", "import", "django", "if", "django", ".", "VERSION", ">=", "(", "1", ",", "8", ")", ":", "c", "=", "{", "}", "response", "=", "HttpResponse", "(", "t", ".", "render", "(", "c", ",", "r...
Internal interface to the rough page view.
[ "Internal", "interface", "to", "the", "rough", "page", "view", "." ]
train
https://github.com/lambdalisue/django-roughpages/blob/f6a2724ece729c5deced2c2546d172561ef785ec/src/roughpages/views.py#L50-L61
ronaldguillen/wave
wave/request.py
is_form_media_type
def is_form_media_type(media_type): """ Return True if the media type is a valid form media type. """ base_media_type, params = parse_header(media_type.encode(HTTP_HEADER_ENCODING)) return (base_media_type == 'application/x-www-form-urlencoded' or base_media_type == 'multipart/form-data'...
python
def is_form_media_type(media_type): """ Return True if the media type is a valid form media type. """ base_media_type, params = parse_header(media_type.encode(HTTP_HEADER_ENCODING)) return (base_media_type == 'application/x-www-form-urlencoded' or base_media_type == 'multipart/form-data'...
[ "def", "is_form_media_type", "(", "media_type", ")", ":", "base_media_type", ",", "params", "=", "parse_header", "(", "media_type", ".", "encode", "(", "HTTP_HEADER_ENCODING", ")", ")", "return", "(", "base_media_type", "==", "'application/x-www-form-urlencoded'", "or...
Return True if the media type is a valid form media type.
[ "Return", "True", "if", "the", "media", "type", "is", "a", "valid", "form", "media", "type", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L25-L31
ronaldguillen/wave
wave/request.py
clone_request
def clone_request(request, method): """ Internal helper method to clone a request, replacing with a different HTTP method. Used for checking permissions against other methods. """ ret = Request(request=request._request, parsers=request.parsers, authenticators=req...
python
def clone_request(request, method): """ Internal helper method to clone a request, replacing with a different HTTP method. Used for checking permissions against other methods. """ ret = Request(request=request._request, parsers=request.parsers, authenticators=req...
[ "def", "clone_request", "(", "request", ",", "method", ")", ":", "ret", "=", "Request", "(", "request", "=", "request", ".", "_request", ",", "parsers", "=", "request", ".", "parsers", ",", "authenticators", "=", "request", ".", "authenticators", ",", "neg...
Internal helper method to clone a request, replacing with a different HTTP method. Used for checking permissions against other methods.
[ "Internal", "helper", "method", "to", "clone", "a", "request", "replacing", "with", "a", "different", "HTTP", "method", ".", "Used", "for", "checking", "permissions", "against", "other", "methods", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L74-L104
ronaldguillen/wave
wave/request.py
Request.user
def user(self, value): """ Sets the user on the current request. This is necessary to maintain compatibility with django.contrib.auth where the user property is set in the login and logout functions. Note that we also set the user on Django's underlying `HttpRequest` ins...
python
def user(self, value): """ Sets the user on the current request. This is necessary to maintain compatibility with django.contrib.auth where the user property is set in the login and logout functions. Note that we also set the user on Django's underlying `HttpRequest` ins...
[ "def", "user", "(", "self", ",", "value", ")", ":", "self", ".", "_user", "=", "value", "self", ".", "_request", ".", "user", "=", "value" ]
Sets the user on the current request. This is necessary to maintain compatibility with django.contrib.auth where the user property is set in the login and logout functions. Note that we also set the user on Django's underlying `HttpRequest` instance, ensuring that it is available to any...
[ "Sets", "the", "user", "on", "the", "current", "request", ".", "This", "is", "necessary", "to", "maintain", "compatibility", "with", "django", ".", "contrib", ".", "auth", "where", "the", "user", "property", "is", "set", "in", "the", "login", "and", "logou...
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L197-L207
ronaldguillen/wave
wave/request.py
Request.auth
def auth(self, value): """ Sets any non-user authentication information associated with the request, such as an authentication token. """ self._auth = value self._request.auth = value
python
def auth(self, value): """ Sets any non-user authentication information associated with the request, such as an authentication token. """ self._auth = value self._request.auth = value
[ "def", "auth", "(", "self", ",", "value", ")", ":", "self", ".", "_auth", "=", "value", "self", ".", "_request", ".", "auth", "=", "value" ]
Sets any non-user authentication information associated with the request, such as an authentication token.
[ "Sets", "any", "non", "-", "user", "authentication", "information", "associated", "with", "the", "request", "such", "as", "an", "authentication", "token", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L220-L226
ronaldguillen/wave
wave/request.py
Request._load_data_and_files
def _load_data_and_files(self): """ Parses the request content into `self.data`. """ if not _hasattr(self, '_data'): self._data, self._files = self._parse() if self._files: self._full_data = self._data.copy() self._full_data.update(...
python
def _load_data_and_files(self): """ Parses the request content into `self.data`. """ if not _hasattr(self, '_data'): self._data, self._files = self._parse() if self._files: self._full_data = self._data.copy() self._full_data.update(...
[ "def", "_load_data_and_files", "(", "self", ")", ":", "if", "not", "_hasattr", "(", "self", ",", "'_data'", ")", ":", "self", ".", "_data", ",", "self", ".", "_files", "=", "self", ".", "_parse", "(", ")", "if", "self", ".", "_files", ":", "self", ...
Parses the request content into `self.data`.
[ "Parses", "the", "request", "content", "into", "self", ".", "data", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L238-L248
ronaldguillen/wave
wave/request.py
Request._load_stream
def _load_stream(self): """ Return the content body of the request, as a stream. """ meta = self._request.META try: content_length = int( meta.get('CONTENT_LENGTH', meta.get('HTTP_CONTENT_LENGTH', 0)) ) except (ValueError, TypeError...
python
def _load_stream(self): """ Return the content body of the request, as a stream. """ meta = self._request.META try: content_length = int( meta.get('CONTENT_LENGTH', meta.get('HTTP_CONTENT_LENGTH', 0)) ) except (ValueError, TypeError...
[ "def", "_load_stream", "(", "self", ")", ":", "meta", "=", "self", ".", "_request", ".", "META", "try", ":", "content_length", "=", "int", "(", "meta", ".", "get", "(", "'CONTENT_LENGTH'", ",", "meta", ".", "get", "(", "'HTTP_CONTENT_LENGTH'", ",", "0", ...
Return the content body of the request, as a stream.
[ "Return", "the", "content", "body", "of", "the", "request", "as", "a", "stream", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L250-L267
ronaldguillen/wave
wave/request.py
Request._parse
def _parse(self): """ Parse the request content, returning a two-tuple of (data, files) May raise an `UnsupportedMediaType`, or `ParseError` exception. """ stream = self.stream media_type = self.content_type if stream is None or media_type is None: e...
python
def _parse(self): """ Parse the request content, returning a two-tuple of (data, files) May raise an `UnsupportedMediaType`, or `ParseError` exception. """ stream = self.stream media_type = self.content_type if stream is None or media_type is None: e...
[ "def", "_parse", "(", "self", ")", ":", "stream", "=", "self", ".", "stream", "media_type", "=", "self", ".", "content_type", "if", "stream", "is", "None", "or", "media_type", "is", "None", ":", "empty_data", "=", "QueryDict", "(", "''", ",", "encoding",...
Parse the request content, returning a two-tuple of (data, files) May raise an `UnsupportedMediaType`, or `ParseError` exception.
[ "Parse", "the", "request", "content", "returning", "a", "two", "-", "tuple", "of", "(", "data", "files", ")" ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L269-L306
ronaldguillen/wave
wave/request.py
Request._authenticate
def _authenticate(self): """ Attempt to authenticate the request using each authentication instance in turn. Returns a three-tuple of (authenticator, user, authtoken). """ for authenticator in self.authenticators: try: user_auth_tuple = authent...
python
def _authenticate(self): """ Attempt to authenticate the request using each authentication instance in turn. Returns a three-tuple of (authenticator, user, authtoken). """ for authenticator in self.authenticators: try: user_auth_tuple = authent...
[ "def", "_authenticate", "(", "self", ")", ":", "for", "authenticator", "in", "self", ".", "authenticators", ":", "try", ":", "user_auth_tuple", "=", "authenticator", ".", "authenticate", "(", "self", ")", "except", "exceptions", ".", "APIException", ":", "self...
Attempt to authenticate the request using each authentication instance in turn. Returns a three-tuple of (authenticator, user, authtoken).
[ "Attempt", "to", "authenticate", "the", "request", "using", "each", "authentication", "instance", "in", "turn", ".", "Returns", "a", "three", "-", "tuple", "of", "(", "authenticator", "user", "authtoken", ")", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L308-L326
ronaldguillen/wave
wave/request.py
Request._not_authenticated
def _not_authenticated(self): """ Return a three-tuple of (authenticator, user, authtoken), representing an unauthenticated request. By default this will be (None, AnonymousUser, None). """ self._authenticator = None if api_settings.UNAUTHENTICATED_USER: ...
python
def _not_authenticated(self): """ Return a three-tuple of (authenticator, user, authtoken), representing an unauthenticated request. By default this will be (None, AnonymousUser, None). """ self._authenticator = None if api_settings.UNAUTHENTICATED_USER: ...
[ "def", "_not_authenticated", "(", "self", ")", ":", "self", ".", "_authenticator", "=", "None", "if", "api_settings", ".", "UNAUTHENTICATED_USER", ":", "self", ".", "user", "=", "api_settings", ".", "UNAUTHENTICATED_USER", "(", ")", "else", ":", "self", ".", ...
Return a three-tuple of (authenticator, user, authtoken), representing an unauthenticated request. By default this will be (None, AnonymousUser, None).
[ "Return", "a", "three", "-", "tuple", "of", "(", "authenticator", "user", "authtoken", ")", "representing", "an", "unauthenticated", "request", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L328-L345
LesPatamechanix/patalib
src/patalib/antonym.py
Antonym.generate_antonym
def generate_antonym(self, input_word): """ Generate an antonym using a Synset and its lemmas. """ results = [] synset = wordnet.synsets(input_word) for i in synset: if i.pos in ['n','v']: for j in i.lemmas: if j.antonyms(): ...
python
def generate_antonym(self, input_word): """ Generate an antonym using a Synset and its lemmas. """ results = [] synset = wordnet.synsets(input_word) for i in synset: if i.pos in ['n','v']: for j in i.lemmas: if j.antonyms(): ...
[ "def", "generate_antonym", "(", "self", ",", "input_word", ")", ":", "results", "=", "[", "]", "synset", "=", "wordnet", ".", "synsets", "(", "input_word", ")", "for", "i", "in", "synset", ":", "if", "i", ".", "pos", "in", "[", "'n'", ",", "'v'", "...
Generate an antonym using a Synset and its lemmas.
[ "Generate", "an", "antonym", "using", "a", "Synset", "and", "its", "lemmas", "." ]
train
https://github.com/LesPatamechanix/patalib/blob/d88cca409b1750fdeb88cece048b308f2a710955/src/patalib/antonym.py#L9-L22
ikalnytskyi/dooku
dooku/ext.py
ExtensionManager.get
def get(self, name, default=None): """ Returns an extension instance with a given name. In case there are few extensions with a given name, the first one will be returned. If no extensions with a given name are exist, the `default` value will be returned. :param name: (...
python
def get(self, name, default=None): """ Returns an extension instance with a given name. In case there are few extensions with a given name, the first one will be returned. If no extensions with a given name are exist, the `default` value will be returned. :param name: (...
[ "def", "get", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "try", ":", "value", "=", "self", "[", "name", "]", "except", "KeyError", ":", "value", "=", "default", "return", "value" ]
Returns an extension instance with a given name. In case there are few extensions with a given name, the first one will be returned. If no extensions with a given name are exist, the `default` value will be returned. :param name: (str) an extension name :param default: (object)...
[ "Returns", "an", "extension", "instance", "with", "a", "given", "name", "." ]
train
https://github.com/ikalnytskyi/dooku/blob/77e6c82c9c41211c86ee36ae5e591d477945fedf/dooku/ext.py#L98-L114
radjkarl/fancyTools
fancytools/math/line.py
cutToFitIntoPolygon
def cutToFitIntoPolygon(line, polygon): """ cut line so it fits into polygon polygon = (( x0,y0), (x1,y1) ,...) """ p0_inside = pointInsidePolygon(line[0], line[1], polygon) p1_inside = pointInsidePolygon(line[2], line[3], polygon) if not p0_inside or not p1_inside: for (i0, j0), (i...
python
def cutToFitIntoPolygon(line, polygon): """ cut line so it fits into polygon polygon = (( x0,y0), (x1,y1) ,...) """ p0_inside = pointInsidePolygon(line[0], line[1], polygon) p1_inside = pointInsidePolygon(line[2], line[3], polygon) if not p0_inside or not p1_inside: for (i0, j0), (i...
[ "def", "cutToFitIntoPolygon", "(", "line", ",", "polygon", ")", ":", "p0_inside", "=", "pointInsidePolygon", "(", "line", "[", "0", "]", ",", "line", "[", "1", "]", ",", "polygon", ")", "p1_inside", "=", "pointInsidePolygon", "(", "line", "[", "2", "]", ...
cut line so it fits into polygon polygon = (( x0,y0), (x1,y1) ,...)
[ "cut", "line", "so", "it", "fits", "into", "polygon", "polygon", "=", "((", "x0", "y0", ")", "(", "x1", "y1", ")", "...", ")" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L22-L45
radjkarl/fancyTools
fancytools/math/line.py
sort
def sort(line): """ change point position if x1,y0 < x0,y0 """ x0, y0, x1, y1 = line # if (x0**2+y0**2)**0.5 < (x1**2+y1**2)**0.5: # return (x1,y1,x0,y0) # return line # # if x1 < x0: # return (x1,y1,x0,y0) # return line turn = False ...
python
def sort(line): """ change point position if x1,y0 < x0,y0 """ x0, y0, x1, y1 = line # if (x0**2+y0**2)**0.5 < (x1**2+y1**2)**0.5: # return (x1,y1,x0,y0) # return line # # if x1 < x0: # return (x1,y1,x0,y0) # return line turn = False ...
[ "def", "sort", "(", "line", ")", ":", "x0", ",", "y0", ",", "x1", ",", "y1", "=", "line", "# if (x0**2+y0**2)**0.5 < (x1**2+y1**2)**0.5:", "# return (x1,y1,x0,y0)", "# return line", "#", "# if x1 < x0:", "# return (x1,y1,x0,y0)", "# return li...
change point position if x1,y0 < x0,y0
[ "change", "point", "position", "if", "x1", "y0", "<", "x0", "y0" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L49-L73
radjkarl/fancyTools
fancytools/math/line.py
dxdy
def dxdy(line): """ return normalised ascent vector """ x0, y0, x1, y1 = line dx = float(x1 - x0) dy = float(y1 - y0) f = hypot(dx, dy) return dx / f, dy / f
python
def dxdy(line): """ return normalised ascent vector """ x0, y0, x1, y1 = line dx = float(x1 - x0) dy = float(y1 - y0) f = hypot(dx, dy) return dx / f, dy / f
[ "def", "dxdy", "(", "line", ")", ":", "x0", ",", "y0", ",", "x1", ",", "y1", "=", "line", "dx", "=", "float", "(", "x1", "-", "x0", ")", "dy", "=", "float", "(", "y1", "-", "y0", ")", "f", "=", "hypot", "(", "dx", ",", "dy", ")", "return"...
return normalised ascent vector
[ "return", "normalised", "ascent", "vector" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L104-L112
radjkarl/fancyTools
fancytools/math/line.py
fromAttr
def fromAttr(mid, ang, dist): """ create from middle, angle and distance """ mx, my = mid dx = cos(ang) * dist * 0.5 dy = sin(ang) * dist * 0.5 return mx - dx, my - dy, mx + dx, my + dy
python
def fromAttr(mid, ang, dist): """ create from middle, angle and distance """ mx, my = mid dx = cos(ang) * dist * 0.5 dy = sin(ang) * dist * 0.5 return mx - dx, my - dy, mx + dx, my + dy
[ "def", "fromAttr", "(", "mid", ",", "ang", ",", "dist", ")", ":", "mx", ",", "my", "=", "mid", "dx", "=", "cos", "(", "ang", ")", "*", "dist", "*", "0.5", "dy", "=", "sin", "(", "ang", ")", "*", "dist", "*", "0.5", "return", "mx", "-", "dx"...
create from middle, angle and distance
[ "create", "from", "middle", "angle", "and", "distance" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L151-L158
radjkarl/fancyTools
fancytools/math/line.py
fromAttr2
def fromAttr2(start, ang, dist): """ create from start, angle and distance """ sx, sy = start dx = cos(ang) * dist dy = sin(ang) * dist return sx, sy, sx + dx, sy + dy
python
def fromAttr2(start, ang, dist): """ create from start, angle and distance """ sx, sy = start dx = cos(ang) * dist dy = sin(ang) * dist return sx, sy, sx + dx, sy + dy
[ "def", "fromAttr2", "(", "start", ",", "ang", ",", "dist", ")", ":", "sx", ",", "sy", "=", "start", "dx", "=", "cos", "(", "ang", ")", "*", "dist", "dy", "=", "sin", "(", "ang", ")", "*", "dist", "return", "sx", ",", "sy", ",", "sx", "+", "...
create from start, angle and distance
[ "create", "from", "start", "angle", "and", "distance" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L161-L168
radjkarl/fancyTools
fancytools/math/line.py
merge
def merge(l1, l2): """ merge 2 lines together """ x1, y1, x2, y2 = l1 xx1, yy1, xx2, yy2 = l2 comb = ((x1, y1, xx1, yy1), (x1, y1, xx2, yy2), (x2, y2, xx1, yy1), (x2, y2, xx2, yy2)) d = [length(c) for c in comb] i = argmax(d) dist = d[i] mid...
python
def merge(l1, l2): """ merge 2 lines together """ x1, y1, x2, y2 = l1 xx1, yy1, xx2, yy2 = l2 comb = ((x1, y1, xx1, yy1), (x1, y1, xx2, yy2), (x2, y2, xx1, yy1), (x2, y2, xx2, yy2)) d = [length(c) for c in comb] i = argmax(d) dist = d[i] mid...
[ "def", "merge", "(", "l1", ",", "l2", ")", ":", "x1", ",", "y1", ",", "x2", ",", "y2", "=", "l1", "xx1", ",", "yy1", ",", "xx2", ",", "yy2", "=", "l2", "comb", "=", "(", "(", "x1", ",", "y1", ",", "xx1", ",", "yy1", ")", ",", "(", "x1",...
merge 2 lines together
[ "merge", "2", "lines", "together" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L190-L209
radjkarl/fancyTools
fancytools/math/line.py
resize
def resize(line, factor): """ factor: relative length (1->no change, 2-> double, 0.5:half) """ a = angle(line) mx, my = middle(line) d = length(line) * factor * 0.5 dx = cos(a) * d dy = sin(a) * d return mx - dx, my - dy, mx + dx, my + dy
python
def resize(line, factor): """ factor: relative length (1->no change, 2-> double, 0.5:half) """ a = angle(line) mx, my = middle(line) d = length(line) * factor * 0.5 dx = cos(a) * d dy = sin(a) * d return mx - dx, my - dy, mx + dx, my + dy
[ "def", "resize", "(", "line", ",", "factor", ")", ":", "a", "=", "angle", "(", "line", ")", "mx", ",", "my", "=", "middle", "(", "line", ")", "d", "=", "length", "(", "line", ")", "*", "factor", "*", "0.5", "dx", "=", "cos", "(", "a", ")", ...
factor: relative length (1->no change, 2-> double, 0.5:half)
[ "factor", ":", "relative", "length", "(", "1", "-", ">", "no", "change", "2", "-", ">", "double", "0", ".", "5", ":", "half", ")" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L212-L221
radjkarl/fancyTools
fancytools/math/line.py
distance
def distance(line, point): """ infinite line to point or line to line distance is point is given as line - use middle point of that liune """ x0, y0, x1, y1 = line try: p1, p2 = point except ValueError: # line is given instead of point p1, p2 = middle(point) n1 = ...
python
def distance(line, point): """ infinite line to point or line to line distance is point is given as line - use middle point of that liune """ x0, y0, x1, y1 = line try: p1, p2 = point except ValueError: # line is given instead of point p1, p2 = middle(point) n1 = ...
[ "def", "distance", "(", "line", ",", "point", ")", ":", "x0", ",", "y0", ",", "x1", ",", "y1", "=", "line", "try", ":", "p1", ",", "p2", "=", "point", "except", "ValueError", ":", "# line is given instead of point", "p1", ",", "p2", "=", "middle", "(...
infinite line to point or line to line distance is point is given as line - use middle point of that liune
[ "infinite", "line", "to", "point", "or", "line", "to", "line", "distance", "is", "point", "is", "given", "as", "line", "-", "use", "middle", "point", "of", "that", "liune" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L236-L250
radjkarl/fancyTools
fancytools/math/line.py
pointIsBetween
def pointIsBetween(startP, endP, p): """ whether point is (+-1e-6) on a straight line in-between two other points """ return (distancePoint(startP, p) + distancePoint(p, endP) - distancePoint(startP, endP) < 1e-6)
python
def pointIsBetween(startP, endP, p): """ whether point is (+-1e-6) on a straight line in-between two other points """ return (distancePoint(startP, p) + distancePoint(p, endP) - distancePoint(startP, endP) < 1e-6)
[ "def", "pointIsBetween", "(", "startP", ",", "endP", ",", "p", ")", ":", "return", "(", "distancePoint", "(", "startP", ",", "p", ")", "+", "distancePoint", "(", "p", ",", "endP", ")", "-", "distancePoint", "(", "startP", ",", "endP", ")", "<", "1e-6...
whether point is (+-1e-6) on a straight line in-between two other points
[ "whether", "point", "is", "(", "+", "-", "1e", "-", "6", ")", "on", "a", "straight", "line", "in", "-", "between", "two", "other", "points" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L297-L303
radjkarl/fancyTools
fancytools/math/line.py
intersection
def intersection(line1, line2): """ Return the coordinates of a point of intersection given two lines. Return None if the lines are parallel, but non-colli_near. Return an arbitrary point of intersection if the lines are colli_near. Parameters: line1 and line2: lines given by 4 points (x0,y0,x1...
python
def intersection(line1, line2): """ Return the coordinates of a point of intersection given two lines. Return None if the lines are parallel, but non-colli_near. Return an arbitrary point of intersection if the lines are colli_near. Parameters: line1 and line2: lines given by 4 points (x0,y0,x1...
[ "def", "intersection", "(", "line1", ",", "line2", ")", ":", "x1", ",", "y1", ",", "x2", ",", "y2", "=", "line1", "u1", ",", "v1", ",", "u2", ",", "v2", "=", "line2", "(", "a", ",", "b", ")", ",", "(", "c", ",", "d", ")", "=", "(", "x2", ...
Return the coordinates of a point of intersection given two lines. Return None if the lines are parallel, but non-colli_near. Return an arbitrary point of intersection if the lines are colli_near. Parameters: line1 and line2: lines given by 4 points (x0,y0,x1,y1).
[ "Return", "the", "coordinates", "of", "a", "point", "of", "intersection", "given", "two", "lines", ".", "Return", "None", "if", "the", "lines", "are", "parallel", "but", "non", "-", "colli_near", ".", "Return", "an", "arbitrary", "point", "of", "intersection...
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L311-L343
radjkarl/fancyTools
fancytools/math/line.py
translate
def translate(line, ascent, offs=0): """ offs -> shifts parallel to line ascent -> rotate line """ # TODO: why do I have thuis factor here? ascent *= -2 offs *= -2 l0 = length(line) # change relative to line: t0 = offs # -h+offs t1 = l0 * ascent + offs return translate...
python
def translate(line, ascent, offs=0): """ offs -> shifts parallel to line ascent -> rotate line """ # TODO: why do I have thuis factor here? ascent *= -2 offs *= -2 l0 = length(line) # change relative to line: t0 = offs # -h+offs t1 = l0 * ascent + offs return translate...
[ "def", "translate", "(", "line", ",", "ascent", ",", "offs", "=", "0", ")", ":", "# TODO: why do I have thuis factor here?", "ascent", "*=", "-", "2", "offs", "*=", "-", "2", "l0", "=", "length", "(", "line", ")", "# change relative to line:", "t0", "=", "...
offs -> shifts parallel to line ascent -> rotate line
[ "offs", "-", ">", "shifts", "parallel", "to", "line", "ascent", "-", ">", "rotate", "line" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L351-L365
radjkarl/fancyTools
fancytools/math/line.py
split
def split(line, lines): """ split <line> into multiple sublines using intersection with <lines> """ out = empty((len(lines) + 1, 4)) p1 = line[:2] for n, l2 in enumerate(lines): p2 = intersection(line, l2) out[n][:2] = p1 out[n][2:] = p2 p1 = p2 out[n + 1...
python
def split(line, lines): """ split <line> into multiple sublines using intersection with <lines> """ out = empty((len(lines) + 1, 4)) p1 = line[:2] for n, l2 in enumerate(lines): p2 = intersection(line, l2) out[n][:2] = p1 out[n][2:] = p2 p1 = p2 out[n + 1...
[ "def", "split", "(", "line", ",", "lines", ")", ":", "out", "=", "empty", "(", "(", "len", "(", "lines", ")", "+", "1", ",", "4", ")", ")", "p1", "=", "line", "[", ":", "2", "]", "for", "n", ",", "l2", "in", "enumerate", "(", "lines", ")", ...
split <line> into multiple sublines using intersection with <lines>
[ "split", "<line", ">", "into", "multiple", "sublines", "using", "intersection", "with", "<lines", ">" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L384-L399
radjkarl/fancyTools
fancytools/math/line.py
splitN
def splitN(line, n): """ split a line n times returns n sublines """ x0, y0, x1, y1 = line out = empty((n, 4), dtype=type(line[0])) px, py = x0, y0 dx = (x1 - x0) / n dy = (y1 - y0) / n for i in range(n): o = out[i] o[0] = px o[1] = py px += dx ...
python
def splitN(line, n): """ split a line n times returns n sublines """ x0, y0, x1, y1 = line out = empty((n, 4), dtype=type(line[0])) px, py = x0, y0 dx = (x1 - x0) / n dy = (y1 - y0) / n for i in range(n): o = out[i] o[0] = px o[1] = py px += dx ...
[ "def", "splitN", "(", "line", ",", "n", ")", ":", "x0", ",", "y0", ",", "x1", ",", "y1", "=", "line", "out", "=", "empty", "(", "(", "n", ",", "4", ")", ",", "dtype", "=", "type", "(", "line", "[", "0", "]", ")", ")", "px", ",", "py", "...
split a line n times returns n sublines
[ "split", "a", "line", "n", "times", "returns", "n", "sublines" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L402-L422
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/request_parser.py
_same_named
def _same_named(fn, fn_list): """ Args: fn (str): Matching filename. fn_list (list): List of filenames. Return: (list of tuples) filenames from `fn_list`, which has same *name* as `fn` and their indexes in tuple (i, fn). Name is taken from the filename and it is just the name of th...
python
def _same_named(fn, fn_list): """ Args: fn (str): Matching filename. fn_list (list): List of filenames. Return: (list of tuples) filenames from `fn_list`, which has same *name* as `fn` and their indexes in tuple (i, fn). Name is taken from the filename and it is just the name of th...
[ "def", "_same_named", "(", "fn", ",", "fn_list", ")", ":", "fn", "=", "_just_name", "(", "fn", ")", "return", "filter", "(", "lambda", "(", "i", ",", "filename", ")", ":", "fn", "==", "_just_name", "(", "filename", ")", ",", "enumerate", "(", "fn_lis...
Args: fn (str): Matching filename. fn_list (list): List of filenames. Return: (list of tuples) filenames from `fn_list`, which has same *name* as `fn` and their indexes in tuple (i, fn). Name is taken from the filename and it is just the name of the file, without suffix and path. ...
[ "Args", ":", "fn", "(", "str", ")", ":", "Matching", "filename", ".", "fn_list", "(", "list", ")", ":", "List", "of", "filenames", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L67-L86
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/request_parser.py
_remove_files
def _remove_files(files): """ Remove all given files. Args: files (list): List of filenames, which will be removed. """ logger.debug("Request for file removal (_remove_files()).") for fn in files: if os.path.exists(fn): logger.debug("Removing '%s'." % fn) ...
python
def _remove_files(files): """ Remove all given files. Args: files (list): List of filenames, which will be removed. """ logger.debug("Request for file removal (_remove_files()).") for fn in files: if os.path.exists(fn): logger.debug("Removing '%s'." % fn) ...
[ "def", "_remove_files", "(", "files", ")", ":", "logger", ".", "debug", "(", "\"Request for file removal (_remove_files()).\"", ")", "for", "fn", "in", "files", ":", "if", "os", ".", "path", ".", "exists", "(", "fn", ")", ":", "logger", ".", "debug", "(", ...
Remove all given files. Args: files (list): List of filenames, which will be removed.
[ "Remove", "all", "given", "files", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L99-L111
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/request_parser.py
_safe_read_meta_file
def _safe_read_meta_file(fn, error_protocol): """ Try to read MetadataFile. If the exception is raised, log the errors to the `error_protocol` and return None. """ try: return MetadataFile(fn) except Exception, e: error_protocol.append( "Can't read MetadataFile '%s':\...
python
def _safe_read_meta_file(fn, error_protocol): """ Try to read MetadataFile. If the exception is raised, log the errors to the `error_protocol` and return None. """ try: return MetadataFile(fn) except Exception, e: error_protocol.append( "Can't read MetadataFile '%s':\...
[ "def", "_safe_read_meta_file", "(", "fn", ",", "error_protocol", ")", ":", "try", ":", "return", "MetadataFile", "(", "fn", ")", "except", "Exception", ",", "e", ":", "error_protocol", ".", "append", "(", "\"Can't read MetadataFile '%s':\\n\\t%s\\n\"", "%", "(", ...
Try to read MetadataFile. If the exception is raised, log the errors to the `error_protocol` and return None.
[ "Try", "to", "read", "MetadataFile", ".", "If", "the", "exception", "is", "raised", "log", "the", "errors", "to", "the", "error_protocol", "and", "return", "None", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L114-L124
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/request_parser.py
_process_pair
def _process_pair(first_fn, second_fn, error_protocol): """ Look at given filenames, decide which is what and try to pair them. """ ebook = None metadata = None if _is_meta(first_fn) and not _is_meta(second_fn): # 1st meta, 2nd data logger.debug( "Parsed: '%s' as meta, '%...
python
def _process_pair(first_fn, second_fn, error_protocol): """ Look at given filenames, decide which is what and try to pair them. """ ebook = None metadata = None if _is_meta(first_fn) and not _is_meta(second_fn): # 1st meta, 2nd data logger.debug( "Parsed: '%s' as meta, '%...
[ "def", "_process_pair", "(", "first_fn", ",", "second_fn", ",", "error_protocol", ")", ":", "ebook", "=", "None", "metadata", "=", "None", "if", "_is_meta", "(", "first_fn", ")", "and", "not", "_is_meta", "(", "second_fn", ")", ":", "# 1st meta, 2nd data", "...
Look at given filenames, decide which is what and try to pair them.
[ "Look", "at", "given", "filenames", "decide", "which", "is", "what", "and", "try", "to", "pair", "them", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L127-L175
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/request_parser.py
_process_directory
def _process_directory(files, user_conf, error_protocol): """ Look at items in given directory, try to match them for same names and pair them. If the items can't be paired, add their representation. Note: All successfully processed files are removed. Returns: list: of items. ...
python
def _process_directory(files, user_conf, error_protocol): """ Look at items in given directory, try to match them for same names and pair them. If the items can't be paired, add their representation. Note: All successfully processed files are removed. Returns: list: of items. ...
[ "def", "_process_directory", "(", "files", ",", "user_conf", ",", "error_protocol", ")", ":", "items", "=", "[", "]", "banned", "=", "[", "settings", ".", "USER_IMPORT_LOG", ",", "settings", ".", "USER_ERROR_LOG", "]", "files", "=", "filter", "(", "lambda", ...
Look at items in given directory, try to match them for same names and pair them. If the items can't be paired, add their representation. Note: All successfully processed files are removed. Returns: list: of items. Example: [MetadataFile, DataPair, DataPair, EbookFile]
[ "Look", "at", "items", "in", "given", "directory", "try", "to", "match", "them", "for", "same", "names", "and", "pair", "them", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L178-L241
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/request_parser.py
_index
def _index(array, item, key=None): """ Array search function. Written, because ``.index()`` method for array doesn't have `key` parameter and raises `ValueError`, if the item is not found. Args: array (list): List of items, which will be searched. item (whatever): Item, which will ...
python
def _index(array, item, key=None): """ Array search function. Written, because ``.index()`` method for array doesn't have `key` parameter and raises `ValueError`, if the item is not found. Args: array (list): List of items, which will be searched. item (whatever): Item, which will ...
[ "def", "_index", "(", "array", ",", "item", ",", "key", "=", "None", ")", ":", "for", "i", ",", "el", "in", "enumerate", "(", "array", ")", ":", "resolved_el", "=", "key", "(", "el", ")", "if", "key", "else", "el", "if", "resolved_el", "==", "ite...
Array search function. Written, because ``.index()`` method for array doesn't have `key` parameter and raises `ValueError`, if the item is not found. Args: array (list): List of items, which will be searched. item (whatever): Item, which will be matched to elements in `array`. key ...
[ "Array", "search", "function", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L244-L266
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/request_parser.py
_isbn_pairing
def _isbn_pairing(items): """ Pair `items` with same ISBN into `DataPair` objects. Args: items (list): list of items, which will be searched. Returns: list: list with paired items. Paired items are removed, `DataPair` is \ added instead. """ NameWrapper = namedtup...
python
def _isbn_pairing(items): """ Pair `items` with same ISBN into `DataPair` objects. Args: items (list): list of items, which will be searched. Returns: list: list with paired items. Paired items are removed, `DataPair` is \ added instead. """ NameWrapper = namedtup...
[ "def", "_isbn_pairing", "(", "items", ")", ":", "NameWrapper", "=", "namedtuple", "(", "\"NameWrapper\"", ",", "[", "\"name\"", ",", "\"obj\"", "]", ")", "metas", "=", "map", "(", "lambda", "x", ":", "NameWrapper", "(", "_just_name", "(", "x", ".", "file...
Pair `items` with same ISBN into `DataPair` objects. Args: items (list): list of items, which will be searched. Returns: list: list with paired items. Paired items are removed, `DataPair` is \ added instead.
[ "Pair", "items", "with", "same", "ISBN", "into", "DataPair", "objects", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L269-L322
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/request_parser.py
_create_import_log
def _create_import_log(items): """ Used to create log with successfully imported data. """ log = [] for item in items: if isinstance(item, MetadataFile): log.append( "Metadata file '%s' successfully imported." % item.filename ) elif isinstance...
python
def _create_import_log(items): """ Used to create log with successfully imported data. """ log = [] for item in items: if isinstance(item, MetadataFile): log.append( "Metadata file '%s' successfully imported." % item.filename ) elif isinstance...
[ "def", "_create_import_log", "(", "items", ")", ":", "log", "=", "[", "]", "for", "item", "in", "items", ":", "if", "isinstance", "(", "item", ",", "MetadataFile", ")", ":", "log", ".", "append", "(", "\"Metadata file '%s' successfully imported.\"", "%", "it...
Used to create log with successfully imported data.
[ "Used", "to", "create", "log", "with", "successfully", "imported", "data", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L325-L349
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/request_parser.py
_process_items
def _process_items(items, user_conf, error_protocol): """ Parse metadata. Remove processed and sucessfully parsed items. Returns sucessfully processed items. """ def process_meta(item, error_protocol): try: return item._parse() except Exception, e: error_prot...
python
def _process_items(items, user_conf, error_protocol): """ Parse metadata. Remove processed and sucessfully parsed items. Returns sucessfully processed items. """ def process_meta(item, error_protocol): try: return item._parse() except Exception, e: error_prot...
[ "def", "_process_items", "(", "items", ",", "user_conf", ",", "error_protocol", ")", ":", "def", "process_meta", "(", "item", ",", "error_protocol", ")", ":", "try", ":", "return", "item", ".", "_parse", "(", ")", "except", "Exception", ",", "e", ":", "e...
Parse metadata. Remove processed and sucessfully parsed items. Returns sucessfully processed items.
[ "Parse", "metadata", ".", "Remove", "processed", "and", "sucessfully", "parsed", "items", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L352-L386
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/request_parser.py
process_import_request
def process_import_request(username, path, timestamp, logger_handler): """ React to import request. Look into user's directory and react to files user uploaded there. Behavior of this function can be set by setting variables in :mod:`ftp.settings`. Args: username (str): Name of the use...
python
def process_import_request(username, path, timestamp, logger_handler): """ React to import request. Look into user's directory and react to files user uploaded there. Behavior of this function can be set by setting variables in :mod:`ftp.settings`. Args: username (str): Name of the use...
[ "def", "process_import_request", "(", "username", ",", "path", ",", "timestamp", ",", "logger_handler", ")", ":", "items", "=", "[", "]", "error_protocol", "=", "[", "]", "# import logger into local namespace", "global", "logger", "logger", "=", "logger_handler", ...
React to import request. Look into user's directory and react to files user uploaded there. Behavior of this function can be set by setting variables in :mod:`ftp.settings`. Args: username (str): Name of the user who triggered the import request. path (str): Path to the file, which tri...
[ "React", "to", "import", "request", ".", "Look", "into", "user", "s", "directory", "and", "react", "to", "files", "user", "uploaded", "there", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L389-L511
maxfischer2781/chainlet
chainlet/driver.py
ChainDriver.start
def start(self, daemon=True): """ Start driving the chain asynchronously, return immediately :param daemon: ungracefully kill the driver when the program terminates :type daemon: bool """ if self._run_lock.acquire(False): try: # there is a sho...
python
def start(self, daemon=True): """ Start driving the chain asynchronously, return immediately :param daemon: ungracefully kill the driver when the program terminates :type daemon: bool """ if self._run_lock.acquire(False): try: # there is a sho...
[ "def", "start", "(", "self", ",", "daemon", "=", "True", ")", ":", "if", "self", ".", "_run_lock", ".", "acquire", "(", "False", ")", ":", "try", ":", "# there is a short race window in which `start` release the lock,", "# but `run` has not picked it up yet, but the thr...
Start driving the chain asynchronously, return immediately :param daemon: ungracefully kill the driver when the program terminates :type daemon: bool
[ "Start", "driving", "the", "chain", "asynchronously", "return", "immediately" ]
train
https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/driver.py#L27-L43
maxfischer2781/chainlet
chainlet/driver.py
ChainDriver.run
def run(self): """ Start driving the chain, block until done """ with self._run_lock: while self.mounts: for mount in self.mounts: try: next(mount) except StopIteration: se...
python
def run(self): """ Start driving the chain, block until done """ with self._run_lock: while self.mounts: for mount in self.mounts: try: next(mount) except StopIteration: se...
[ "def", "run", "(", "self", ")", ":", "with", "self", ".", "_run_lock", ":", "while", "self", ".", "mounts", ":", "for", "mount", "in", "self", ".", "mounts", ":", "try", ":", "next", "(", "mount", ")", "except", "StopIteration", ":", "self", ".", "...
Start driving the chain, block until done
[ "Start", "driving", "the", "chain", "block", "until", "done" ]
train
https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/driver.py#L51-L61
PyMLGame/pymlgame
pymlgame/surface.py
Surface.fill
def fill(self, color): """ Fill the whole screen with the given color. :param color: Color to use for filling :type color: tuple """ self.matrix = [[color for _ in range(self.height)] for _ in range(self.width)]
python
def fill(self, color): """ Fill the whole screen with the given color. :param color: Color to use for filling :type color: tuple """ self.matrix = [[color for _ in range(self.height)] for _ in range(self.width)]
[ "def", "fill", "(", "self", ",", "color", ")", ":", "self", ".", "matrix", "=", "[", "[", "color", "for", "_", "in", "range", "(", "self", ".", "height", ")", "]", "for", "_", "in", "range", "(", "self", ".", "width", ")", "]" ]
Fill the whole screen with the given color. :param color: Color to use for filling :type color: tuple
[ "Fill", "the", "whole", "screen", "with", "the", "given", "color", "." ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/surface.py#L25-L32
PyMLGame/pymlgame
pymlgame/surface.py
Surface.draw_dot
def draw_dot(self, pos, color): """ Draw one single dot with the given color on the screen. :param pos: Position of the dot :param color: COlor for the dot :type pos: tuple :type color: tuple """ if 0 <= pos[0] < self.width and 0 <= pos[1] < self.height: ...
python
def draw_dot(self, pos, color): """ Draw one single dot with the given color on the screen. :param pos: Position of the dot :param color: COlor for the dot :type pos: tuple :type color: tuple """ if 0 <= pos[0] < self.width and 0 <= pos[1] < self.height: ...
[ "def", "draw_dot", "(", "self", ",", "pos", ",", "color", ")", ":", "if", "0", "<=", "pos", "[", "0", "]", "<", "self", ".", "width", "and", "0", "<=", "pos", "[", "1", "]", "<", "self", ".", "height", ":", "self", ".", "matrix", "[", "pos", ...
Draw one single dot with the given color on the screen. :param pos: Position of the dot :param color: COlor for the dot :type pos: tuple :type color: tuple
[ "Draw", "one", "single", "dot", "with", "the", "given", "color", "on", "the", "screen", "." ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/surface.py#L34-L44
PyMLGame/pymlgame
pymlgame/surface.py
Surface.draw_line
def draw_line(self, start, end, color): """ Draw a line with the given color on the screen. :param start: Start point of the line :param end: End point of the line :param color: Color of the line :type start: tuple :type end: tuple :type color: tuple ...
python
def draw_line(self, start, end, color): """ Draw a line with the given color on the screen. :param start: Start point of the line :param end: End point of the line :param color: Color of the line :type start: tuple :type end: tuple :type color: tuple ...
[ "def", "draw_line", "(", "self", ",", "start", ",", "end", ",", "color", ")", ":", "def", "dist", "(", "p", ",", "a", ",", "b", ")", ":", "return", "(", "abs", "(", "(", "b", "[", "0", "]", "-", "a", "[", "0", "]", ")", "*", "(", "a", "...
Draw a line with the given color on the screen. :param start: Start point of the line :param end: End point of the line :param color: Color of the line :type start: tuple :type end: tuple :type color: tuple
[ "Draw", "a", "line", "with", "the", "given", "color", "on", "the", "screen", "." ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/surface.py#L46-L67
PyMLGame/pymlgame
pymlgame/surface.py
Surface.draw_rect
def draw_rect(self, pos, size, color, fillcolor=None): """ Draw a rectangle with the given color on the screen and optionally fill it with fillcolor. :param pos: Top left corner of the rectangle :param size: Sieze of the rectangle :param color: Color for borders :param f...
python
def draw_rect(self, pos, size, color, fillcolor=None): """ Draw a rectangle with the given color on the screen and optionally fill it with fillcolor. :param pos: Top left corner of the rectangle :param size: Sieze of the rectangle :param color: Color for borders :param f...
[ "def", "draw_rect", "(", "self", ",", "pos", ",", "size", ",", "color", ",", "fillcolor", "=", "None", ")", ":", "# draw top and botton line", "for", "x", "in", "range", "(", "size", "[", "0", "]", ")", ":", "self", ".", "draw_dot", "(", "(", "pos", ...
Draw a rectangle with the given color on the screen and optionally fill it with fillcolor. :param pos: Top left corner of the rectangle :param size: Sieze of the rectangle :param color: Color for borders :param fillcolor: Color for infill :type pos: tuple :type size: tup...
[ "Draw", "a", "rectangle", "with", "the", "given", "color", "on", "the", "screen", "and", "optionally", "fill", "it", "with", "fillcolor", "." ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/surface.py#L69-L94
PyMLGame/pymlgame
pymlgame/surface.py
Surface.draw_circle
def draw_circle(self, pos, radius, color, fillcolor=None): """ Draw a circle with the given color on the screen and optionally fill it with fillcolor. :param pos: Center of the circle :param radius: Radius :param color: Color for border :param fillcolor: Color for infill...
python
def draw_circle(self, pos, radius, color, fillcolor=None): """ Draw a circle with the given color on the screen and optionally fill it with fillcolor. :param pos: Center of the circle :param radius: Radius :param color: Color for border :param fillcolor: Color for infill...
[ "def", "draw_circle", "(", "self", ",", "pos", ",", "radius", ",", "color", ",", "fillcolor", "=", "None", ")", ":", "#TODO: This still produces rubbish but it's on a good way to success", "def", "dist", "(", "d", ",", "p", ",", "r", ")", ":", "return", "abs",...
Draw a circle with the given color on the screen and optionally fill it with fillcolor. :param pos: Center of the circle :param radius: Radius :param color: Color for border :param fillcolor: Color for infill :type pos: tuple :type radius: int :type color: tuple ...
[ "Draw", "a", "circle", "with", "the", "given", "color", "on", "the", "screen", "and", "optionally", "fill", "it", "with", "fillcolor", "." ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/surface.py#L96-L126
PyMLGame/pymlgame
pymlgame/surface.py
Surface.blit
def blit(self, surface, pos=(0, 0)): """ Blits a surface on this surface at pos :param surface: Surface to blit :param pos: Top left point to start blitting :type surface: Surface :type pos: tuple """ for x in range(surface.width): for y in ra...
python
def blit(self, surface, pos=(0, 0)): """ Blits a surface on this surface at pos :param surface: Surface to blit :param pos: Top left point to start blitting :type surface: Surface :type pos: tuple """ for x in range(surface.width): for y in ra...
[ "def", "blit", "(", "self", ",", "surface", ",", "pos", "=", "(", "0", ",", "0", ")", ")", ":", "for", "x", "in", "range", "(", "surface", ".", "width", ")", ":", "for", "y", "in", "range", "(", "surface", ".", "height", ")", ":", "px", "=", ...
Blits a surface on this surface at pos :param surface: Surface to blit :param pos: Top left point to start blitting :type surface: Surface :type pos: tuple
[ "Blits", "a", "surface", "on", "this", "surface", "at", "pos" ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/surface.py#L128-L142
PyMLGame/pymlgame
pymlgame/surface.py
Surface.replace_color
def replace_color(self, before, after): """ Replaces a color on a surface with another one. :param before: Change all pixels with this color :param after: To that color :type before: tuple :type after: tuple """ #TODO: find out if this actually works ...
python
def replace_color(self, before, after): """ Replaces a color on a surface with another one. :param before: Change all pixels with this color :param after: To that color :type before: tuple :type after: tuple """ #TODO: find out if this actually works ...
[ "def", "replace_color", "(", "self", ",", "before", ",", "after", ")", ":", "#TODO: find out if this actually works", "#((self.matrix[x][y] = after for y in range(self.height) if self.matrix[x][y] == before) for x in range(self.width))", "for", "x", "in", "range", "(", "self", "....
Replaces a color on a surface with another one. :param before: Change all pixels with this color :param after: To that color :type before: tuple :type after: tuple
[ "Replaces", "a", "color", "on", "a", "surface", "with", "another", "one", "." ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/surface.py#L144-L158
matthewdeanmartin/jiggle_version
build.py
detect_secrets
def detect_secrets(): """ Call detect-secrets tool """ # use # blah blah = "foo" # pragma: whitelist secret # to ignore a false posites errors_file = "detect-secrets-results.txt" print(execute_get_text("pwd")) command = "{0} detect-secrets --scan --base64-limit 4 --exclude .ide...
python
def detect_secrets(): """ Call detect-secrets tool """ # use # blah blah = "foo" # pragma: whitelist secret # to ignore a false posites errors_file = "detect-secrets-results.txt" print(execute_get_text("pwd")) command = "{0} detect-secrets --scan --base64-limit 4 --exclude .ide...
[ "def", "detect_secrets", "(", ")", ":", "# use", "# blah blah = \"foo\" # pragma: whitelist secret", "# to ignore a false posites", "errors_file", "=", "\"detect-secrets-results.txt\"", "print", "(", "execute_get_text", "(", "\"pwd\"", ")", ")", "command", "=", "\"{0} det...
Call detect-secrets tool
[ "Call", "detect", "-", "secrets", "tool" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/build.py#L138-L182
matthewdeanmartin/jiggle_version
build.py
docs
def docs(): """ Docs """ with safe_cd(SRC): with safe_cd("docs"): my_env = config_pythonpath() command = "{0} make html".format(PIPENV).strip() print(command) execute_with_environment(command, env=my_env)
python
def docs(): """ Docs """ with safe_cd(SRC): with safe_cd("docs"): my_env = config_pythonpath() command = "{0} make html".format(PIPENV).strip() print(command) execute_with_environment(command, env=my_env)
[ "def", "docs", "(", ")", ":", "with", "safe_cd", "(", "SRC", ")", ":", "with", "safe_cd", "(", "\"docs\"", ")", ":", "my_env", "=", "config_pythonpath", "(", ")", "command", "=", "\"{0} make html\"", ".", "format", "(", "PIPENV", ")", ".", "strip", "("...
Docs
[ "Docs" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/build.py#L294-L303
matthewdeanmartin/jiggle_version
build.py
mypy
def mypy(): """ Are types ok? """ if sys.version_info < (3, 4): print("Mypy doesn't work on python < 3.4") return if IS_TRAVIS: command = "{0} -m mypy {1} --ignore-missing-imports --strict".format(PYTHON, PROJECT_NAME).strip() else: command = "{0} mypy {1} --ignor...
python
def mypy(): """ Are types ok? """ if sys.version_info < (3, 4): print("Mypy doesn't work on python < 3.4") return if IS_TRAVIS: command = "{0} -m mypy {1} --ignore-missing-imports --strict".format(PYTHON, PROJECT_NAME).strip() else: command = "{0} mypy {1} --ignor...
[ "def", "mypy", "(", ")", ":", "if", "sys", ".", "version_info", "<", "(", "3", ",", "4", ")", ":", "print", "(", "\"Mypy doesn't work on python < 3.4\"", ")", "return", "if", "IS_TRAVIS", ":", "command", "=", "\"{0} -m mypy {1} --ignore-missing-imports --strict\""...
Are types ok?
[ "Are", "types", "ok?" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/build.py#L336-L374
matthewdeanmartin/jiggle_version
build.py
gemfury
def gemfury(): """ Push to gem fury, a repo with private options """ # fury login # fury push dist/*.gz --as=YOUR_ACCT # fury push dist/*.whl --as=YOUR_ACCT cp = subprocess.run(("fury login --as={0}".format(GEM_FURY).split(" ")), stdout=subprocess.PIPE, stderr=subpro...
python
def gemfury(): """ Push to gem fury, a repo with private options """ # fury login # fury push dist/*.gz --as=YOUR_ACCT # fury push dist/*.whl --as=YOUR_ACCT cp = subprocess.run(("fury login --as={0}".format(GEM_FURY).split(" ")), stdout=subprocess.PIPE, stderr=subpro...
[ "def", "gemfury", "(", ")", ":", "# fury login", "# fury push dist/*.gz --as=YOUR_ACCT", "# fury push dist/*.whl --as=YOUR_ACCT", "cp", "=", "subprocess", ".", "run", "(", "(", "\"fury login --as={0}\"", ".", "format", "(", "GEM_FURY", ")", ".", "split", "(", "\" \"",...
Push to gem fury, a repo with private options
[ "Push", "to", "gem", "fury", "a", "repo", "with", "private", "options" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/build.py#L449-L490
ronaldguillen/wave
wave/utils/field_mapping.py
needs_label
def needs_label(model_field, field_name): """ Returns `True` if the label based on the model's verbose name is not equal to the default label it would have based on it's field name. """ default_label = field_name.replace('_', ' ').capitalize() return capfirst(model_field.verbose_name) != default...
python
def needs_label(model_field, field_name): """ Returns `True` if the label based on the model's verbose name is not equal to the default label it would have based on it's field name. """ default_label = field_name.replace('_', ' ').capitalize() return capfirst(model_field.verbose_name) != default...
[ "def", "needs_label", "(", "model_field", ",", "field_name", ")", ":", "default_label", "=", "field_name", ".", "replace", "(", "'_'", ",", "' '", ")", ".", "capitalize", "(", ")", "return", "capfirst", "(", "model_field", ".", "verbose_name", ")", "!=", "...
Returns `True` if the label based on the model's verbose name is not equal to the default label it would have based on it's field name.
[ "Returns", "True", "if", "the", "label", "based", "on", "the", "model", "s", "verbose", "name", "is", "not", "equal", "to", "the", "default", "label", "it", "would", "have", "based", "on", "it", "s", "field", "name", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/utils/field_mapping.py#L46-L52
ronaldguillen/wave
wave/utils/field_mapping.py
get_field_kwargs
def get_field_kwargs(field_name, model_field): """ Creates a default instance of a basic non-relational field. """ kwargs = {} validator_kwarg = list(model_field.validators) # The following will only be used by ModelField classes. # Gets removed for everything else. kwargs['model_field'...
python
def get_field_kwargs(field_name, model_field): """ Creates a default instance of a basic non-relational field. """ kwargs = {} validator_kwarg = list(model_field.validators) # The following will only be used by ModelField classes. # Gets removed for everything else. kwargs['model_field'...
[ "def", "get_field_kwargs", "(", "field_name", ",", "model_field", ")", ":", "kwargs", "=", "{", "}", "validator_kwarg", "=", "list", "(", "model_field", ".", "validators", ")", "# The following will only be used by ModelField classes.", "# Gets removed for everything else."...
Creates a default instance of a basic non-relational field.
[ "Creates", "a", "default", "instance", "of", "a", "basic", "non", "-", "relational", "field", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/utils/field_mapping.py#L66-L234
ronaldguillen/wave
wave/utils/field_mapping.py
get_relation_kwargs
def get_relation_kwargs(field_name, relation_info): """ Creates a default instance of a flat relational field. """ model_field, related_model, to_many, to_field, has_through_model = relation_info kwargs = { 'queryset': related_model._default_manager, 'view_name': get_detail_view_name...
python
def get_relation_kwargs(field_name, relation_info): """ Creates a default instance of a flat relational field. """ model_field, related_model, to_many, to_field, has_through_model = relation_info kwargs = { 'queryset': related_model._default_manager, 'view_name': get_detail_view_name...
[ "def", "get_relation_kwargs", "(", "field_name", ",", "relation_info", ")", ":", "model_field", ",", "related_model", ",", "to_many", ",", "to_field", ",", "has_through_model", "=", "relation_info", "kwargs", "=", "{", "'queryset'", ":", "related_model", ".", "_de...
Creates a default instance of a flat relational field.
[ "Creates", "a", "default", "instance", "of", "a", "flat", "relational", "field", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/utils/field_mapping.py#L237-L283
Diaoul/pyextdirect
pyextdirect/api.py
create_api
def create_api(bases, url, **kwargs): """Create the JS code for the API using one or more :class:`Bases <pyextdirect.configuration.Base>` :param bases: configuration bases :type bases: :class:`~pyextdirect.configuration.Base` or list of :class:`~pyextdirect.configuration.Base` :param string url: see :f...
python
def create_api(bases, url, **kwargs): """Create the JS code for the API using one or more :class:`Bases <pyextdirect.configuration.Base>` :param bases: configuration bases :type bases: :class:`~pyextdirect.configuration.Base` or list of :class:`~pyextdirect.configuration.Base` :param string url: see :f...
[ "def", "create_api", "(", "bases", ",", "url", ",", "*", "*", "kwargs", ")", ":", "return", "'Ext.app.REMOTING_API = %s;'", "%", "json", ".", "dumps", "(", "create_api_dict", "(", "bases", ",", "url", ",", "*", "*", "kwargs", ")", ")" ]
Create the JS code for the API using one or more :class:`Bases <pyextdirect.configuration.Base>` :param bases: configuration bases :type bases: :class:`~pyextdirect.configuration.Base` or list of :class:`~pyextdirect.configuration.Base` :param string url: see :func:`create_api_dict` :param \*\*kwargs: ...
[ "Create", "the", "JS", "code", "for", "the", "API", "using", "one", "or", "more", ":", "class", ":", "Bases", "<pyextdirect", ".", "configuration", ".", "Base", ">" ]
train
https://github.com/Diaoul/pyextdirect/blob/34ddfe882d467b3769644e8131fb90fe472eff80/pyextdirect/api.py#L24-L33
Diaoul/pyextdirect
pyextdirect/api.py
create_api_dict
def create_api_dict(bases, url, **kwargs): """Create an API dict :param bases: configuration bases :type bases: :class:`~pyextdirect.configuration.Base` or list of :class:`~pyextdirect.configuration.Base` :param string url: URL where the router can be reached :param \*\*kwargs: extra keyword argume...
python
def create_api_dict(bases, url, **kwargs): """Create an API dict :param bases: configuration bases :type bases: :class:`~pyextdirect.configuration.Base` or list of :class:`~pyextdirect.configuration.Base` :param string url: URL where the router can be reached :param \*\*kwargs: extra keyword argume...
[ "def", "create_api_dict", "(", "bases", ",", "url", ",", "*", "*", "kwargs", ")", ":", "api", "=", "kwargs", "or", "{", "}", "api", ".", "update", "(", "{", "'type'", ":", "'remoting'", ",", "'url'", ":", "url", ",", "'actions'", ":", "defaultdict", ...
Create an API dict :param bases: configuration bases :type bases: :class:`~pyextdirect.configuration.Base` or list of :class:`~pyextdirect.configuration.Base` :param string url: URL where the router can be reached :param \*\*kwargs: extra keyword arguments to populate the API dict. Most common keyword ...
[ "Create", "an", "API", "dict" ]
train
https://github.com/Diaoul/pyextdirect/blob/34ddfe882d467b3769644e8131fb90fe472eff80/pyextdirect/api.py#L36-L65
oblalex/isotopic-logging
isotopic_logging/generators.py
generate_uuid_based_oid
def generate_uuid_based_oid(length=None): """ OID generator which uses uuid.uuid4 (random UUIDs) to produce result. """ length = min(length or OID_LENGTH, OID_MAX_LENGTH) while True: yield uuid.uuid4().hex.upper()[:length]
python
def generate_uuid_based_oid(length=None): """ OID generator which uses uuid.uuid4 (random UUIDs) to produce result. """ length = min(length or OID_LENGTH, OID_MAX_LENGTH) while True: yield uuid.uuid4().hex.upper()[:length]
[ "def", "generate_uuid_based_oid", "(", "length", "=", "None", ")", ":", "length", "=", "min", "(", "length", "or", "OID_LENGTH", ",", "OID_MAX_LENGTH", ")", "while", "True", ":", "yield", "uuid", ".", "uuid4", "(", ")", ".", "hex", ".", "upper", "(", "...
OID generator which uses uuid.uuid4 (random UUIDs) to produce result.
[ "OID", "generator", "which", "uses", "uuid", ".", "uuid4", "(", "random", "UUIDs", ")", "to", "produce", "result", "." ]
train
https://github.com/oblalex/isotopic-logging/blob/f60bbb04c4c9ac3046a8c5c9cb8c814b75f496be/isotopic_logging/generators.py#L9-L16
maxfischer2781/chainlet
chainlet/primitives/bundle.py
bundle_sequences
def bundle_sequences(element): """ Convert sequence types to bundles This converter automatically constructs a :py:class:`~.Bundle` from any :py:class:`tuple`, :py:class:`list` or :py:class:`set` encountered during linking. The following two lines produce the same chain: .. code:: python ...
python
def bundle_sequences(element): """ Convert sequence types to bundles This converter automatically constructs a :py:class:`~.Bundle` from any :py:class:`tuple`, :py:class:`list` or :py:class:`set` encountered during linking. The following two lines produce the same chain: .. code:: python ...
[ "def", "bundle_sequences", "(", "element", ")", ":", "if", "isinstance", "(", "element", ",", "(", "tuple", ",", "list", ",", "set", ")", ")", ":", "return", "Bundle", "(", "element", ")", "return", "NotImplemented" ]
Convert sequence types to bundles This converter automatically constructs a :py:class:`~.Bundle` from any :py:class:`tuple`, :py:class:`list` or :py:class:`set` encountered during linking. The following two lines produce the same chain: .. code:: python a >> [b, c, d] >> e a >> Bu...
[ "Convert", "sequence", "types", "to", "bundles" ]
train
https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/primitives/bundle.py#L41-L57
ch3pjw/junction
jcn/formatting.py
StringWithFormatting.chunk
def chunk(self, regex): '''FIXME: ''' chunks = [] for component in self._content: chunks.extend( StringComponent(component.placeholder, s) for s in regex.split(str(component))) for i, (chunk1, chunk2) in enumerate( zip(c...
python
def chunk(self, regex): '''FIXME: ''' chunks = [] for component in self._content: chunks.extend( StringComponent(component.placeholder, s) for s in regex.split(str(component))) for i, (chunk1, chunk2) in enumerate( zip(c...
[ "def", "chunk", "(", "self", ",", "regex", ")", ":", "chunks", "=", "[", "]", "for", "component", "in", "self", ".", "_content", ":", "chunks", ".", "extend", "(", "StringComponent", "(", "component", ".", "placeholder", ",", "s", ")", "for", "s", "i...
FIXME:
[ "FIXME", ":" ]
train
https://github.com/ch3pjw/junction/blob/7d0c4d279589bee8ae7b3ac4dee2ab425c0b1b0e/jcn/formatting.py#L547-L565
ch3pjw/junction
jcn/formatting.py
StringWithFormatting.strip
def strip(self): '''FIXME: ''' if len(self._content) == 0: return self elif len(self._content) == 1: return self.__class__(self._content[0].strip()) else: first_component = self._content[0] last_component = self._content[-1] ...
python
def strip(self): '''FIXME: ''' if len(self._content) == 0: return self elif len(self._content) == 1: return self.__class__(self._content[0].strip()) else: first_component = self._content[0] last_component = self._content[-1] ...
[ "def", "strip", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_content", ")", "==", "0", ":", "return", "self", "elif", "len", "(", "self", ".", "_content", ")", "==", "1", ":", "return", "self", ".", "__class__", "(", "self", ".", "_con...
FIXME:
[ "FIXME", ":" ]
train
https://github.com/ch3pjw/junction/blob/7d0c4d279589bee8ae7b3ac4dee2ab425c0b1b0e/jcn/formatting.py#L567-L581
ch3pjw/junction
jcn/formatting.py
StringWithFormatting.populate
def populate(self, terminal=None, styles=None, default_esc_seq=''): '''Get the concrete (including terminal escape sequences) representation of this string. :parameter Terminal terminal: The terminal object to use for turning formatting attributes such as :attr:`Root.format.blue` in...
python
def populate(self, terminal=None, styles=None, default_esc_seq=''): '''Get the concrete (including terminal escape sequences) representation of this string. :parameter Terminal terminal: The terminal object to use for turning formatting attributes such as :attr:`Root.format.blue` in...
[ "def", "populate", "(", "self", ",", "terminal", "=", "None", ",", "styles", "=", "None", ",", "default_esc_seq", "=", "''", ")", ":", "terminal", "=", "terminal", "or", "get_terminal", "(", ")", "styles", "=", "styles", "or", "{", "}", "return", "''",...
Get the concrete (including terminal escape sequences) representation of this string. :parameter Terminal terminal: The terminal object to use for turning formatting attributes such as :attr:`Root.format.blue` into concrete escape sequences. :parameter styles: An object ...
[ "Get", "the", "concrete", "(", "including", "terminal", "escape", "sequences", ")", "representation", "of", "this", "string", "." ]
train
https://github.com/ch3pjw/junction/blob/7d0c4d279589bee8ae7b3ac4dee2ab425c0b1b0e/jcn/formatting.py#L583-L611
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/ext.py
InvenioUpgrader.init_app
def init_app(self, app): """Flask application initialization.""" app.cli.add_command(upgrader_cmd) app.extensions['invenio-upgrader'] = self
python
def init_app(self, app): """Flask application initialization.""" app.cli.add_command(upgrader_cmd) app.extensions['invenio-upgrader'] = self
[ "def", "init_app", "(", "self", ",", "app", ")", ":", "app", ".", "cli", ".", "add_command", "(", "upgrader_cmd", ")", "app", ".", "extensions", "[", "'invenio-upgrader'", "]", "=", "self" ]
Flask application initialization.
[ "Flask", "application", "initialization", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/ext.py#L40-L43
kallimachos/chios
chios/bolditalic/__init__.py
css
def css(app, env): """ Add bolditalic CSS. :param app: Sphinx application context. :param env: Sphinx environment context. """ srcdir = os.path.abspath(os.path.dirname(__file__)) cssfile = 'bolditalic.css' csspath = os.path.join(srcdir, cssfile) buildpath = os.path.join(app.outdir, ...
python
def css(app, env): """ Add bolditalic CSS. :param app: Sphinx application context. :param env: Sphinx environment context. """ srcdir = os.path.abspath(os.path.dirname(__file__)) cssfile = 'bolditalic.css' csspath = os.path.join(srcdir, cssfile) buildpath = os.path.join(app.outdir, ...
[ "def", "css", "(", "app", ",", "env", ")", ":", "srcdir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "cssfile", "=", "'bolditalic.css'", "csspath", "=", "os", ".", "path", ".", "join",...
Add bolditalic CSS. :param app: Sphinx application context. :param env: Sphinx environment context.
[ "Add", "bolditalic", "CSS", "." ]
train
https://github.com/kallimachos/chios/blob/e14044e4019d57089c625d4ad2f73ccb66b8b7b8/chios/bolditalic/__init__.py#L31-L49
kallimachos/chios
chios/bolditalic/__init__.py
bolditalic
def bolditalic(name, rawtext, text, lineno, inliner, options={}, content=[]): """ Add bolditalic role. Returns 2 part tuple containing list of nodes to insert into the document and a list of system messages. Both are allowed to be empty. :param name: The role name used in the document. :p...
python
def bolditalic(name, rawtext, text, lineno, inliner, options={}, content=[]): """ Add bolditalic role. Returns 2 part tuple containing list of nodes to insert into the document and a list of system messages. Both are allowed to be empty. :param name: The role name used in the document. :p...
[ "def", "bolditalic", "(", "name", ",", "rawtext", ",", "text", ",", "lineno", ",", "inliner", ",", "options", "=", "{", "}", ",", "content", "=", "[", "]", ")", ":", "node", "=", "nodes", ".", "inline", "(", "rawtext", ",", "text", ")", "node", "...
Add bolditalic role. Returns 2 part tuple containing list of nodes to insert into the document and a list of system messages. Both are allowed to be empty. :param name: The role name used in the document. :param rawtext: The entire markup snippet, with role. :param text: The text marked with ...
[ "Add", "bolditalic", "role", "." ]
train
https://github.com/kallimachos/chios/blob/e14044e4019d57089c625d4ad2f73ccb66b8b7b8/chios/bolditalic/__init__.py#L52-L70
kallimachos/chios
chios/bolditalic/__init__.py
setup
def setup(app): """ Setup for Sphinx extension. :param app: Sphinx application context. """ try: app.info('adding bolditalic role...', nonl=True) app.add_role('bolditalic', bolditalic) app.connect('env-updated', css) app.info(' done') except Exception: ap...
python
def setup(app): """ Setup for Sphinx extension. :param app: Sphinx application context. """ try: app.info('adding bolditalic role...', nonl=True) app.add_role('bolditalic', bolditalic) app.connect('env-updated', css) app.info(' done') except Exception: ap...
[ "def", "setup", "(", "app", ")", ":", "try", ":", "app", ".", "info", "(", "'adding bolditalic role...'", ",", "nonl", "=", "True", ")", "app", ".", "add_role", "(", "'bolditalic'", ",", "bolditalic", ")", "app", ".", "connect", "(", "'env-updated'", ","...
Setup for Sphinx extension. :param app: Sphinx application context.
[ "Setup", "for", "Sphinx", "extension", "." ]
train
https://github.com/kallimachos/chios/blob/e14044e4019d57089c625d4ad2f73ccb66b8b7b8/chios/bolditalic/__init__.py#L73-L90
sassoo/goldman
goldman/types/zipcode.py
Type.validate_zip_code
def validate_zip_code(self, value): """ Schematics validator """ if not Type.ZIPCODE_REGEX.match(value): raise ValidationError(self.messages['zip_code']) return value
python
def validate_zip_code(self, value): """ Schematics validator """ if not Type.ZIPCODE_REGEX.match(value): raise ValidationError(self.messages['zip_code']) return value
[ "def", "validate_zip_code", "(", "self", ",", "value", ")", ":", "if", "not", "Type", ".", "ZIPCODE_REGEX", ".", "match", "(", "value", ")", ":", "raise", "ValidationError", "(", "self", ".", "messages", "[", "'zip_code'", "]", ")", "return", "value" ]
Schematics validator
[ "Schematics", "validator" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/types/zipcode.py#L23-L28
rosenbrockc/acorn
acorn/logging/decoration.py
iswhat
def iswhat(o): """Returns a dictionary of all possible identity checks available to :mod:`inspect` applied to `o`. Returns: dict: keys are `inspect.is*` function names; values are `bool` results returned by each of the methods. """ import inspect isfs = {n: f for n, f in inspe...
python
def iswhat(o): """Returns a dictionary of all possible identity checks available to :mod:`inspect` applied to `o`. Returns: dict: keys are `inspect.is*` function names; values are `bool` results returned by each of the methods. """ import inspect isfs = {n: f for n, f in inspe...
[ "def", "iswhat", "(", "o", ")", ":", "import", "inspect", "isfs", "=", "{", "n", ":", "f", "for", "n", ",", "f", "in", "inspect", ".", "getmembers", "(", "inspect", ")", "if", "n", "[", "0", ":", "2", "]", "==", "\"is\"", "}", "return", "{", ...
Returns a dictionary of all possible identity checks available to :mod:`inspect` applied to `o`. Returns: dict: keys are `inspect.is*` function names; values are `bool` results returned by each of the methods.
[ "Returns", "a", "dictionary", "of", "all", "possible", "identity", "checks", "available", "to", ":", "mod", ":", "inspect", "applied", "to", "o", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L60-L70
rosenbrockc/acorn
acorn/logging/decoration.py
_safe_getmodule
def _safe_getmodule(o): """Attempts to return the module in which `o` is defined. """ from inspect import getmodule try: return getmodule(o) except: # pragma: no cover #There is nothing we can do about this for now. msg.err("_safe_getmodule: {}".format(o), 2) pass
python
def _safe_getmodule(o): """Attempts to return the module in which `o` is defined. """ from inspect import getmodule try: return getmodule(o) except: # pragma: no cover #There is nothing we can do about this for now. msg.err("_safe_getmodule: {}".format(o), 2) pass
[ "def", "_safe_getmodule", "(", "o", ")", ":", "from", "inspect", "import", "getmodule", "try", ":", "return", "getmodule", "(", "o", ")", "except", ":", "# pragma: no cover", "#There is nothing we can do about this for now.", "msg", ".", "err", "(", "\"_safe_getmodu...
Attempts to return the module in which `o` is defined.
[ "Attempts", "to", "return", "the", "module", "in", "which", "o", "is", "defined", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L72-L81
rosenbrockc/acorn
acorn/logging/decoration.py
_safe_getattr
def _safe_getattr(o): """Gets the attribute from the specified object, taking the acorn decoration into account. """ def getattribute(attr): # pragma: no cover if hasattr(o, "__acornext__") and o.__acornext__ is not None: return o.__acornext__.__getattribute__(attr) elif hasa...
python
def _safe_getattr(o): """Gets the attribute from the specified object, taking the acorn decoration into account. """ def getattribute(attr): # pragma: no cover if hasattr(o, "__acornext__") and o.__acornext__ is not None: return o.__acornext__.__getattribute__(attr) elif hasa...
[ "def", "_safe_getattr", "(", "o", ")", ":", "def", "getattribute", "(", "attr", ")", ":", "# pragma: no cover", "if", "hasattr", "(", "o", ",", "\"__acornext__\"", ")", "and", "o", ".", "__acornext__", "is", "not", "None", ":", "return", "o", ".", "__aco...
Gets the attribute from the specified object, taking the acorn decoration into account.
[ "Gets", "the", "attribute", "from", "the", "specified", "object", "taking", "the", "acorn", "decoration", "into", "account", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L83-L96
rosenbrockc/acorn
acorn/logging/decoration.py
_safe_hasattr
def _safe_hasattr(o, attr): """Returns True if `o` has the specified attribute. Takes edge cases into account where packages didn't intend to be used like acorn uses them. """ try: has = hasattr(o, attr) except: # pragma: no cover has = False msg.err("_safe_hasattr: {}.{}".fo...
python
def _safe_hasattr(o, attr): """Returns True if `o` has the specified attribute. Takes edge cases into account where packages didn't intend to be used like acorn uses them. """ try: has = hasattr(o, attr) except: # pragma: no cover has = False msg.err("_safe_hasattr: {}.{}".fo...
[ "def", "_safe_hasattr", "(", "o", ",", "attr", ")", ":", "try", ":", "has", "=", "hasattr", "(", "o", ",", "attr", ")", "except", ":", "# pragma: no cover", "has", "=", "False", "msg", ".", "err", "(", "\"_safe_hasattr: {}.{}\"", ".", "format", "(", "o...
Returns True if `o` has the specified attribute. Takes edge cases into account where packages didn't intend to be used like acorn uses them.
[ "Returns", "True", "if", "o", "has", "the", "specified", "attribute", ".", "Takes", "edge", "cases", "into", "account", "where", "packages", "didn", "t", "intend", "to", "be", "used", "like", "acorn", "uses", "them", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L98-L108
rosenbrockc/acorn
acorn/logging/decoration.py
_update_attrs
def _update_attrs(nobj, oobj, exceptions=None, acornext=False): """Updates the attributes on `nobj` to match those of old, excluding the any attributes in the exceptions list. """ success = True if (acornext and hasattr(oobj, "__acornext__") and oobj.__acornext__ is not None): # pragma: no c...
python
def _update_attrs(nobj, oobj, exceptions=None, acornext=False): """Updates the attributes on `nobj` to match those of old, excluding the any attributes in the exceptions list. """ success = True if (acornext and hasattr(oobj, "__acornext__") and oobj.__acornext__ is not None): # pragma: no c...
[ "def", "_update_attrs", "(", "nobj", ",", "oobj", ",", "exceptions", "=", "None", ",", "acornext", "=", "False", ")", ":", "success", "=", "True", "if", "(", "acornext", "and", "hasattr", "(", "oobj", ",", "\"__acornext__\"", ")", "and", "oobj", ".", "...
Updates the attributes on `nobj` to match those of old, excluding the any attributes in the exceptions list.
[ "Updates", "the", "attributes", "on", "nobj", "to", "match", "those", "of", "old", "excluding", "the", "any", "attributes", "in", "the", "exceptions", "list", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L110-L150
rosenbrockc/acorn
acorn/logging/decoration.py
_get_name_filter
def _get_name_filter(package, context="decorate", reparse=False): """Makes sure that the name filters for the specified package have been loaded. Args: package (str): name of the package that this method belongs to. context (str): one of ['decorate', 'time', 'analyze']; specifies which ...
python
def _get_name_filter(package, context="decorate", reparse=False): """Makes sure that the name filters for the specified package have been loaded. Args: package (str): name of the package that this method belongs to. context (str): one of ['decorate', 'time', 'analyze']; specifies which ...
[ "def", "_get_name_filter", "(", "package", ",", "context", "=", "\"decorate\"", ",", "reparse", "=", "False", ")", ":", "global", "name_filters", "pkey", "=", "(", "package", ",", "context", ")", "if", "pkey", "in", "name_filters", "and", "not", "reparse", ...
Makes sure that the name filters for the specified package have been loaded. Args: package (str): name of the package that this method belongs to. context (str): one of ['decorate', 'time', 'analyze']; specifies which section of the configuration settings to check.
[ "Makes", "sure", "that", "the", "name", "filters", "for", "the", "specified", "package", "have", "been", "loaded", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L167-L222
rosenbrockc/acorn
acorn/logging/decoration.py
filter_name
def filter_name(funcname, package, context="decorate", explicit=False): """Returns True if the specified function should be filtered (i.e., included or excluded for use in the specified context.) Args: funcname (str): name of the method/function being called. package (str): name of the pac...
python
def filter_name(funcname, package, context="decorate", explicit=False): """Returns True if the specified function should be filtered (i.e., included or excluded for use in the specified context.) Args: funcname (str): name of the method/function being called. package (str): name of the pac...
[ "def", "filter_name", "(", "funcname", ",", "package", ",", "context", "=", "\"decorate\"", ",", "explicit", "=", "False", ")", ":", "packfilter", "=", "_get_name_filter", "(", "package", ",", "context", ")", "if", "packfilter", "is", "None", ":", "# By defa...
Returns True if the specified function should be filtered (i.e., included or excluded for use in the specified context.) Args: funcname (str): name of the method/function being called. package (str): name of the package that the method belongs to. context (str): one of ['decorate', 'ti...
[ "Returns", "True", "if", "the", "specified", "function", "should", "be", "filtered", "(", "i", ".", "e", ".", "included", "or", "excluded", "for", "use", "in", "the", "specified", "context", ".", ")" ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L224-L279
rosenbrockc/acorn
acorn/logging/decoration.py
_tracker_str
def _tracker_str(item): """Returns a string representation of the tracker object for the given item. Args: item: object to get tracker for. fqdn (str): fully-qualified domain name of the object. """ instance = tracker(item) if instance is not None: if isinstance(instance...
python
def _tracker_str(item): """Returns a string representation of the tracker object for the given item. Args: item: object to get tracker for. fqdn (str): fully-qualified domain name of the object. """ instance = tracker(item) if instance is not None: if isinstance(instance...
[ "def", "_tracker_str", "(", "item", ")", ":", "instance", "=", "tracker", "(", "item", ")", "if", "instance", "is", "not", "None", ":", "if", "isinstance", "(", "instance", ",", "str", ")", ":", "return", "instance", "elif", "isinstance", "(", "instance"...
Returns a string representation of the tracker object for the given item. Args: item: object to get tracker for. fqdn (str): fully-qualified domain name of the object.
[ "Returns", "a", "string", "representation", "of", "the", "tracker", "object", "for", "the", "given", "item", ".", "Args", ":", "item", ":", "object", "to", "get", "tracker", "for", ".", "fqdn", "(", "str", ")", ":", "fully", "-", "qualified", "domain", ...
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L281-L299
rosenbrockc/acorn
acorn/logging/decoration.py
_check_args
def _check_args(*argl, **argd): """Checks the specified argument lists for objects that are trackable. """ args = {"_": []} for item in argl: args["_"].append(_tracker_str(item)) for key, item in argd.items(): args[key] = _tracker_str(item) return args
python
def _check_args(*argl, **argd): """Checks the specified argument lists for objects that are trackable. """ args = {"_": []} for item in argl: args["_"].append(_tracker_str(item)) for key, item in argd.items(): args[key] = _tracker_str(item) return args
[ "def", "_check_args", "(", "*", "argl", ",", "*", "*", "argd", ")", ":", "args", "=", "{", "\"_\"", ":", "[", "]", "}", "for", "item", "in", "argl", ":", "args", "[", "\"_\"", "]", ".", "append", "(", "_tracker_str", "(", "item", ")", ")", "for...
Checks the specified argument lists for objects that are trackable.
[ "Checks", "the", "specified", "argument", "lists", "for", "objects", "that", "are", "trackable", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L301-L311
rosenbrockc/acorn
acorn/logging/decoration.py
_reduced_stack
def _reduced_stack(istart=3, iend=5, ipython=True): """Returns the reduced function call stack that includes only relevant function calls (i.e., ignores any that are not part of the specified package or acorn. Args: package (str): name of the package that the logged method belongs to. """ ...
python
def _reduced_stack(istart=3, iend=5, ipython=True): """Returns the reduced function call stack that includes only relevant function calls (i.e., ignores any that are not part of the specified package or acorn. Args: package (str): name of the package that the logged method belongs to. """ ...
[ "def", "_reduced_stack", "(", "istart", "=", "3", ",", "iend", "=", "5", ",", "ipython", "=", "True", ")", ":", "import", "inspect", "return", "[", "i", "[", "istart", ":", "iend", "]", "for", "i", "in", "inspect", ".", "stack", "(", ")", "if", "...
Returns the reduced function call stack that includes only relevant function calls (i.e., ignores any that are not part of the specified package or acorn. Args: package (str): name of the package that the logged method belongs to.
[ "Returns", "the", "reduced", "function", "call", "stack", "that", "includes", "only", "relevant", "function", "calls", "(", "i", ".", "e", ".", "ignores", "any", "that", "are", "not", "part", "of", "the", "specified", "package", "or", "acorn", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L328-L337
rosenbrockc/acorn
acorn/logging/decoration.py
_pre_create
def _pre_create(cls, atdepth, stackdepth, *argl, **argd): """Checks whether the the logging should happen based on the specified parameters. If it should, an initialized entry is returned. """ from time import time if not atdepth: rstack = _reduced_stack() reduced = len(rstack) ...
python
def _pre_create(cls, atdepth, stackdepth, *argl, **argd): """Checks whether the the logging should happen based on the specified parameters. If it should, an initialized entry is returned. """ from time import time if not atdepth: rstack = _reduced_stack() reduced = len(rstack) ...
[ "def", "_pre_create", "(", "cls", ",", "atdepth", ",", "stackdepth", ",", "*", "argl", ",", "*", "*", "argd", ")", ":", "from", "time", "import", "time", "if", "not", "atdepth", ":", "rstack", "=", "_reduced_stack", "(", ")", "reduced", "=", "len", "...
Checks whether the the logging should happen based on the specified parameters. If it should, an initialized entry is returned.
[ "Checks", "whether", "the", "the", "logging", "should", "happen", "based", "on", "the", "specified", "parameters", ".", "If", "it", "should", "an", "initialized", "entry", "is", "returned", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L350-L378
rosenbrockc/acorn
acorn/logging/decoration.py
_post_create
def _post_create(atdepth, entry, result): """Finishes the entry logging if applicable. """ if not atdepth and entry is not None: if result is not None: #We need to get these results a UUID that will be saved so that any #instance methods applied to this object has a parent to...
python
def _post_create(atdepth, entry, result): """Finishes the entry logging if applicable. """ if not atdepth and entry is not None: if result is not None: #We need to get these results a UUID that will be saved so that any #instance methods applied to this object has a parent to...
[ "def", "_post_create", "(", "atdepth", ",", "entry", ",", "result", ")", ":", "if", "not", "atdepth", "and", "entry", "is", "not", "None", ":", "if", "result", "is", "not", "None", ":", "#We need to get these results a UUID that will be saved so that any", "#insta...
Finishes the entry logging if applicable.
[ "Finishes", "the", "entry", "logging", "if", "applicable", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L380-L394
rosenbrockc/acorn
acorn/logging/decoration.py
creationlog
def creationlog(base, package, stackdepth=_def_stackdepth): """Decorator for wrapping the creation of class instances that are being logged by acorn. Args: base: base class used to call __new__ for the construction. package (str): name of (global) package the class belongs to. stack...
python
def creationlog(base, package, stackdepth=_def_stackdepth): """Decorator for wrapping the creation of class instances that are being logged by acorn. Args: base: base class used to call __new__ for the construction. package (str): name of (global) package the class belongs to. stack...
[ "def", "creationlog", "(", "base", ",", "package", ",", "stackdepth", "=", "_def_stackdepth", ")", ":", "@", "staticmethod", "def", "wrapnew", "(", "cls", ",", "*", "argl", ",", "*", "*", "argd", ")", ":", "global", "_atdepth_new", ",", "_cstack_new", ",...
Decorator for wrapping the creation of class instances that are being logged by acorn. Args: base: base class used to call __new__ for the construction. package (str): name of (global) package the class belongs to. stackdepth (int): if the calling stack is less than this depth, than ...
[ "Decorator", "for", "wrapping", "the", "creation", "of", "class", "instances", "that", "are", "being", "logged", "by", "acorn", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L396-L474
rosenbrockc/acorn
acorn/logging/decoration.py
_pre_call
def _pre_call(atdepth, parent, fqdn, stackdepth, *argl, **argd): """Checks whether the logging should create an entry based on stackdepth. If so, the entry is created. """ from time import time if not atdepth: rstack = _reduced_stack() if "<module>" in rstack[-1]: # pragma: no cover ...
python
def _pre_call(atdepth, parent, fqdn, stackdepth, *argl, **argd): """Checks whether the logging should create an entry based on stackdepth. If so, the entry is created. """ from time import time if not atdepth: rstack = _reduced_stack() if "<module>" in rstack[-1]: # pragma: no cover ...
[ "def", "_pre_call", "(", "atdepth", ",", "parent", ",", "fqdn", ",", "stackdepth", ",", "*", "argl", ",", "*", "*", "argd", ")", ":", "from", "time", "import", "time", "if", "not", "atdepth", ":", "rstack", "=", "_reduced_stack", "(", ")", "if", "\"<...
Checks whether the logging should create an entry based on stackdepth. If so, the entry is created.
[ "Checks", "whether", "the", "logging", "should", "create", "an", "entry", "based", "on", "stackdepth", ".", "If", "so", "the", "entry", "is", "created", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L487-L556
rosenbrockc/acorn
acorn/logging/decoration.py
_post_call
def _post_call(atdepth, package, fqdn, result, entry, bound, ekey, argl, argd): """Finishes constructing the log and records it to the database. """ from time import time if not atdepth and entry is not None: ek = ekey if result is not None: retid = _tracker_str(result) ...
python
def _post_call(atdepth, package, fqdn, result, entry, bound, ekey, argl, argd): """Finishes constructing the log and records it to the database. """ from time import time if not atdepth and entry is not None: ek = ekey if result is not None: retid = _tracker_str(result) ...
[ "def", "_post_call", "(", "atdepth", ",", "package", ",", "fqdn", ",", "result", ",", "entry", ",", "bound", ",", "ekey", ",", "argl", ",", "argd", ")", ":", "from", "time", "import", "time", "if", "not", "atdepth", "and", "entry", "is", "not", "None...
Finishes constructing the log and records it to the database.
[ "Finishes", "constructing", "the", "log", "and", "records", "it", "to", "the", "database", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L558-L584
rosenbrockc/acorn
acorn/logging/decoration.py
post
def post(fqdn, package, result, entry, bound, ekey, *argl, **argd): """Adds logging for the post-call result of calling the method externally. Args: fqdn (str): fully-qualified domain name of the function being logged. package (str): name of the package we are logging for. Usually the first ...
python
def post(fqdn, package, result, entry, bound, ekey, *argl, **argd): """Adds logging for the post-call result of calling the method externally. Args: fqdn (str): fully-qualified domain name of the function being logged. package (str): name of the package we are logging for. Usually the first ...
[ "def", "post", "(", "fqdn", ",", "package", ",", "result", ",", "entry", ",", "bound", ",", "ekey", ",", "*", "argl", ",", "*", "*", "argd", ")", ":", "global", "_atdepth_call", ",", "_cstack_call", "_cstack_call", ".", "pop", "(", ")", "if", "len", ...
Adds logging for the post-call result of calling the method externally. Args: fqdn (str): fully-qualified domain name of the function being logged. package (str): name of the package we are logging for. Usually the first element of `fqdn.split('.')`. result: returned from calling ...
[ "Adds", "logging", "for", "the", "post", "-", "call", "result", "of", "calling", "the", "method", "externally", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L586-L604
rosenbrockc/acorn
acorn/logging/decoration.py
pre
def pre(fqdn, parent, stackdepth, *argl, **argd): """Adds logging for a call to the specified function that is being handled by an external module. Args: fqdn (str): fully-qualified domain name of the function being logged. parent: *object* that the function belongs to. stackdepth (...
python
def pre(fqdn, parent, stackdepth, *argl, **argd): """Adds logging for a call to the specified function that is being handled by an external module. Args: fqdn (str): fully-qualified domain name of the function being logged. parent: *object* that the function belongs to. stackdepth (...
[ "def", "pre", "(", "fqdn", ",", "parent", ",", "stackdepth", ",", "*", "argl", ",", "*", "*", "argd", ")", ":", "global", "_atdepth_call", ",", "_cstack_call", "#We add +1 to stackdepth because this method had to be called in", "#addition to the wrapper method, so we woul...
Adds logging for a call to the specified function that is being handled by an external module. Args: fqdn (str): fully-qualified domain name of the function being logged. parent: *object* that the function belongs to. stackdepth (int): maximum stack depth before entries are ignored. ...
[ "Adds", "logging", "for", "a", "call", "to", "the", "specified", "function", "that", "is", "being", "handled", "by", "an", "external", "module", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L606-L624
rosenbrockc/acorn
acorn/logging/decoration.py
_create_extension
def _create_extension(o, otype, fqdn, pmodule): """Creates an extension object to represent `o` that can have attributes set, but which behaves identically to the given object. Args: o: object to create an extension for; no checks are performed to see if extension is actually required. ...
python
def _create_extension(o, otype, fqdn, pmodule): """Creates an extension object to represent `o` that can have attributes set, but which behaves identically to the given object. Args: o: object to create an extension for; no checks are performed to see if extension is actually required. ...
[ "def", "_create_extension", "(", "o", ",", "otype", ",", "fqdn", ",", "pmodule", ")", ":", "import", "types", "xdict", "=", "{", "\"__acornext__\"", ":", "o", ",", "\"__doc__\"", ":", "o", ".", "__doc__", "}", "if", "otype", "==", "\"classes\"", ":", "...
Creates an extension object to represent `o` that can have attributes set, but which behaves identically to the given object. Args: o: object to create an extension for; no checks are performed to see if extension is actually required. otype (str): object types; one of ["classes", "fu...
[ "Creates", "an", "extension", "object", "to", "represent", "o", "that", "can", "have", "attributes", "set", "but", "which", "behaves", "identically", "to", "the", "given", "object", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L739-L811
rosenbrockc/acorn
acorn/logging/decoration.py
_safe_setattr
def _safe_setattr(obj, name, value): """Safely sets the attribute of the specified object. This includes not setting attributes for final objects and setting __func__ for instancemethod typed objects. Args: obj: object to set an attribute for. name (str): new attribute name. val...
python
def _safe_setattr(obj, name, value): """Safely sets the attribute of the specified object. This includes not setting attributes for final objects and setting __func__ for instancemethod typed objects. Args: obj: object to set an attribute for. name (str): new attribute name. val...
[ "def", "_safe_setattr", "(", "obj", ",", "name", ",", "value", ")", ":", "okey", "=", "id", "(", "obj", ")", "if", "okey", "in", "_set_failures", "or", "okey", "in", "_final_objs", ":", "return", "False", "import", "inspect", "try", ":", "if", "inspect...
Safely sets the attribute of the specified object. This includes not setting attributes for final objects and setting __func__ for instancemethod typed objects. Args: obj: object to set an attribute for. name (str): new attribute name. value: new attribute value. Returns: ...
[ "Safely", "sets", "the", "attribute", "of", "the", "specified", "object", ".", "This", "includes", "not", "setting", "attributes", "for", "final", "objects", "and", "setting", "__func__", "for", "instancemethod", "typed", "objects", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L818-L849
rosenbrockc/acorn
acorn/logging/decoration.py
_extend_object
def _extend_object(parent, n, o, otype, fqdn): """Extends the specified object if it needs to be extended. The method attempts to add an attribute to the object; if it fails, a new object is created that inherits all of `o` attributes, but is now a regular object that can have attributes set. Args:...
python
def _extend_object(parent, n, o, otype, fqdn): """Extends the specified object if it needs to be extended. The method attempts to add an attribute to the object; if it fails, a new object is created that inherits all of `o` attributes, but is now a regular object that can have attributes set. Args:...
[ "def", "_extend_object", "(", "parent", ",", "n", ",", "o", ",", "otype", ",", "fqdn", ")", ":", "from", "inspect", "import", "ismodule", ",", "isclass", "pmodule", "=", "parent", "if", "ismodule", "(", "parent", ")", "or", "isclass", "(", "parent", ")...
Extends the specified object if it needs to be extended. The method attempts to add an attribute to the object; if it fails, a new object is created that inherits all of `o` attributes, but is now a regular object that can have attributes set. Args: parent: has `n` in its `__dict__` attribute. ...
[ "Extends", "the", "specified", "object", "if", "it", "needs", "to", "be", "extended", ".", "The", "method", "attempts", "to", "add", "an", "attribute", "to", "the", "object", ";", "if", "it", "fails", "a", "new", "object", "is", "created", "that", "inher...
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L851-L895
rosenbrockc/acorn
acorn/logging/decoration.py
_get_members
def _get_members(o): """Returns the likely members of the object by appealing to :func:`dir` instead of using `__dict__` attribute, since that misses certain members. """ result = [] for n in dir(o): if hasattr(o, n) and n not in ["__globals__", "func_globals"]: result.append((n,...
python
def _get_members(o): """Returns the likely members of the object by appealing to :func:`dir` instead of using `__dict__` attribute, since that misses certain members. """ result = [] for n in dir(o): if hasattr(o, n) and n not in ["__globals__", "func_globals"]: result.append((n,...
[ "def", "_get_members", "(", "o", ")", ":", "result", "=", "[", "]", "for", "n", "in", "dir", "(", "o", ")", ":", "if", "hasattr", "(", "o", ",", "n", ")", "and", "n", "not", "in", "[", "\"__globals__\"", ",", "\"func_globals\"", "]", ":", "result...
Returns the likely members of the object by appealing to :func:`dir` instead of using `__dict__` attribute, since that misses certain members.
[ "Returns", "the", "likely", "members", "of", "the", "object", "by", "appealing", "to", ":", "func", ":", "dir", "instead", "of", "using", "__dict__", "attribute", "since", "that", "misses", "certain", "members", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L897-L905
rosenbrockc/acorn
acorn/logging/decoration.py
_split_object
def _split_object(pobj, package, resplit=False, packincl=None, skipext=False): """Splits the specified object into its modules, classes, methods and functions so that it can be decorated more easily. For extension modules/classes that can't have attributes set, the object's dictionary is modified to poi...
python
def _split_object(pobj, package, resplit=False, packincl=None, skipext=False): """Splits the specified object into its modules, classes, methods and functions so that it can be decorated more easily. For extension modules/classes that can't have attributes set, the object's dictionary is modified to poi...
[ "def", "_split_object", "(", "pobj", ",", "package", ",", "resplit", "=", "False", ",", "packincl", "=", "None", ",", "skipext", "=", "False", ")", ":", "import", "inspect", "result", "=", "{", "\"classes\"", ":", "[", "]", ",", "\"functions\"", ":", "...
Splits the specified object into its modules, classes, methods and functions so that it can be decorated more easily. For extension modules/classes that can't have attributes set, the object's dictionary is modified to point to a derived-type version. Args: pobj: object instance returned from t...
[ "Splits", "the", "specified", "object", "into", "its", "modules", "classes", "methods", "and", "functions", "so", "that", "it", "can", "be", "decorated", "more", "easily", ".", "For", "extension", "modules", "/", "classes", "that", "can", "t", "have", "attri...
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L911-L1061