partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
PipeFunction.reduce
Wrap a reduce function to Pipe object. Reduce function is a function with at least two arguments. It works like built-in reduce function. It takes first argument for accumulated result, second argument for the new data to process. A keyword-based argument named 'init' is optional. If ini...
cmdlet/cmdlet.py
def reduce(func): """Wrap a reduce function to Pipe object. Reduce function is a function with at least two arguments. It works like built-in reduce function. It takes first argument for accumulated result, second argument for the new data to process. A keyword-based argument named 'init...
def reduce(func): """Wrap a reduce function to Pipe object. Reduce function is a function with at least two arguments. It works like built-in reduce function. It takes first argument for accumulated result, second argument for the new data to process. A keyword-based argument named 'init...
[ "Wrap", "a", "reduce", "function", "to", "Pipe", "object", ".", "Reduce", "function", "is", "a", "function", "with", "at", "least", "two", "arguments", ".", "It", "works", "like", "built", "-", "in", "reduce", "function", ".", "It", "takes", "first", "ar...
GaryLee/cmdlet
python
https://github.com/GaryLee/cmdlet/blob/5852a63fc2c7dd723a3d7abe18455f8dacb49433/cmdlet/cmdlet.py#L270-L295
[ "def", "reduce", "(", "func", ")", ":", "def", "wrapper", "(", "prev", ",", "*", "argv", ",", "*", "*", "kw", ")", ":", "accum_value", "=", "None", "if", "'init'", "not", "in", "kw", "else", "kw", ".", "pop", "(", "'init'", ")", "if", "prev", "...
5852a63fc2c7dd723a3d7abe18455f8dacb49433
valid
PipeFunction.stopper
Wrap a conditoinal function(stopper function) to Pipe object. wrapped function should return boolean value. The cascading pipe will stop the execution if wrapped function return True. Stopper is useful if you have unlimited number of input data. :param func: The conditoinal function t...
cmdlet/cmdlet.py
def stopper(func): """Wrap a conditoinal function(stopper function) to Pipe object. wrapped function should return boolean value. The cascading pipe will stop the execution if wrapped function return True. Stopper is useful if you have unlimited number of input data. :param fu...
def stopper(func): """Wrap a conditoinal function(stopper function) to Pipe object. wrapped function should return boolean value. The cascading pipe will stop the execution if wrapped function return True. Stopper is useful if you have unlimited number of input data. :param fu...
[ "Wrap", "a", "conditoinal", "function", "(", "stopper", "function", ")", "to", "Pipe", "object", "." ]
GaryLee/cmdlet
python
https://github.com/GaryLee/cmdlet/blob/5852a63fc2c7dd723a3d7abe18455f8dacb49433/cmdlet/cmdlet.py#L299-L320
[ "def", "stopper", "(", "func", ")", ":", "def", "wrapper", "(", "prev", ",", "*", "argv", ",", "*", "*", "kw", ")", ":", "if", "prev", "is", "None", ":", "raise", "TypeError", "(", "'A stopper must have input.'", ")", "for", "i", "in", "prev", ":", ...
5852a63fc2c7dd723a3d7abe18455f8dacb49433
valid
_list_networks
Return a dictionary of network name to active status bools. Sample virsh net-list output:: Name State Autostart ----------------------------------------- default active yes juju-test inactive no foobar inactive no Pars...
revolver/tool/lxc.py
def _list_networks(): """Return a dictionary of network name to active status bools. Sample virsh net-list output:: Name State Autostart ----------------------------------------- default active yes juju-test inactive no foobar ...
def _list_networks(): """Return a dictionary of network name to active status bools. Sample virsh net-list output:: Name State Autostart ----------------------------------------- default active yes juju-test inactive no foobar ...
[ "Return", "a", "dictionary", "of", "network", "name", "to", "active", "status", "bools", "." ]
michaelcontento/revolver
python
https://github.com/michaelcontento/revolver/blob/bbae82df0804ff2708a82fd0016b776664ee2deb/revolver/tool/lxc.py#L66-L92
[ "def", "_list_networks", "(", ")", ":", "output", "=", "core", ".", "run", "(", "\"virsh net-list --all\"", ")", "networks", "=", "{", "}", "# Take the header off and normalize whitespace.", "net_lines", "=", "[", "n", ".", "strip", "(", ")", "for", "n", "in",...
bbae82df0804ff2708a82fd0016b776664ee2deb
valid
Captain.flush
flush the line to stdout
captain/client.py
def flush(self, line): """flush the line to stdout""" # TODO -- maybe use echo? sys.stdout.write(line) sys.stdout.flush()
def flush(self, line): """flush the line to stdout""" # TODO -- maybe use echo? sys.stdout.write(line) sys.stdout.flush()
[ "flush", "the", "line", "to", "stdout" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/client.py#L87-L91
[ "def", "flush", "(", "self", ",", "line", ")", ":", "# TODO -- maybe use echo?", "sys", ".", "stdout", ".", "write", "(", "line", ")", "sys", ".", "stdout", ".", "flush", "(", ")" ]
4297f32961d423a10d0f053bc252e29fbe939a47
valid
Captain.execute
runs the passed in arguments and returns an iterator on the output of running command
captain/client.py
def execute(self, arg_str='', **kwargs): """runs the passed in arguments and returns an iterator on the output of running command""" cmd = "{} {} {}".format(self.cmd_prefix, self.script, arg_str) expected_ret_code = kwargs.pop('code', 0) # any kwargs with all capital letters sho...
def execute(self, arg_str='', **kwargs): """runs the passed in arguments and returns an iterator on the output of running command""" cmd = "{} {} {}".format(self.cmd_prefix, self.script, arg_str) expected_ret_code = kwargs.pop('code', 0) # any kwargs with all capital letters sho...
[ "runs", "the", "passed", "in", "arguments", "and", "returns", "an", "iterator", "on", "the", "output", "of", "running", "command" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/client.py#L110-L168
[ "def", "execute", "(", "self", ",", "arg_str", "=", "''", ",", "*", "*", "kwargs", ")", ":", "cmd", "=", "\"{} {} {}\"", ".", "format", "(", "self", ".", "cmd_prefix", ",", "self", ".", "script", ",", "arg_str", ")", "expected_ret_code", "=", "kwargs",...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
get_request_subfields
Build a basic 035 subfield with basic information from the OAI-PMH request. :param root: ElementTree root node :return: list of subfield tuples [(..),(..)]
harvestingkit/etree_utils.py
def get_request_subfields(root): """Build a basic 035 subfield with basic information from the OAI-PMH request. :param root: ElementTree root node :return: list of subfield tuples [(..),(..)] """ request = root.find('request') responsedate = root.find('responseDate') subs = [("9", request...
def get_request_subfields(root): """Build a basic 035 subfield with basic information from the OAI-PMH request. :param root: ElementTree root node :return: list of subfield tuples [(..),(..)] """ request = root.find('request') responsedate = root.find('responseDate') subs = [("9", request...
[ "Build", "a", "basic", "035", "subfield", "with", "basic", "information", "from", "the", "OAI", "-", "PMH", "request", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/etree_utils.py#L25-L38
[ "def", "get_request_subfields", "(", "root", ")", ":", "request", "=", "root", ".", "find", "(", "'request'", ")", "responsedate", "=", "root", ".", "find", "(", "'responseDate'", ")", "subs", "=", "[", "(", "\"9\"", ",", "request", ".", "text", ")", "...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
strip_xml_namespace
Strip out namespace data from an ElementTree. This function is recursive and will traverse all subnodes to the root element @param root: the root element @return: the same root element, minus namespace
harvestingkit/etree_utils.py
def strip_xml_namespace(root): """Strip out namespace data from an ElementTree. This function is recursive and will traverse all subnodes to the root element @param root: the root element @return: the same root element, minus namespace """ try: root.tag = root.tag.split('}')[1] ...
def strip_xml_namespace(root): """Strip out namespace data from an ElementTree. This function is recursive and will traverse all subnodes to the root element @param root: the root element @return: the same root element, minus namespace """ try: root.tag = root.tag.split('}')[1] ...
[ "Strip", "out", "namespace", "data", "from", "an", "ElementTree", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/etree_utils.py#L41-L57
[ "def", "strip_xml_namespace", "(", "root", ")", ":", "try", ":", "root", ".", "tag", "=", "root", ".", "tag", ".", "split", "(", "'}'", ")", "[", "1", "]", "except", "IndexError", ":", "pass", "for", "element", "in", "root", ".", "getchildren", "(", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
element_tree_collection_to_records
Take an ElementTree and converts the nodes into BibRecord records. This function is for a tree root of collection as such: <collection> <record> <!-- MARCXML --> </record> <record> ... </record> </collection>
harvestingkit/etree_utils.py
def element_tree_collection_to_records(tree): """Take an ElementTree and converts the nodes into BibRecord records. This function is for a tree root of collection as such: <collection> <record> <!-- MARCXML --> </record> <record> ... </record> </collection> """ ...
def element_tree_collection_to_records(tree): """Take an ElementTree and converts the nodes into BibRecord records. This function is for a tree root of collection as such: <collection> <record> <!-- MARCXML --> </record> <record> ... </record> </collection> """ ...
[ "Take", "an", "ElementTree", "and", "converts", "the", "nodes", "into", "BibRecord", "records", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/etree_utils.py#L60-L81
[ "def", "element_tree_collection_to_records", "(", "tree", ")", ":", "from", ".", "bibrecord", "import", "create_record", "records", "=", "[", "]", "collection", "=", "tree", ".", "getroot", "(", ")", "for", "record_element", "in", "collection", ".", "getchildren...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
element_tree_oai_records
Take an ElementTree and converts the nodes into BibRecord records. This expects a clean OAI response with the tree root as ListRecords or GetRecord and record as the subtag like so: <ListRecords|GetRecord> <record> <header> <!-- Record Information --> </heade...
harvestingkit/etree_utils.py
def element_tree_oai_records(tree, header_subs=None): """Take an ElementTree and converts the nodes into BibRecord records. This expects a clean OAI response with the tree root as ListRecords or GetRecord and record as the subtag like so: <ListRecords|GetRecord> <record> <header> ...
def element_tree_oai_records(tree, header_subs=None): """Take an ElementTree and converts the nodes into BibRecord records. This expects a clean OAI response with the tree root as ListRecords or GetRecord and record as the subtag like so: <ListRecords|GetRecord> <record> <header> ...
[ "Take", "an", "ElementTree", "and", "converts", "the", "nodes", "into", "BibRecord", "records", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/etree_utils.py#L84-L143
[ "def", "element_tree_oai_records", "(", "tree", ",", "header_subs", "=", "None", ")", ":", "from", ".", "bibrecord", "import", "record_add_field", ",", "create_record", "if", "not", "header_subs", ":", "header_subs", "=", "[", "]", "# Make it a tuple, this informati...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
run
Start a server instance. This method blocks until the server terminates. :param app: WSGI application or target string supported by :func:`load_app`. (default: :func:`default_app`) :param server: Server adapter to use. See :data:`server_names` keys for valid names or pass ...
pgs/bottle.py
def run(app=None, server='wsgiref', host='127.0.0.1', port=8080, interval=1, reloader=False, quiet=False, plugins=None, debug=None, **kargs): """ Start a server instance. This method blocks until the server terminates. :param app: WSGI applica...
def run(app=None, server='wsgiref', host='127.0.0.1', port=8080, interval=1, reloader=False, quiet=False, plugins=None, debug=None, **kargs): """ Start a server instance. This method blocks until the server terminates. :param app: WSGI applica...
[ "Start", "a", "server", "instance", ".", "This", "method", "blocks", "until", "the", "server", "terminates", "." ]
westurner/pgs
python
https://github.com/westurner/pgs/blob/1cc2bf2c41479d8d3ba50480f003183f1675e518/pgs/bottle.py#L3152-L3251
[ "def", "run", "(", "app", "=", "None", ",", "server", "=", "'wsgiref'", ",", "host", "=", "'127.0.0.1'", ",", "port", "=", "8080", ",", "interval", "=", "1", ",", "reloader", "=", "False", ",", "quiet", "=", "False", ",", "plugins", "=", "None", ",...
1cc2bf2c41479d8d3ba50480f003183f1675e518
valid
ConfigDict.load_dict
Load values from a dictionary structure. Nesting can be used to represent namespaces. >>> c = ConfigDict() >>> c.load_dict({'some': {'namespace': {'key': 'value'} } }) {'some.namespace.key': 'value'}
pgs/bottle.py
def load_dict(self, source, namespace=''): """ Load values from a dictionary structure. Nesting can be used to represent namespaces. >>> c = ConfigDict() >>> c.load_dict({'some': {'namespace': {'key': 'value'} } }) {'some.namespace.key': 'value'} """ ...
def load_dict(self, source, namespace=''): """ Load values from a dictionary structure. Nesting can be used to represent namespaces. >>> c = ConfigDict() >>> c.load_dict({'some': {'namespace': {'key': 'value'} } }) {'some.namespace.key': 'value'} """ ...
[ "Load", "values", "from", "a", "dictionary", "structure", ".", "Nesting", "can", "be", "used", "to", "represent", "namespaces", "." ]
westurner/pgs
python
https://github.com/westurner/pgs/blob/1cc2bf2c41479d8d3ba50480f003183f1675e518/pgs/bottle.py#L2170-L2187
[ "def", "load_dict", "(", "self", ",", "source", ",", "namespace", "=", "''", ")", ":", "for", "key", ",", "value", "in", "source", ".", "items", "(", ")", ":", "if", "isinstance", "(", "key", ",", "str", ")", ":", "nskey", "=", "(", "namespace", ...
1cc2bf2c41479d8d3ba50480f003183f1675e518
valid
json
The oembed endpoint, or the url to which requests for metadata are passed. Third parties will want to access this view with URLs for your site's content and be returned OEmbed metadata.
oembed/views.py
def json(request, *args, **kwargs): """ The oembed endpoint, or the url to which requests for metadata are passed. Third parties will want to access this view with URLs for your site's content and be returned OEmbed metadata. """ # coerce to dictionary params = dict(request.GET.items()) ...
def json(request, *args, **kwargs): """ The oembed endpoint, or the url to which requests for metadata are passed. Third parties will want to access this view with URLs for your site's content and be returned OEmbed metadata. """ # coerce to dictionary params = dict(request.GET.items()) ...
[ "The", "oembed", "endpoint", "or", "the", "url", "to", "which", "requests", "for", "metadata", "are", "passed", ".", "Third", "parties", "will", "want", "to", "access", "this", "view", "with", "URLs", "for", "your", "site", "s", "content", "and", "be", "...
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/views.py#L19-L56
[ "def", "json", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# coerce to dictionary", "params", "=", "dict", "(", "request", ".", "GET", ".", "items", "(", ")", ")", "callback", "=", "params", ".", "pop", "(", "'callback'", ",...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
consume_json
Extract and return oembed content for given urls. Required GET params: urls - list of urls to consume Optional GET params: width - maxwidth attribute for oembed content height - maxheight attribute for oembed content template_dir - template_dir to use when rendering oembed ...
oembed/views.py
def consume_json(request): """ Extract and return oembed content for given urls. Required GET params: urls - list of urls to consume Optional GET params: width - maxwidth attribute for oembed content height - maxheight attribute for oembed content template_dir - templat...
def consume_json(request): """ Extract and return oembed content for given urls. Required GET params: urls - list of urls to consume Optional GET params: width - maxwidth attribute for oembed content height - maxheight attribute for oembed content template_dir - templat...
[ "Extract", "and", "return", "oembed", "content", "for", "given", "urls", "." ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/views.py#L59-L99
[ "def", "consume_json", "(", "request", ")", ":", "client", "=", "OEmbedConsumer", "(", ")", "urls", "=", "request", ".", "GET", ".", "getlist", "(", "'urls'", ")", "width", "=", "request", ".", "GET", ".", "get", "(", "'width'", ")", "height", "=", "...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
oembed_schema
A site profile detailing valid endpoints for a given domain. Allows for better auto-discovery of embeddable content. OEmbed-able content lives at a URL that maps to a provider.
oembed/views.py
def oembed_schema(request): """ A site profile detailing valid endpoints for a given domain. Allows for better auto-discovery of embeddable content. OEmbed-able content lives at a URL that maps to a provider. """ current_domain = Site.objects.get_current().domain url_schemes = [] # a list ...
def oembed_schema(request): """ A site profile detailing valid endpoints for a given domain. Allows for better auto-discovery of embeddable content. OEmbed-able content lives at a URL that maps to a provider. """ current_domain = Site.objects.get_current().domain url_schemes = [] # a list ...
[ "A", "site", "profile", "detailing", "valid", "endpoints", "for", "a", "given", "domain", ".", "Allows", "for", "better", "auto", "-", "discovery", "of", "embeddable", "content", "." ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/views.py#L101-L144
[ "def", "oembed_schema", "(", "request", ")", ":", "current_domain", "=", "Site", ".", "objects", ".", "get_current", "(", ")", ".", "domain", "url_schemes", "=", "[", "]", "# a list of dictionaries for all the urls we can match", "endpoint", "=", "reverse", "(", "...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
find_meta
Extract __*meta*__ from meta_file.
setup.py
def find_meta(*meta_file_parts, meta_key): """Extract __*meta*__ from meta_file.""" meta_file = read(*meta_file_parts) meta_match = re.search(r"^__{}__ = ['\"]([^'\"]*)['\"]".format(meta_key), meta_file, re.M) if meta_match: return meta_match.group(1) raise Runtime...
def find_meta(*meta_file_parts, meta_key): """Extract __*meta*__ from meta_file.""" meta_file = read(*meta_file_parts) meta_match = re.search(r"^__{}__ = ['\"]([^'\"]*)['\"]".format(meta_key), meta_file, re.M) if meta_match: return meta_match.group(1) raise Runtime...
[ "Extract", "__", "*", "meta", "*", "__", "from", "meta_file", "." ]
MinchinWeb/minchin.pelican.jinja_filters
python
https://github.com/MinchinWeb/minchin.pelican.jinja_filters/blob/94b8b1dd04be49950d660fe11d28f0df0fe49664/setup.py#L16-L23
[ "def", "find_meta", "(", "*", "meta_file_parts", ",", "meta_key", ")", ":", "meta_file", "=", "read", "(", "*", "meta_file_parts", ")", "meta_match", "=", "re", ".", "search", "(", "r\"^__{}__ = ['\\\"]([^'\\\"]*)['\\\"]\"", ".", "format", "(", "meta_key", ")", ...
94b8b1dd04be49950d660fe11d28f0df0fe49664
valid
main
scan path directory and any subdirectories for valid captain scripts
captain/__main__.py
def main(path): '''scan path directory and any subdirectories for valid captain scripts''' basepath = os.path.abspath(os.path.expanduser(str(path))) echo.h2("Available scripts in {}".format(basepath)) echo.br() for root_dir, dirs, files in os.walk(basepath, topdown=True): for f in fnmatch.f...
def main(path): '''scan path directory and any subdirectories for valid captain scripts''' basepath = os.path.abspath(os.path.expanduser(str(path))) echo.h2("Available scripts in {}".format(basepath)) echo.br() for root_dir, dirs, files in os.walk(basepath, topdown=True): for f in fnmatch.f...
[ "scan", "path", "directory", "and", "any", "subdirectories", "for", "valid", "captain", "scripts" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/__main__.py#L15-L65
[ "def", "main", "(", "path", ")", ":", "basepath", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "expanduser", "(", "str", "(", "path", ")", ")", ")", "echo", ".", "h2", "(", "\"Available scripts in {}\"", ".", "format", "(", ...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
ZipTaxClient.get_rate
Finds sales tax for given info. Returns Decimal of the tax rate, e.g. 8.750.
pyziptax/ziptax.py
def get_rate(self, zipcode, city=None, state=None, multiple_rates=False): """ Finds sales tax for given info. Returns Decimal of the tax rate, e.g. 8.750. """ data = self.make_request_data(zipcode, city, state) r = requests.get(self.url, params=data) resp = r.jso...
def get_rate(self, zipcode, city=None, state=None, multiple_rates=False): """ Finds sales tax for given info. Returns Decimal of the tax rate, e.g. 8.750. """ data = self.make_request_data(zipcode, city, state) r = requests.get(self.url, params=data) resp = r.jso...
[ "Finds", "sales", "tax", "for", "given", "info", ".", "Returns", "Decimal", "of", "the", "tax", "rate", "e", ".", "g", ".", "8", ".", "750", "." ]
albertyw/pyziptax
python
https://github.com/albertyw/pyziptax/blob/c56dd440e4cadff7f2dd4b72e5dcced06a44969d/pyziptax/ziptax.py#L24-L34
[ "def", "get_rate", "(", "self", ",", "zipcode", ",", "city", "=", "None", ",", "state", "=", "None", ",", "multiple_rates", "=", "False", ")", ":", "data", "=", "self", ".", "make_request_data", "(", "zipcode", ",", "city", ",", "state", ")", "r", "=...
c56dd440e4cadff7f2dd4b72e5dcced06a44969d
valid
ZipTaxClient.make_request_data
Make the request params given location data
pyziptax/ziptax.py
def make_request_data(self, zipcode, city, state): """ Make the request params given location data """ data = {'key': self.api_key, 'postalcode': str(zipcode), 'city': city, 'state': state } data = ZipTaxClient._clean_request_data(data) ...
def make_request_data(self, zipcode, city, state): """ Make the request params given location data """ data = {'key': self.api_key, 'postalcode': str(zipcode), 'city': city, 'state': state } data = ZipTaxClient._clean_request_data(data) ...
[ "Make", "the", "request", "params", "given", "location", "data" ]
albertyw/pyziptax
python
https://github.com/albertyw/pyziptax/blob/c56dd440e4cadff7f2dd4b72e5dcced06a44969d/pyziptax/ziptax.py#L36-L44
[ "def", "make_request_data", "(", "self", ",", "zipcode", ",", "city", ",", "state", ")", ":", "data", "=", "{", "'key'", ":", "self", ".", "api_key", ",", "'postalcode'", ":", "str", "(", "zipcode", ")", ",", "'city'", ":", "city", ",", "'state'", ":...
c56dd440e4cadff7f2dd4b72e5dcced06a44969d
valid
ZipTaxClient.process_response
Get the tax rate from the ZipTax response
pyziptax/ziptax.py
def process_response(self, resp, multiple_rates): """ Get the tax rate from the ZipTax response """ self._check_for_exceptions(resp, multiple_rates) rates = {} for result in resp['results']: rate = ZipTaxClient._cast_tax_rate(result['taxSales']) rates[result['geo...
def process_response(self, resp, multiple_rates): """ Get the tax rate from the ZipTax response """ self._check_for_exceptions(resp, multiple_rates) rates = {} for result in resp['results']: rate = ZipTaxClient._cast_tax_rate(result['taxSales']) rates[result['geo...
[ "Get", "the", "tax", "rate", "from", "the", "ZipTax", "response" ]
albertyw/pyziptax
python
https://github.com/albertyw/pyziptax/blob/c56dd440e4cadff7f2dd4b72e5dcced06a44969d/pyziptax/ziptax.py#L57-L67
[ "def", "process_response", "(", "self", ",", "resp", ",", "multiple_rates", ")", ":", "self", ".", "_check_for_exceptions", "(", "resp", ",", "multiple_rates", ")", "rates", "=", "{", "}", "for", "result", "in", "resp", "[", "'results'", "]", ":", "rate", ...
c56dd440e4cadff7f2dd4b72e5dcced06a44969d
valid
ZipTaxClient._check_for_exceptions
Check if there are exceptions that should be raised
pyziptax/ziptax.py
def _check_for_exceptions(self, resp, multiple_rates): """ Check if there are exceptions that should be raised """ if resp['rCode'] != 100: raise exceptions.get_exception_for_code(resp['rCode'])(resp) results = resp['results'] if len(results) == 0: raise exceptio...
def _check_for_exceptions(self, resp, multiple_rates): """ Check if there are exceptions that should be raised """ if resp['rCode'] != 100: raise exceptions.get_exception_for_code(resp['rCode'])(resp) results = resp['results'] if len(results) == 0: raise exceptio...
[ "Check", "if", "there", "are", "exceptions", "that", "should", "be", "raised" ]
albertyw/pyziptax
python
https://github.com/albertyw/pyziptax/blob/c56dd440e4cadff7f2dd4b72e5dcced06a44969d/pyziptax/ziptax.py#L69-L81
[ "def", "_check_for_exceptions", "(", "self", ",", "resp", ",", "multiple_rates", ")", ":", "if", "resp", "[", "'rCode'", "]", "!=", "100", ":", "raise", "exceptions", ".", "get_exception_for_code", "(", "resp", "[", "'rCode'", "]", ")", "(", "resp", ")", ...
c56dd440e4cadff7f2dd4b72e5dcced06a44969d
valid
get_all_text
Recursively extract all text from node.
harvestingkit/minidom_utils.py
def get_all_text(node): """Recursively extract all text from node.""" if node.nodeType == node.TEXT_NODE: return node.data else: text_string = "" for child_node in node.childNodes: text_string += get_all_text(child_node) return text_string
def get_all_text(node): """Recursively extract all text from node.""" if node.nodeType == node.TEXT_NODE: return node.data else: text_string = "" for child_node in node.childNodes: text_string += get_all_text(child_node) return text_string
[ "Recursively", "extract", "all", "text", "from", "node", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/minidom_utils.py#L65-L73
[ "def", "get_all_text", "(", "node", ")", ":", "if", "node", ".", "nodeType", "==", "node", ".", "TEXT_NODE", ":", "return", "node", ".", "data", "else", ":", "text_string", "=", "\"\"", "for", "child_node", "in", "node", ".", "childNodes", ":", "text_str...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
ContrastOutConnector._extract_packages
Extract a package in a new temporary directory.
harvestingkit/contrast_out.py
def _extract_packages(self): """ Extract a package in a new temporary directory. """ self.path_unpacked = mkdtemp(prefix="scoap3_package_", dir=CFG_TMPSHAREDDIR) for path in self.retrieved_packages_unpacked: scoap3utils_extract_pac...
def _extract_packages(self): """ Extract a package in a new temporary directory. """ self.path_unpacked = mkdtemp(prefix="scoap3_package_", dir=CFG_TMPSHAREDDIR) for path in self.retrieved_packages_unpacked: scoap3utils_extract_pac...
[ "Extract", "a", "package", "in", "a", "new", "temporary", "directory", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/contrast_out.py#L217-L226
[ "def", "_extract_packages", "(", "self", ")", ":", "self", ".", "path_unpacked", "=", "mkdtemp", "(", "prefix", "=", "\"scoap3_package_\"", ",", "dir", "=", "CFG_TMPSHAREDDIR", ")", "for", "path", "in", "self", ".", "retrieved_packages_unpacked", ":", "scoap3uti...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
ProviderSite.register
Registers a provider with the site.
oembed/sites.py
def register(self, provider_class): """ Registers a provider with the site. """ if not issubclass(provider_class, BaseProvider): raise TypeError('%s is not a subclass of BaseProvider' % provider_class.__name__) if provider_class in self._registered_providers:...
def register(self, provider_class): """ Registers a provider with the site. """ if not issubclass(provider_class, BaseProvider): raise TypeError('%s is not a subclass of BaseProvider' % provider_class.__name__) if provider_class in self._registered_providers:...
[ "Registers", "a", "provider", "with", "the", "site", "." ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/sites.py#L29-L53
[ "def", "register", "(", "self", ",", "provider_class", ")", ":", "if", "not", "issubclass", "(", "provider_class", ",", "BaseProvider", ")", ":", "raise", "TypeError", "(", "'%s is not a subclass of BaseProvider'", "%", "provider_class", ".", "__name__", ")", "if"...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
ProviderSite.unregister
Unregisters a provider from the site.
oembed/sites.py
def unregister(self, provider_class): """ Unregisters a provider from the site. """ if not issubclass(provider_class, BaseProvider): raise TypeError('%s must be a subclass of BaseProvider' % provider_class.__name__) if provider_class not in self._registered_p...
def unregister(self, provider_class): """ Unregisters a provider from the site. """ if not issubclass(provider_class, BaseProvider): raise TypeError('%s must be a subclass of BaseProvider' % provider_class.__name__) if provider_class not in self._registered_p...
[ "Unregisters", "a", "provider", "from", "the", "site", "." ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/sites.py#L55-L68
[ "def", "unregister", "(", "self", ",", "provider_class", ")", ":", "if", "not", "issubclass", "(", "provider_class", ",", "BaseProvider", ")", ":", "raise", "TypeError", "(", "'%s must be a subclass of BaseProvider'", "%", "provider_class", ".", "__name__", ")", "...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
ProviderSite.populate
Populate the internal registry's dictionary with the regexes for each provider instance
oembed/sites.py
def populate(self): """ Populate the internal registry's dictionary with the regexes for each provider instance """ self._registry = {} for provider_class in self._registered_providers: instance = provider_class() self._registry[instance] ...
def populate(self): """ Populate the internal registry's dictionary with the regexes for each provider instance """ self._registry = {} for provider_class in self._registered_providers: instance = provider_class() self._registry[instance] ...
[ "Populate", "the", "internal", "registry", "s", "dictionary", "with", "the", "regexes", "for", "each", "provider", "instance" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/sites.py#L70-L84
[ "def", "populate", "(", "self", ")", ":", "self", ".", "_registry", "=", "{", "}", "for", "provider_class", "in", "self", ".", "_registered_providers", ":", "instance", "=", "provider_class", "(", ")", "self", ".", "_registry", "[", "instance", "]", "=", ...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
ProviderSite.provider_for_url
Find the right provider for a URL
oembed/sites.py
def provider_for_url(self, url): """ Find the right provider for a URL """ for provider, regex in self.get_registry().items(): if re.match(regex, url) is not None: return provider raise OEmbedMissingEndpoint('No endpoint matches URL: %s' % url...
def provider_for_url(self, url): """ Find the right provider for a URL """ for provider, regex in self.get_registry().items(): if re.match(regex, url) is not None: return provider raise OEmbedMissingEndpoint('No endpoint matches URL: %s' % url...
[ "Find", "the", "right", "provider", "for", "a", "URL" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/sites.py#L106-L114
[ "def", "provider_for_url", "(", "self", ",", "url", ")", ":", "for", "provider", ",", "regex", "in", "self", ".", "get_registry", "(", ")", ".", "items", "(", ")", ":", "if", "re", ".", "match", "(", "regex", ",", "url", ")", "is", "not", "None", ...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
ProviderSite.invalidate_stored_oembeds
A hook for django-based oembed providers to delete any stored oembeds
oembed/sites.py
def invalidate_stored_oembeds(self, sender, instance, created, **kwargs): """ A hook for django-based oembed providers to delete any stored oembeds """ ctype = ContentType.objects.get_for_model(instance) StoredOEmbed.objects.filter( object_id=instance.pk, ...
def invalidate_stored_oembeds(self, sender, instance, created, **kwargs): """ A hook for django-based oembed providers to delete any stored oembeds """ ctype = ContentType.objects.get_for_model(instance) StoredOEmbed.objects.filter( object_id=instance.pk, ...
[ "A", "hook", "for", "django", "-", "based", "oembed", "providers", "to", "delete", "any", "stored", "oembeds" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/sites.py#L116-L123
[ "def", "invalidate_stored_oembeds", "(", "self", ",", "sender", ",", "instance", ",", "created", ",", "*", "*", "kwargs", ")", ":", "ctype", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "instance", ")", "StoredOEmbed", ".", "objects", ".", ...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
ProviderSite.embed
The heart of the matter
oembed/sites.py
def embed(self, url, **kwargs): """ The heart of the matter """ try: # first figure out the provider provider = self.provider_for_url(url) except OEmbedMissingEndpoint: raise else: try: # check the database f...
def embed(self, url, **kwargs): """ The heart of the matter """ try: # first figure out the provider provider = self.provider_for_url(url) except OEmbedMissingEndpoint: raise else: try: # check the database f...
[ "The", "heart", "of", "the", "matter" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/sites.py#L125-L175
[ "def", "embed", "(", "self", ",", "url", ",", "*", "*", "kwargs", ")", ":", "try", ":", "# first figure out the provider", "provider", "=", "self", ".", "provider_for_url", "(", "url", ")", "except", "OEmbedMissingEndpoint", ":", "raise", "else", ":", "try",...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
ProviderSite.autodiscover
Load up StoredProviders from url if it is an oembed scheme
oembed/sites.py
def autodiscover(self, url): """ Load up StoredProviders from url if it is an oembed scheme """ headers, response = fetch_url(url) if headers['content-type'].split(';')[0] in ('application/json', 'text/javascript'): provider_data = json.loads(response) ret...
def autodiscover(self, url): """ Load up StoredProviders from url if it is an oembed scheme """ headers, response = fetch_url(url) if headers['content-type'].split(';')[0] in ('application/json', 'text/javascript'): provider_data = json.loads(response) ret...
[ "Load", "up", "StoredProviders", "from", "url", "if", "it", "is", "an", "oembed", "scheme" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/sites.py#L177-L184
[ "def", "autodiscover", "(", "self", ",", "url", ")", ":", "headers", ",", "response", "=", "fetch_url", "(", "url", ")", "if", "headers", "[", "'content-type'", "]", ".", "split", "(", "';'", ")", "[", "0", "]", "in", "(", "'application/json'", ",", ...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
ProviderSite.store_providers
Iterate over the returned json and try to sort out any new providers
oembed/sites.py
def store_providers(self, provider_data): """ Iterate over the returned json and try to sort out any new providers """ if not hasattr(provider_data, '__iter__'): raise OEmbedException('Autodiscovered response not iterable') provider_pks = [] ...
def store_providers(self, provider_data): """ Iterate over the returned json and try to sort out any new providers """ if not hasattr(provider_data, '__iter__'): raise OEmbedException('Autodiscovered response not iterable') provider_pks = [] ...
[ "Iterate", "over", "the", "returned", "json", "and", "try", "to", "sort", "out", "any", "new", "providers" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/sites.py#L186-L218
[ "def", "store_providers", "(", "self", ",", "provider_data", ")", ":", "if", "not", "hasattr", "(", "provider_data", ",", "'__iter__'", ")", ":", "raise", "OEmbedException", "(", "'Autodiscovered response not iterable'", ")", "provider_pks", "=", "[", "]", "for", ...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
HTTPProvider.request_resource
Request an OEmbedResource for a given url. Some valid keyword args: - format - maxwidth - maxheight
oembed/providers.py
def request_resource(self, url, **kwargs): """ Request an OEmbedResource for a given url. Some valid keyword args: - format - maxwidth - maxheight """ params = kwargs params['url'] = url params['format'] = 'json' if '?' i...
def request_resource(self, url, **kwargs): """ Request an OEmbedResource for a given url. Some valid keyword args: - format - maxwidth - maxheight """ params = kwargs params['url'] = url params['format'] = 'json' if '?' i...
[ "Request", "an", "OEmbedResource", "for", "a", "given", "url", ".", "Some", "valid", "keyword", "args", ":", "-", "format", "-", "maxwidth", "-", "maxheight" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L114-L134
[ "def", "request_resource", "(", "self", ",", "url", ",", "*", "*", "kwargs", ")", ":", "params", "=", "kwargs", "params", "[", "'url'", "]", "=", "url", "params", "[", "'format'", "]", "=", "'json'", "if", "'?'", "in", "self", ".", "endpoint_url", ":...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
DjangoProviderOptions._image_field
Try to automatically detect an image field
oembed/providers.py
def _image_field(self): """ Try to automatically detect an image field """ for field in self.model._meta.fields: if isinstance(field, ImageField): return field.name
def _image_field(self): """ Try to automatically detect an image field """ for field in self.model._meta.fields: if isinstance(field, ImageField): return field.name
[ "Try", "to", "automatically", "detect", "an", "image", "field" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L179-L185
[ "def", "_image_field", "(", "self", ")", ":", "for", "field", "in", "self", ".", "model", ".", "_meta", ".", "fields", ":", "if", "isinstance", "(", "field", ",", "ImageField", ")", ":", "return", "field", ".", "name" ]
f3f2be283441d91d1f89db780444dc75f7b51902
valid
DjangoProviderOptions._date_field
Try to automatically detect an image field
oembed/providers.py
def _date_field(self): """ Try to automatically detect an image field """ for field in self.model._meta.fields: if isinstance(field, (DateTimeField, DateField)): return field.name
def _date_field(self): """ Try to automatically detect an image field """ for field in self.model._meta.fields: if isinstance(field, (DateTimeField, DateField)): return field.name
[ "Try", "to", "automatically", "detect", "an", "image", "field" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L188-L194
[ "def", "_date_field", "(", "self", ")", ":", "for", "field", "in", "self", ".", "model", ".", "_meta", ".", "fields", ":", "if", "isinstance", "(", "field", ",", "(", "DateTimeField", ",", "DateField", ")", ")", ":", "return", "field", ".", "name" ]
f3f2be283441d91d1f89db780444dc75f7b51902
valid
DjangoProvider._build_regex
Performs a reverse lookup on a named view and generates a list of regexes that match that object. It generates regexes with the domain name included, using sites provided by the get_sites() method. >>> regex = provider.regex >>> regex.pattern 'http://(www2.kuspo...
oembed/providers.py
def _build_regex(self): """ Performs a reverse lookup on a named view and generates a list of regexes that match that object. It generates regexes with the domain name included, using sites provided by the get_sites() method. >>> regex = provider.regex >...
def _build_regex(self): """ Performs a reverse lookup on a named view and generates a list of regexes that match that object. It generates regexes with the domain name included, using sites provided by the get_sites() method. >>> regex = provider.regex >...
[ "Performs", "a", "reverse", "lookup", "on", "a", "named", "view", "and", "generates", "a", "list", "of", "regexes", "that", "match", "that", "object", ".", "It", "generates", "regexes", "with", "the", "domain", "name", "included", "using", "sites", "provided...
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L276-L309
[ "def", "_build_regex", "(", "self", ")", ":", "# get the regexes from the urlconf", "url_patterns", "=", "resolver", ".", "reverse_dict", ".", "get", "(", "self", ".", "_meta", ".", "named_view", ")", "try", ":", "regex", "=", "url_patterns", "[", "1", "]", ...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
DjangoProvider.provider_from_url
Given a URL for any of our sites, try and match it to one, returning the domain & name of the match. If no match is found, return current. Returns a tuple of domain, site name -- used to determine 'provider'
oembed/providers.py
def provider_from_url(self, url): """ Given a URL for any of our sites, try and match it to one, returning the domain & name of the match. If no match is found, return current. Returns a tuple of domain, site name -- used to determine 'provider' """ domain = get...
def provider_from_url(self, url): """ Given a URL for any of our sites, try and match it to one, returning the domain & name of the match. If no match is found, return current. Returns a tuple of domain, site name -- used to determine 'provider' """ domain = get...
[ "Given", "a", "URL", "for", "any", "of", "our", "sites", "try", "and", "match", "it", "to", "one", "returning", "the", "domain", "&", "name", "of", "the", "match", ".", "If", "no", "match", "is", "found", "return", "current", ".", "Returns", "a", "tu...
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L327-L340
[ "def", "provider_from_url", "(", "self", ",", "url", ")", ":", "domain", "=", "get_domain", "(", "url", ")", "site_tuples", "=", "self", ".", "get_cleaned_sites", "(", ")", ".", "values", "(", ")", "for", "domain_re", ",", "name", ",", "normalized_domain",...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
DjangoProvider.get_params
Extract the named parameters from a url regex. If the url regex does not contain named parameters, they will be keyed _0, _1, ... * Named parameters Regex: /photos/^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{1,2})/(?P<object_id>\d+)/ URL: http://www2.l...
oembed/providers.py
def get_params(self, url): """ Extract the named parameters from a url regex. If the url regex does not contain named parameters, they will be keyed _0, _1, ... * Named parameters Regex: /photos/^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{1,2})/(?P<object_id>\d...
def get_params(self, url): """ Extract the named parameters from a url regex. If the url regex does not contain named parameters, they will be keyed _0, _1, ... * Named parameters Regex: /photos/^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{1,2})/(?P<object_id>\d...
[ "Extract", "the", "named", "parameters", "from", "a", "url", "regex", ".", "If", "the", "url", "regex", "does", "not", "contain", "named", "parameters", "they", "will", "be", "keyed", "_0", "_1", "...", "*", "Named", "parameters", "Regex", ":", "/", "pho...
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L342-L376
[ "def", "get_params", "(", "self", ",", "url", ")", ":", "match", "=", "re", ".", "match", "(", "self", ".", "regex", ",", "url", ")", "if", "match", "is", "not", "None", ":", "params", "=", "match", ".", "groupdict", "(", ")", "if", "not", "param...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
DjangoProvider.get_object
Fields to match is a mapping of url params to fields, so for the photos example above, it would be: fields_to_match = { 'object_id': 'id' } This procedure parses out named params from a URL and then uses the fields_to_match dictionary to generate a query.
oembed/providers.py
def get_object(self, url): """ Fields to match is a mapping of url params to fields, so for the photos example above, it would be: fields_to_match = { 'object_id': 'id' } This procedure parses out named params from a URL and then uses the fields_to_match...
def get_object(self, url): """ Fields to match is a mapping of url params to fields, so for the photos example above, it would be: fields_to_match = { 'object_id': 'id' } This procedure parses out named params from a URL and then uses the fields_to_match...
[ "Fields", "to", "match", "is", "a", "mapping", "of", "url", "params", "to", "fields", "so", "for", "the", "photos", "example", "above", "it", "would", "be", ":", "fields_to_match", "=", "{", "object_id", ":", "id", "}", "This", "procedure", "parses", "ou...
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L381-L404
[ "def", "get_object", "(", "self", ",", "url", ")", ":", "params", "=", "self", ".", "get_params", "(", "url", ")", "query", "=", "{", "}", "for", "key", ",", "value", "in", "self", ".", "_meta", ".", "fields_to_match", ".", "iteritems", "(", ")", "...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
DjangoProvider.render_html
Generate the 'html' attribute of an oembed resource using a template. Sort of a corollary to the parser's render_oembed method. By default, the current mapping will be passed in as the context. OEmbed templates are stored in: oembed/provider/[app_label]_[model].html ...
oembed/providers.py
def render_html(self, obj, context=None): """ Generate the 'html' attribute of an oembed resource using a template. Sort of a corollary to the parser's render_oembed method. By default, the current mapping will be passed in as the context. OEmbed templates are stored in...
def render_html(self, obj, context=None): """ Generate the 'html' attribute of an oembed resource using a template. Sort of a corollary to the parser's render_oembed method. By default, the current mapping will be passed in as the context. OEmbed templates are stored in...
[ "Generate", "the", "html", "attribute", "of", "an", "oembed", "resource", "using", "a", "template", ".", "Sort", "of", "a", "corollary", "to", "the", "parser", "s", "render_oembed", "method", ".", "By", "default", "the", "current", "mapping", "will", "be", ...
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L406-L428
[ "def", "render_html", "(", "self", ",", "obj", ",", "context", "=", "None", ")", ":", "provided_context", "=", "context", "or", "Context", "(", ")", "context", "=", "RequestContext", "(", "mock_request", "(", ")", ")", "context", ".", "update", "(", "pro...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
DjangoProvider.map_attr
A kind of cheesy method that allows for callables or attributes to be used interchangably
oembed/providers.py
def map_attr(self, mapping, attr, obj): """ A kind of cheesy method that allows for callables or attributes to be used interchangably """ if attr not in mapping and hasattr(self, attr): if not callable(getattr(self, attr)): mapping[attr] = getattr(self...
def map_attr(self, mapping, attr, obj): """ A kind of cheesy method that allows for callables or attributes to be used interchangably """ if attr not in mapping and hasattr(self, attr): if not callable(getattr(self, attr)): mapping[attr] = getattr(self...
[ "A", "kind", "of", "cheesy", "method", "that", "allows", "for", "callables", "or", "attributes", "to", "be", "used", "interchangably" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L430-L439
[ "def", "map_attr", "(", "self", ",", "mapping", ",", "attr", ",", "obj", ")", ":", "if", "attr", "not", "in", "mapping", "and", "hasattr", "(", "self", ",", "attr", ")", ":", "if", "not", "callable", "(", "getattr", "(", "self", ",", "attr", ")", ...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
DjangoProvider.get_image
Return an ImageFileField instance
oembed/providers.py
def get_image(self, obj): """ Return an ImageFileField instance """ if self._meta.image_field: return getattr(obj, self._meta.image_field)
def get_image(self, obj): """ Return an ImageFileField instance """ if self._meta.image_field: return getattr(obj, self._meta.image_field)
[ "Return", "an", "ImageFileField", "instance" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L441-L446
[ "def", "get_image", "(", "self", ",", "obj", ")", ":", "if", "self", ".", "_meta", ".", "image_field", ":", "return", "getattr", "(", "obj", ",", "self", ".", "_meta", ".", "image_field", ")" ]
f3f2be283441d91d1f89db780444dc75f7b51902
valid
DjangoProvider.resize
Resize an image to the 'best fit' width & height, maintaining the scale of the image, so a 500x500 image sized to 300x400 will actually be scaled to 300x300. Params: image: ImageFieldFile to be resized (i.e. model.image_field) new_width & new_height: desired maximums for...
oembed/providers.py
def resize(self, image_field, new_width=None, new_height=None): """ Resize an image to the 'best fit' width & height, maintaining the scale of the image, so a 500x500 image sized to 300x400 will actually be scaled to 300x300. Params: image: ImageFieldFile to be r...
def resize(self, image_field, new_width=None, new_height=None): """ Resize an image to the 'best fit' width & height, maintaining the scale of the image, so a 500x500 image sized to 300x400 will actually be scaled to 300x300. Params: image: ImageFieldFile to be r...
[ "Resize", "an", "image", "to", "the", "best", "fit", "width", "&", "height", "maintaining", "the", "scale", "of", "the", "image", "so", "a", "500x500", "image", "sized", "to", "300x400", "will", "actually", "be", "scaled", "to", "300x300", ".", "Params", ...
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L448-L486
[ "def", "resize", "(", "self", ",", "image_field", ",", "new_width", "=", "None", ",", "new_height", "=", "None", ")", ":", "if", "isinstance", "(", "image_field", ",", "ImageFieldFile", ")", "and", "image_field", ".", "field", ".", "width_field", "and", "i...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
DjangoProvider.map_to_dictionary
Build a dictionary of metadata for the requested object.
oembed/providers.py
def map_to_dictionary(self, url, obj, **kwargs): """ Build a dictionary of metadata for the requested object. """ maxwidth = kwargs.get('maxwidth', None) maxheight = kwargs.get('maxheight', None) provider_url, provider_name = self.provider_from_url(url) ...
def map_to_dictionary(self, url, obj, **kwargs): """ Build a dictionary of metadata for the requested object. """ maxwidth = kwargs.get('maxwidth', None) maxheight = kwargs.get('maxheight', None) provider_url, provider_name = self.provider_from_url(url) ...
[ "Build", "a", "dictionary", "of", "metadata", "for", "the", "requested", "object", "." ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L513-L568
[ "def", "map_to_dictionary", "(", "self", ",", "url", ",", "obj", ",", "*", "*", "kwargs", ")", ":", "maxwidth", "=", "kwargs", ".", "get", "(", "'maxwidth'", ",", "None", ")", "maxheight", "=", "kwargs", ".", "get", "(", "'maxheight'", ",", "None", "...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
DjangoProvider.request_resource
Request an OEmbedResource for a given url. Some valid keyword args: - format - maxwidth - maxheight
oembed/providers.py
def request_resource(self, url, **kwargs): """ Request an OEmbedResource for a given url. Some valid keyword args: - format - maxwidth - maxheight """ obj = self.get_object(url) mapping = self.map_to_dictionary(url, obj, **kwargs) ...
def request_resource(self, url, **kwargs): """ Request an OEmbedResource for a given url. Some valid keyword args: - format - maxwidth - maxheight """ obj = self.get_object(url) mapping = self.map_to_dictionary(url, obj, **kwargs) ...
[ "Request", "an", "OEmbedResource", "for", "a", "given", "url", ".", "Some", "valid", "keyword", "args", ":", "-", "format", "-", "maxwidth", "-", "maxheight" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L570-L584
[ "def", "request_resource", "(", "self", ",", "url", ",", "*", "*", "kwargs", ")", ":", "obj", "=", "self", ".", "get_object", "(", "url", ")", "mapping", "=", "self", ".", "map_to_dictionary", "(", "url", ",", "obj", ",", "*", "*", "kwargs", ")", "...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
DjangoDateBasedProvider.get_object
Parses the date from a url and uses it in the query. For objects which are unique for date.
oembed/providers.py
def get_object(self, url, month_format='%b', day_format='%d'): """ Parses the date from a url and uses it in the query. For objects which are unique for date. """ params = self.get_params(url) try: year = params[self._meta.year_part] month = param...
def get_object(self, url, month_format='%b', day_format='%d'): """ Parses the date from a url and uses it in the query. For objects which are unique for date. """ params = self.get_params(url) try: year = params[self._meta.year_part] month = param...
[ "Parses", "the", "date", "from", "a", "url", "and", "uses", "it", "in", "the", "query", ".", "For", "objects", "which", "are", "unique", "for", "date", "." ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L595-L640
[ "def", "get_object", "(", "self", ",", "url", ",", "month_format", "=", "'%b'", ",", "day_format", "=", "'%d'", ")", ":", "params", "=", "self", ".", "get_params", "(", "url", ")", "try", ":", "year", "=", "params", "[", "self", ".", "_meta", ".", ...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
Inspire2CDS.get_record
Override the base.
harvestingkit/inspire_cds_package/from_inspire.py
def get_record(self): """Override the base.""" self.recid = self.get_recid() self.remove_controlfields() self.update_system_numbers() self.add_systemnumber("Inspire", recid=self.recid) self.add_control_number("003", "SzGeCERN") self.update_collections() se...
def get_record(self): """Override the base.""" self.recid = self.get_recid() self.remove_controlfields() self.update_system_numbers() self.add_systemnumber("Inspire", recid=self.recid) self.add_control_number("003", "SzGeCERN") self.update_collections() se...
[ "Override", "the", "base", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L178-L230
[ "def", "get_record", "(", "self", ")", ":", "self", ".", "recid", "=", "self", ".", "get_recid", "(", ")", "self", ".", "remove_controlfields", "(", ")", "self", ".", "update_system_numbers", "(", ")", "self", ".", "add_systemnumber", "(", "\"Inspire\"", "...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_oai_info
Add the 909 OAI info to 035.
harvestingkit/inspire_cds_package/from_inspire.py
def update_oai_info(self): """Add the 909 OAI info to 035.""" for field in record_get_field_instances(self.record, '909', ind1="C", ind2="O"): new_subs = [] for tag, value in field[0]: if tag == "o": new_subs.append(("a", value)) ...
def update_oai_info(self): """Add the 909 OAI info to 035.""" for field in record_get_field_instances(self.record, '909', ind1="C", ind2="O"): new_subs = [] for tag, value in field[0]: if tag == "o": new_subs.append(("a", value)) ...
[ "Add", "the", "909", "OAI", "info", "to", "035", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L232-L244
[ "def", "update_oai_info", "(", "self", ")", ":", "for", "field", "in", "record_get_field_instances", "(", "self", ".", "record", ",", "'909'", ",", "ind1", "=", "\"C\"", ",", "ind2", "=", "\"O\"", ")", ":", "new_subs", "=", "[", "]", "for", "tag", ",",...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_cnum
Check if we shall add cnum in 035.
harvestingkit/inspire_cds_package/from_inspire.py
def update_cnum(self): """Check if we shall add cnum in 035.""" if "ConferencePaper" not in self.collections: cnums = record_get_field_values(self.record, '773', code="w") for cnum in cnums: cnum_subs = [ ("9", "INSPIRE-CNUM"), ...
def update_cnum(self): """Check if we shall add cnum in 035.""" if "ConferencePaper" not in self.collections: cnums = record_get_field_values(self.record, '773', code="w") for cnum in cnums: cnum_subs = [ ("9", "INSPIRE-CNUM"), ...
[ "Check", "if", "we", "shall", "add", "cnum", "in", "035", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L246-L255
[ "def", "update_cnum", "(", "self", ")", ":", "if", "\"ConferencePaper\"", "not", "in", "self", ".", "collections", ":", "cnums", "=", "record_get_field_values", "(", "self", ".", "record", ",", "'773'", ",", "code", "=", "\"w\"", ")", "for", "cnum", "in", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_hidden_notes
Remove hidden notes and tag a CERN if detected.
harvestingkit/inspire_cds_package/from_inspire.py
def update_hidden_notes(self): """Remove hidden notes and tag a CERN if detected.""" if not self.tag_as_cern: notes = record_get_field_instances(self.record, tag="595") for field in notes: for dummy, value in field[0]...
def update_hidden_notes(self): """Remove hidden notes and tag a CERN if detected.""" if not self.tag_as_cern: notes = record_get_field_instances(self.record, tag="595") for field in notes: for dummy, value in field[0]...
[ "Remove", "hidden", "notes", "and", "tag", "a", "CERN", "if", "detected", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L257-L266
[ "def", "update_hidden_notes", "(", "self", ")", ":", "if", "not", "self", ".", "tag_as_cern", ":", "notes", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "tag", "=", "\"595\"", ")", "for", "field", "in", "notes", ":", "for", "dummy", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_system_numbers
035 Externals.
harvestingkit/inspire_cds_package/from_inspire.py
def update_system_numbers(self): """035 Externals.""" scn_035_fields = record_get_field_instances(self.record, '035') new_fields = [] for field in scn_035_fields: subs = field_get_subfields(field) if '9' in subs: if subs['9'][0].lower() == "cds" an...
def update_system_numbers(self): """035 Externals.""" scn_035_fields = record_get_field_instances(self.record, '035') new_fields = [] for field in scn_035_fields: subs = field_get_subfields(field) if '9' in subs: if subs['9'][0].lower() == "cds" an...
[ "035", "Externals", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L268-L282
[ "def", "update_system_numbers", "(", "self", ")", ":", "scn_035_fields", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'035'", ")", "new_fields", "=", "[", "]", "for", "field", "in", "scn_035_fields", ":", "subs", "=", "field_get_subfields...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_collections
Try to determine which collections this record should belong to.
harvestingkit/inspire_cds_package/from_inspire.py
def update_collections(self): """Try to determine which collections this record should belong to.""" for value in record_get_field_values(self.record, '980', code='a'): if 'NOTE' in value.upper(): self.collections.add('NOTE') if 'THESIS' in value.upper(): ...
def update_collections(self): """Try to determine which collections this record should belong to.""" for value in record_get_field_values(self.record, '980', code='a'): if 'NOTE' in value.upper(): self.collections.add('NOTE') if 'THESIS' in value.upper(): ...
[ "Try", "to", "determine", "which", "collections", "this", "record", "should", "belong", "to", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L284-L325
[ "def", "update_collections", "(", "self", ")", ":", "for", "value", "in", "record_get_field_values", "(", "self", ".", "record", ",", "'980'", ",", "code", "=", "'a'", ")", ":", "if", "'NOTE'", "in", "value", ".", "upper", "(", ")", ":", "self", ".", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_notes
Remove INSPIRE specific notes.
harvestingkit/inspire_cds_package/from_inspire.py
def update_notes(self): """Remove INSPIRE specific notes.""" fields = record_get_field_instances(self.record, '500') for field in fields: subs = field_get_subfields(field) for sub in subs.get('a', []): sub = sub.strip() # remove any spaces before/after ...
def update_notes(self): """Remove INSPIRE specific notes.""" fields = record_get_field_instances(self.record, '500') for field in fields: subs = field_get_subfields(field) for sub in subs.get('a', []): sub = sub.strip() # remove any spaces before/after ...
[ "Remove", "INSPIRE", "specific", "notes", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L327-L336
[ "def", "update_notes", "(", "self", ")", ":", "fields", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'500'", ")", "for", "field", "in", "fields", ":", "subs", "=", "field_get_subfields", "(", "field", ")", "for", "sub", "in", "subs"...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_title_to_proceeding
Move title info from 245 to 111 proceeding style.
harvestingkit/inspire_cds_package/from_inspire.py
def update_title_to_proceeding(self): """Move title info from 245 to 111 proceeding style.""" titles = record_get_field_instances(self.record, tag="245") for title in titles: subs = field_get_subfields(title) new_subs = [] ...
def update_title_to_proceeding(self): """Move title info from 245 to 111 proceeding style.""" titles = record_get_field_instances(self.record, tag="245") for title in titles: subs = field_get_subfields(title) new_subs = [] ...
[ "Move", "title", "info", "from", "245", "to", "111", "proceeding", "style", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L338-L353
[ "def", "update_title_to_proceeding", "(", "self", ")", ":", "titles", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "tag", "=", "\"245\"", ")", "for", "title", "in", "titles", ":", "subs", "=", "field_get_subfields", "(", "title", ")", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_experiments
Experiment mapping.
harvestingkit/inspire_cds_package/from_inspire.py
def update_experiments(self): """Experiment mapping.""" # 693 Remove if 'not applicable' for field in record_get_field_instances(self.record, '693'): subs = field_get_subfields(field) acc_experiment = subs.get("e", []) if not acc_experiment: ac...
def update_experiments(self): """Experiment mapping.""" # 693 Remove if 'not applicable' for field in record_get_field_instances(self.record, '693'): subs = field_get_subfields(field) acc_experiment = subs.get("e", []) if not acc_experiment: ac...
[ "Experiment", "mapping", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L372-L408
[ "def", "update_experiments", "(", "self", ")", ":", "# 693 Remove if 'not applicable'", "for", "field", "in", "record_get_field_instances", "(", "self", ".", "record", ",", "'693'", ")", ":", "subs", "=", "field_get_subfields", "(", "field", ")", "acc_experiment", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_reportnumbers
Update reportnumbers.
harvestingkit/inspire_cds_package/from_inspire.py
def update_reportnumbers(self): """Update reportnumbers.""" report_037_fields = record_get_field_instances(self.record, '037') for field in report_037_fields: subs = field_get_subfields(field) for val in subs.get("a", []): if "arXiv" not in val: ...
def update_reportnumbers(self): """Update reportnumbers.""" report_037_fields = record_get_field_instances(self.record, '037') for field in report_037_fields: subs = field_get_subfields(field) for val in subs.get("a", []): if "arXiv" not in val: ...
[ "Update", "reportnumbers", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L410-L422
[ "def", "update_reportnumbers", "(", "self", ")", ":", "report_037_fields", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'037'", ")", "for", "field", "in", "report_037_fields", ":", "subs", "=", "field_get_subfields", "(", "field", ")", "f...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_authors
100 & 700 punctuate author names.
harvestingkit/inspire_cds_package/from_inspire.py
def update_authors(self): """100 & 700 punctuate author names.""" author_names = record_get_field_instances(self.record, '100') author_names.extend(record_get_field_instances(self.record, '700')) for field in author_names: subs = field_get_subfields(field) for idx...
def update_authors(self): """100 & 700 punctuate author names.""" author_names = record_get_field_instances(self.record, '100') author_names.extend(record_get_field_instances(self.record, '700')) for field in author_names: subs = field_get_subfields(field) for idx...
[ "100", "&", "700", "punctuate", "author", "names", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L424-L436
[ "def", "update_authors", "(", "self", ")", ":", "author_names", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'100'", ")", "author_names", ".", "extend", "(", "record_get_field_instances", "(", "self", ".", "record", ",", "'700'", ")", "...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_isbn
Remove dashes from ISBN.
harvestingkit/inspire_cds_package/from_inspire.py
def update_isbn(self): """Remove dashes from ISBN.""" isbns = record_get_field_instances(self.record, '020') for field in isbns: for idx, (key, value) in enumerate(field[0]): if key == 'a': field[0][idx] = ('a', value.replace("-", "").strip())
def update_isbn(self): """Remove dashes from ISBN.""" isbns = record_get_field_instances(self.record, '020') for field in isbns: for idx, (key, value) in enumerate(field[0]): if key == 'a': field[0][idx] = ('a', value.replace("-", "").strip())
[ "Remove", "dashes", "from", "ISBN", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L438-L444
[ "def", "update_isbn", "(", "self", ")", ":", "isbns", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'020'", ")", "for", "field", "in", "isbns", ":", "for", "idx", ",", "(", "key", ",", "value", ")", "in", "enumerate", "(", "field...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_dois
Remove duplicate BibMatch DOIs.
harvestingkit/inspire_cds_package/from_inspire.py
def update_dois(self): """Remove duplicate BibMatch DOIs.""" dois = record_get_field_instances(self.record, '024', ind1="7") all_dois = {} for field in dois: subs = field_get_subfield_instances(field) subs_dict = dict(subs) if subs_dict.get('a'): ...
def update_dois(self): """Remove duplicate BibMatch DOIs.""" dois = record_get_field_instances(self.record, '024', ind1="7") all_dois = {} for field in dois: subs = field_get_subfield_instances(field) subs_dict = dict(subs) if subs_dict.get('a'): ...
[ "Remove", "duplicate", "BibMatch", "DOIs", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L446-L457
[ "def", "update_dois", "(", "self", ")", ":", "dois", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'024'", ",", "ind1", "=", "\"7\"", ")", "all_dois", "=", "{", "}", "for", "field", "in", "dois", ":", "subs", "=", "field_get_subfie...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_journals
773 journal translations.
harvestingkit/inspire_cds_package/from_inspire.py
def update_journals(self): """773 journal translations.""" for field in record_get_field_instances(self.record, '773'): subs = field_get_subfield_instances(field) new_subs = [] volume_letter = "" journal_name = "" for idx, (key, value) in enume...
def update_journals(self): """773 journal translations.""" for field in record_get_field_instances(self.record, '773'): subs = field_get_subfield_instances(field) new_subs = [] volume_letter = "" journal_name = "" for idx, (key, value) in enume...
[ "773", "journal", "translations", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L459-L489
[ "def", "update_journals", "(", "self", ")", ":", "for", "field", "in", "record_get_field_instances", "(", "self", ".", "record", ",", "'773'", ")", ":", "subs", "=", "field_get_subfield_instances", "(", "field", ")", "new_subs", "=", "[", "]", "volume_letter",...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_thesis_supervisors
700 -> 701 Thesis supervisors.
harvestingkit/inspire_cds_package/from_inspire.py
def update_thesis_supervisors(self): """700 -> 701 Thesis supervisors.""" for field in record_get_field_instances(self.record, '701'): subs = list(field[0]) subs.append(("e", "dir.")) record_add_field(self.record, '700', subfields=subs) record_delete_fields(se...
def update_thesis_supervisors(self): """700 -> 701 Thesis supervisors.""" for field in record_get_field_instances(self.record, '701'): subs = list(field[0]) subs.append(("e", "dir.")) record_add_field(self.record, '700', subfields=subs) record_delete_fields(se...
[ "700", "-", ">", "701", "Thesis", "supervisors", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L491-L497
[ "def", "update_thesis_supervisors", "(", "self", ")", ":", "for", "field", "in", "record_get_field_instances", "(", "self", ".", "record", ",", "'701'", ")", ":", "subs", "=", "list", "(", "field", "[", "0", "]", ")", "subs", ".", "append", "(", "(", "...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_thesis_information
501 degree info - move subfields.
harvestingkit/inspire_cds_package/from_inspire.py
def update_thesis_information(self): """501 degree info - move subfields.""" fields_501 = record_get_field_instances(self.record, '502') for field in fields_501: new_subs = [] for key, value in field[0]: if key == 'b': new_subs.append((...
def update_thesis_information(self): """501 degree info - move subfields.""" fields_501 = record_get_field_instances(self.record, '502') for field in fields_501: new_subs = [] for key, value in field[0]: if key == 'b': new_subs.append((...
[ "501", "degree", "info", "-", "move", "subfields", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L499-L515
[ "def", "update_thesis_information", "(", "self", ")", ":", "fields_501", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'502'", ")", "for", "field", "in", "fields_501", ":", "new_subs", "=", "[", "]", "for", "key", ",", "value", "in", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_pagenumber
300 page number.
harvestingkit/inspire_cds_package/from_inspire.py
def update_pagenumber(self): """300 page number.""" pages = record_get_field_instances(self.record, '300') for field in pages: for idx, (key, value) in enumerate(field[0]): if key == 'a': field[0][idx] = ('a', "{0} p".format(value))
def update_pagenumber(self): """300 page number.""" pages = record_get_field_instances(self.record, '300') for field in pages: for idx, (key, value) in enumerate(field[0]): if key == 'a': field[0][idx] = ('a', "{0} p".format(value))
[ "300", "page", "number", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L517-L523
[ "def", "update_pagenumber", "(", "self", ")", ":", "pages", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'300'", ")", "for", "field", "in", "pages", ":", "for", "idx", ",", "(", "key", ",", "value", ")", "in", "enumerate", "(", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_date
269 Date normalization.
harvestingkit/inspire_cds_package/from_inspire.py
def update_date(self): """269 Date normalization.""" dates_269 = record_get_field_instances(self.record, '269') for idx, field in enumerate(dates_269): new_subs = [] old_subs = field[0] for code, value in old_subs: if code == "c": ...
def update_date(self): """269 Date normalization.""" dates_269 = record_get_field_instances(self.record, '269') for idx, field in enumerate(dates_269): new_subs = [] old_subs = field[0] for code, value in old_subs: if code == "c": ...
[ "269", "Date", "normalization", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L525-L539
[ "def", "update_date", "(", "self", ")", ":", "dates_269", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'269'", ")", "for", "idx", ",", "field", "in", "enumerate", "(", "dates_269", ")", ":", "new_subs", "=", "[", "]", "old_subs", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_date_year
260 Date normalization.
harvestingkit/inspire_cds_package/from_inspire.py
def update_date_year(self): """260 Date normalization.""" dates = record_get_field_instances(self.record, '260') for field in dates: for idx, (key, value) in enumerate(field[0]): if key == 'c': field[0][idx] = ('c', value[:4]) elif ...
def update_date_year(self): """260 Date normalization.""" dates = record_get_field_instances(self.record, '260') for field in dates: for idx, (key, value) in enumerate(field[0]): if key == 'c': field[0][idx] = ('c', value[:4]) elif ...
[ "260", "Date", "normalization", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L541-L559
[ "def", "update_date_year", "(", "self", ")", ":", "dates", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'260'", ")", "for", "field", "in", "dates", ":", "for", "idx", ",", "(", "key", ",", "value", ")", "in", "enumerate", "(", "...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.is_published
Check fields 980 and 773 to see if the record has already been published. :return: True is published, else False
harvestingkit/inspire_cds_package/from_inspire.py
def is_published(self): """Check fields 980 and 773 to see if the record has already been published. :return: True is published, else False """ field773 = record_get_field_instances(self.record, '773') for f773 in field773: if 'c' in field_get_subfields(f773): ...
def is_published(self): """Check fields 980 and 773 to see if the record has already been published. :return: True is published, else False """ field773 = record_get_field_instances(self.record, '773') for f773 in field773: if 'c' in field_get_subfields(f773): ...
[ "Check", "fields", "980", "and", "773", "to", "see", "if", "the", "record", "has", "already", "been", "published", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L561-L570
[ "def", "is_published", "(", "self", ")", ":", "field773", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'773'", ")", "for", "f773", "in", "field773", ":", "if", "'c'", "in", "field_get_subfields", "(", "f773", ")", ":", "return", "Tr...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_links_and_ffts
FFT (856) Dealing with files.
harvestingkit/inspire_cds_package/from_inspire.py
def update_links_and_ffts(self): """FFT (856) Dealing with files.""" for field in record_get_field_instances(self.record, tag='856', ind1='4'): subs = field_get_subfields(field) newsub...
def update_links_and_ffts(self): """FFT (856) Dealing with files.""" for field in record_get_field_instances(self.record, tag='856', ind1='4'): subs = field_get_subfields(field) newsub...
[ "FFT", "(", "856", ")", "Dealing", "with", "files", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L572-L600
[ "def", "update_links_and_ffts", "(", "self", ")", ":", "for", "field", "in", "record_get_field_instances", "(", "self", ".", "record", ",", "tag", "=", "'856'", ",", "ind1", "=", "'4'", ")", ":", "subs", "=", "field_get_subfields", "(", "field", ")", "news...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
Inspire2CDS.update_languages
041 Language.
harvestingkit/inspire_cds_package/from_inspire.py
def update_languages(self): """041 Language.""" language_fields = record_get_field_instances(self.record, '041') language = "eng" record_delete_fields(self.record, "041") for field in language_fields: subs = field_get_subfields(field) if 'a' in subs: ...
def update_languages(self): """041 Language.""" language_fields = record_get_field_instances(self.record, '041') language = "eng" record_delete_fields(self.record, "041") for field in language_fields: subs = field_get_subfields(field) if 'a' in subs: ...
[ "041", "Language", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L602-L613
[ "def", "update_languages", "(", "self", ")", ":", "language_fields", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'041'", ")", "language", "=", "\"eng\"", "record_delete_fields", "(", "self", ".", "record", ",", "\"041\"", ")", "for", "...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
pathjoin
Arguments: args (list): *args list of paths if len(args) == 1, args[0] is not a string, and args[0] is iterable, set args to args[0]. Basically:: joined_path = u'/'.join( [args[0].rstrip('/')] + [a.strip('/') for a in args[1:-1]] + [args[...
pgs/app.py
def pathjoin(*args, **kwargs): """ Arguments: args (list): *args list of paths if len(args) == 1, args[0] is not a string, and args[0] is iterable, set args to args[0]. Basically:: joined_path = u'/'.join( [args[0].rstrip('/')] + [a.strip('/'...
def pathjoin(*args, **kwargs): """ Arguments: args (list): *args list of paths if len(args) == 1, args[0] is not a string, and args[0] is iterable, set args to args[0]. Basically:: joined_path = u'/'.join( [args[0].rstrip('/')] + [a.strip('/'...
[ "Arguments", ":", "args", "(", "list", ")", ":", "*", "args", "list", "of", "paths", "if", "len", "(", "args", ")", "==", "1", "args", "[", "0", "]", "is", "not", "a", "string", "and", "args", "[", "0", "]", "is", "iterable", "set", "args", "to...
westurner/pgs
python
https://github.com/westurner/pgs/blob/1cc2bf2c41479d8d3ba50480f003183f1675e518/pgs/app.py#L60-L94
[ "def", "pathjoin", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "log", ".", "debug", "(", "'pathjoin: %r'", "%", "list", "(", "args", ")", ")", "def", "_pathjoin", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "len_", "=", "len", ...
1cc2bf2c41479d8d3ba50480f003183f1675e518
valid
generate_dirlist_html
Generate directory listing HTML Arguments: FS (FS): filesystem object to read files from filepath (str): path to generate directory listings for Keyword Arguments: list_dir (callable: list[str]): list file names in a directory isdir (callable: bool): os.path.isdir Yields: ...
pgs/app.py
def generate_dirlist_html(FS, filepath): """ Generate directory listing HTML Arguments: FS (FS): filesystem object to read files from filepath (str): path to generate directory listings for Keyword Arguments: list_dir (callable: list[str]): list file names in a directory ...
def generate_dirlist_html(FS, filepath): """ Generate directory listing HTML Arguments: FS (FS): filesystem object to read files from filepath (str): path to generate directory listings for Keyword Arguments: list_dir (callable: list[str]): list file names in a directory ...
[ "Generate", "directory", "listing", "HTML" ]
westurner/pgs
python
https://github.com/westurner/pgs/blob/1cc2bf2c41479d8d3ba50480f003183f1675e518/pgs/app.py#L386-L410
[ "def", "generate_dirlist_html", "(", "FS", ",", "filepath", ")", ":", "yield", "'<table class=\"dirlist\">'", "if", "filepath", "==", "'/'", ":", "filepath", "=", "''", "for", "name", "in", "FS", ".", "listdir", "(", "filepath", ")", ":", "full_path", "=", ...
1cc2bf2c41479d8d3ba50480f003183f1675e518
valid
git_static_file
This method is derived from bottle.static_file: Open [a file] and return :exc:`HTTPResponse` with status code 200, 305, 403 or 404. The ``Content-Type``, ``Content-Encoding``, ``Content-Length`` and ``Last-Modified`` headers are set if possible. Special support for ``If-Modified-Since``...
pgs/app.py
def git_static_file(filename, mimetype='auto', download=False, charset='UTF-8'): """ This method is derived from bottle.static_file: Open [a file] and return :exc:`HTTPResponse` with status code 200, 305, 403 or 404. The ``Content-Type``, ...
def git_static_file(filename, mimetype='auto', download=False, charset='UTF-8'): """ This method is derived from bottle.static_file: Open [a file] and return :exc:`HTTPResponse` with status code 200, 305, 403 or 404. The ``Content-Type``, ...
[ "This", "method", "is", "derived", "from", "bottle", ".", "static_file", ":" ]
westurner/pgs
python
https://github.com/westurner/pgs/blob/1cc2bf2c41479d8d3ba50480f003183f1675e518/pgs/app.py#L460-L542
[ "def", "git_static_file", "(", "filename", ",", "mimetype", "=", "'auto'", ",", "download", "=", "False", ",", "charset", "=", "'UTF-8'", ")", ":", "# root = os.path.abspath(root) + os.sep", "# filename = os.path.abspath(pathjoin(root, filename.strip('/\\\\')))", "filename", ...
1cc2bf2c41479d8d3ba50480f003183f1675e518
valid
check_pkgs_integrity
Checks if files are not being uploaded to server. @timeout - time after which the script will register an error.
harvestingkit/scoap3utils.py
def check_pkgs_integrity(filelist, logger, ftp_connector, timeout=120, sleep_time=10): """ Checks if files are not being uploaded to server. @timeout - time after which the script will register an error. """ ref_1 = [] ref_2 = [] i = 1 print >> sys.stdout, "\nChe...
def check_pkgs_integrity(filelist, logger, ftp_connector, timeout=120, sleep_time=10): """ Checks if files are not being uploaded to server. @timeout - time after which the script will register an error. """ ref_1 = [] ref_2 = [] i = 1 print >> sys.stdout, "\nChe...
[ "Checks", "if", "files", "are", "not", "being", "uploaded", "to", "server", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/scoap3utils.py#L120-L158
[ "def", "check_pkgs_integrity", "(", "filelist", ",", "logger", ",", "ftp_connector", ",", "timeout", "=", "120", ",", "sleep_time", "=", "10", ")", ":", "ref_1", "=", "[", "]", "ref_2", "=", "[", "]", "i", "=", "1", "print", ">>", "sys", ".", "stdout...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
normalize_query
Example: >>> normalize_query(' some random words "with quotes " and spaces') ['some', 'random', 'words', 'with quotes', 'and', 'spaces']
model_search/lib.py
def normalize_query(query_string, terms=TERMS, norm_space=NORM_SPACE): """ Example: >>> normalize_query(' some random words "with quotes " and spaces') ['some', 'random', 'words', 'with quotes', 'and', 'spaces'] """ return [ norm_space(' ', (t[0] or t[1]).strip()) for t in terms(q...
def normalize_query(query_string, terms=TERMS, norm_space=NORM_SPACE): """ Example: >>> normalize_query(' some random words "with quotes " and spaces') ['some', 'random', 'words', 'with quotes', 'and', 'spaces'] """ return [ norm_space(' ', (t[0] or t[1]).strip()) for t in terms(q...
[ "Example", ":", ">>>", "normalize_query", "(", "some", "random", "words", "with", "quotes", "and", "spaces", ")", "[", "some", "random", "words", "with", "quotes", "and", "spaces", "]" ]
pmaigutyak/mp-search
python
https://github.com/pmaigutyak/mp-search/blob/48d82a335667517f28893a2828101a5bd0b1c64b/model_search/lib.py#L19-L26
[ "def", "normalize_query", "(", "query_string", ",", "terms", "=", "TERMS", ",", "norm_space", "=", "NORM_SPACE", ")", ":", "return", "[", "norm_space", "(", "' '", ",", "(", "t", "[", "0", "]", "or", "t", "[", "1", "]", ")", ".", "strip", "(", ")",...
48d82a335667517f28893a2828101a5bd0b1c64b
valid
collapse_initials
Removes the space between initials. eg T. A. --> T.A.
harvestingkit/scripts/fix_marc_record.py
def collapse_initials(name): """ Removes the space between initials. eg T. A. --> T.A.""" if len(name.split()) > 1: name = re.sub(r'([A-Z]\.) +(?=[A-Z]\.)', r'\1', name) return name
def collapse_initials(name): """ Removes the space between initials. eg T. A. --> T.A.""" if len(name.split()) > 1: name = re.sub(r'([A-Z]\.) +(?=[A-Z]\.)', r'\1', name) return name
[ "Removes", "the", "space", "between", "initials", ".", "eg", "T", ".", "A", ".", "--", ">", "T", ".", "A", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/scripts/fix_marc_record.py#L48-L53
[ "def", "collapse_initials", "(", "name", ")", ":", "if", "len", "(", "name", ".", "split", "(", ")", ")", ">", "1", ":", "name", "=", "re", ".", "sub", "(", "r'([A-Z]\\.) +(?=[A-Z]\\.)'", ",", "r'\\1'", ",", "name", ")", "return", "name" ]
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
fix_name_capitalization
Converts capital letters to lower keeps first letter capital.
harvestingkit/scripts/fix_marc_record.py
def fix_name_capitalization(lastname, givennames): """ Converts capital letters to lower keeps first letter capital. """ lastnames = lastname.split() if len(lastnames) == 1: if '-' in lastname: names = lastname.split('-') names = map(lambda a: a[0] + a[1:].lower(), names) ...
def fix_name_capitalization(lastname, givennames): """ Converts capital letters to lower keeps first letter capital. """ lastnames = lastname.split() if len(lastnames) == 1: if '-' in lastname: names = lastname.split('-') names = map(lambda a: a[0] + a[1:].lower(), names) ...
[ "Converts", "capital", "letters", "to", "lower", "keeps", "first", "letter", "capital", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/scripts/fix_marc_record.py#L56-L82
[ "def", "fix_name_capitalization", "(", "lastname", ",", "givennames", ")", ":", "lastnames", "=", "lastname", ".", "split", "(", ")", "if", "len", "(", "lastnames", ")", "==", "1", ":", "if", "'-'", "in", "lastname", ":", "names", "=", "lastname", ".", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
OEmbedConsumer.extract_oembeds
Scans a block of text and extracts oembed data on any urls, returning it in a list of dictionaries
oembed/consumer.py
def extract_oembeds(self, text, maxwidth=None, maxheight=None, resource_type=None): """ Scans a block of text and extracts oembed data on any urls, returning it in a list of dictionaries """ parser = text_parser() urls = parser.extract_urls(text) return self.handl...
def extract_oembeds(self, text, maxwidth=None, maxheight=None, resource_type=None): """ Scans a block of text and extracts oembed data on any urls, returning it in a list of dictionaries """ parser = text_parser() urls = parser.extract_urls(text) return self.handl...
[ "Scans", "a", "block", "of", "text", "and", "extracts", "oembed", "data", "on", "any", "urls", "returning", "it", "in", "a", "list", "of", "dictionaries" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/consumer.py#L30-L37
[ "def", "extract_oembeds", "(", "self", ",", "text", ",", "maxwidth", "=", "None", ",", "maxheight", "=", "None", ",", "resource_type", "=", "None", ")", ":", "parser", "=", "text_parser", "(", ")", "urls", "=", "parser", ".", "extract_urls", "(", "text",...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
OEmbedConsumer.strip
Try to maintain parity with what is extracted by extract since strip will most likely be used in conjunction with extract
oembed/consumer.py
def strip(self, text, *args, **kwargs): """ Try to maintain parity with what is extracted by extract since strip will most likely be used in conjunction with extract """ if OEMBED_DEFAULT_PARSE_HTML: extracted = self.extract_oembeds_html(text, *args, **kwargs) ...
def strip(self, text, *args, **kwargs): """ Try to maintain parity with what is extracted by extract since strip will most likely be used in conjunction with extract """ if OEMBED_DEFAULT_PARSE_HTML: extracted = self.extract_oembeds_html(text, *args, **kwargs) ...
[ "Try", "to", "maintain", "parity", "with", "what", "is", "extracted", "by", "extract", "since", "strip", "will", "most", "likely", "be", "used", "in", "conjunction", "with", "extract" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/consumer.py#L60-L73
[ "def", "strip", "(", "self", ",", "text", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "OEMBED_DEFAULT_PARSE_HTML", ":", "extracted", "=", "self", ".", "extract_oembeds_html", "(", "text", ",", "*", "args", ",", "*", "*", "kwargs", ")", ...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
autodiscover
Automatically build the provider index.
oembed/__init__.py
def autodiscover(): """ Automatically build the provider index. """ import imp from django.conf import settings for app in settings.INSTALLED_APPS: try: app_path = __import__(app, {}, {}, [app.split('.')[-1]]).__path__ except AttributeError: continue ...
def autodiscover(): """ Automatically build the provider index. """ import imp from django.conf import settings for app in settings.INSTALLED_APPS: try: app_path = __import__(app, {}, {}, [app.split('.')[-1]]).__path__ except AttributeError: continue ...
[ "Automatically", "build", "the", "provider", "index", "." ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/__init__.py#L12-L30
[ "def", "autodiscover", "(", ")", ":", "import", "imp", "from", "django", ".", "conf", "import", "settings", "for", "app", "in", "settings", ".", "INSTALLED_APPS", ":", "try", ":", "app_path", "=", "__import__", "(", "app", ",", "{", "}", ",", "{", "}",...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
select
pass in a list of options, promt the user to select one, and return the selected option or None
pyselect.py
def select(options=None): """ pass in a list of options, promt the user to select one, and return the selected option or None """ if not options: return None width = len(str(len(options))) for x,option in enumerate(options): sys.stdout.write('{:{width}}) {}\n'.format(x+1,option, width=wi...
def select(options=None): """ pass in a list of options, promt the user to select one, and return the selected option or None """ if not options: return None width = len(str(len(options))) for x,option in enumerate(options): sys.stdout.write('{:{width}}) {}\n'.format(x+1,option, width=wi...
[ "pass", "in", "a", "list", "of", "options", "promt", "the", "user", "to", "select", "one", "and", "return", "the", "selected", "option", "or", "None" ]
askedrelic/pyselect
python
https://github.com/askedrelic/pyselect/blob/2f68e3e87e3c44e9d96e1506ba98f9c3a30ded2c/pyselect.py#L11-L46
[ "def", "select", "(", "options", "=", "None", ")", ":", "if", "not", "options", ":", "return", "None", "width", "=", "len", "(", "str", "(", "len", "(", "options", ")", ")", ")", "for", "x", ",", "option", "in", "enumerate", "(", "options", ")", ...
2f68e3e87e3c44e9d96e1506ba98f9c3a30ded2c
valid
main
Transforms the argparse arguments from Namespace to dict and then to Bunch Therefore it is not necessary to access the arguments using the dict syntax The settings can be called like regular vars on the settings object
harvestingkit/harvestingkit_cli.py
def main(): argparser = ArgumentParser() subparsers = argparser.add_subparsers(dest='selected_subparser') all_parser = subparsers.add_parser('all') elsevier_parser = subparsers.add_parser('elsevier') oxford_parser = subparsers.add_parser('oxford') springer_parser = subparsers.add_parser('sprin...
def main(): argparser = ArgumentParser() subparsers = argparser.add_subparsers(dest='selected_subparser') all_parser = subparsers.add_parser('all') elsevier_parser = subparsers.add_parser('elsevier') oxford_parser = subparsers.add_parser('oxford') springer_parser = subparsers.add_parser('sprin...
[ "Transforms", "the", "argparse", "arguments", "from", "Namespace", "to", "dict", "and", "then", "to", "Bunch", "Therefore", "it", "is", "not", "necessary", "to", "access", "the", "arguments", "using", "the", "dict", "syntax", "The", "settings", "can", "be", ...
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/harvestingkit_cli.py#L119-L157
[ "def", "main", "(", ")", ":", "argparser", "=", "ArgumentParser", "(", ")", "subparsers", "=", "argparser", ".", "add_subparsers", "(", "dest", "=", "'selected_subparser'", ")", "all_parser", "=", "subparsers", ".", "add_parser", "(", "'all'", ")", "elsevier_p...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
PosPackage.get_record
Reads a dom xml element in oaidc format and returns the bibrecord object
harvestingkit/pos_package.py
def get_record(self, record): """ Reads a dom xml element in oaidc format and returns the bibrecord object """ self.document = record rec = create_record() language = self._get_language() if language and language != 'en': record_add_field(rec, '041', subfi...
def get_record(self, record): """ Reads a dom xml element in oaidc format and returns the bibrecord object """ self.document = record rec = create_record() language = self._get_language() if language and language != 'en': record_add_field(rec, '041', subfi...
[ "Reads", "a", "dom", "xml", "element", "in", "oaidc", "format", "and", "returns", "the", "bibrecord", "object" ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/pos_package.py#L117-L166
[ "def", "get_record", "(", "self", ",", "record", ")", ":", "self", ".", "document", "=", "record", "rec", "=", "create_record", "(", ")", "language", "=", "self", ".", "_get_language", "(", ")", "if", "language", "and", "language", "!=", "'en'", ":", "...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
progress
display a progress that can update in place example -- total_length = 1000 with echo.progress(total_length) as p: for x in range(total_length): # do something crazy p.update(x) length -- int -- the total size of what you will be updating progress on
captain/echo.py
def progress(length, **kwargs): """display a progress that can update in place example -- total_length = 1000 with echo.progress(total_length) as p: for x in range(total_length): # do something crazy p.update(x) length -- int -- the total size o...
def progress(length, **kwargs): """display a progress that can update in place example -- total_length = 1000 with echo.progress(total_length) as p: for x in range(total_length): # do something crazy p.update(x) length -- int -- the total size o...
[ "display", "a", "progress", "that", "can", "update", "in", "place" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/echo.py#L101-L122
[ "def", "progress", "(", "length", ",", "*", "*", "kwargs", ")", ":", "quiet", "=", "False", "progress_class", "=", "kwargs", ".", "pop", "(", "\"progress_class\"", ",", "Progress", ")", "kwargs", "[", "\"write_method\"", "]", "=", "istdout", ".", "info", ...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
increment
Similar to enumerate but will set format_msg.format(n) into the prefix on each iteration :Example: for v in increment(["foo", "bar"]): echo.out(v) # 1. foo\n2. bar :param itr: iterator, any iterator you want to set a numeric prefix on on every iteration :param n: integer, t...
captain/echo.py
def increment(itr, n=1, format_msg="{}. "): """Similar to enumerate but will set format_msg.format(n) into the prefix on each iteration :Example: for v in increment(["foo", "bar"]): echo.out(v) # 1. foo\n2. bar :param itr: iterator, any iterator you want to set a numeric prefix on ...
def increment(itr, n=1, format_msg="{}. "): """Similar to enumerate but will set format_msg.format(n) into the prefix on each iteration :Example: for v in increment(["foo", "bar"]): echo.out(v) # 1. foo\n2. bar :param itr: iterator, any iterator you want to set a numeric prefix on ...
[ "Similar", "to", "enumerate", "but", "will", "set", "format_msg", ".", "format", "(", "n", ")", "into", "the", "prefix", "on", "each", "iteration" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/echo.py#L141-L158
[ "def", "increment", "(", "itr", ",", "n", "=", "1", ",", "format_msg", "=", "\"{}. \"", ")", ":", "for", "i", ",", "v", "in", "enumerate", "(", "itr", ",", "n", ")", ":", "with", "prefix", "(", "format_msg", ",", "i", ")", ":", "yield", "v" ]
4297f32961d423a10d0f053bc252e29fbe939a47
valid
err
print format_msg to stderr
captain/echo.py
def err(format_msg, *args, **kwargs): '''print format_msg to stderr''' exc_info = kwargs.pop("exc_info", False) stderr.warning(str(format_msg).format(*args, **kwargs), exc_info=exc_info)
def err(format_msg, *args, **kwargs): '''print format_msg to stderr''' exc_info = kwargs.pop("exc_info", False) stderr.warning(str(format_msg).format(*args, **kwargs), exc_info=exc_info)
[ "print", "format_msg", "to", "stderr" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/echo.py#L177-L180
[ "def", "err", "(", "format_msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "exc_info", "=", "kwargs", ".", "pop", "(", "\"exc_info\"", ",", "False", ")", "stderr", ".", "warning", "(", "str", "(", "format_msg", ")", ".", "format", "(", "...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
out
print format_msg to stdout, taking into account --quiet setting
captain/echo.py
def out(format_msg="", *args, **kwargs): '''print format_msg to stdout, taking into account --quiet setting''' logmethod = kwargs.get("logmethod", stdout.info) if format_msg != "": if Prefix.has(): if isinstance(format_msg, basestring): format_msg = Prefix.get() + format...
def out(format_msg="", *args, **kwargs): '''print format_msg to stdout, taking into account --quiet setting''' logmethod = kwargs.get("logmethod", stdout.info) if format_msg != "": if Prefix.has(): if isinstance(format_msg, basestring): format_msg = Prefix.get() + format...
[ "print", "format_msg", "to", "stdout", "taking", "into", "account", "--", "quiet", "setting" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/echo.py#L197-L222
[ "def", "out", "(", "format_msg", "=", "\"\"", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logmethod", "=", "kwargs", ".", "get", "(", "\"logmethod\"", ",", "stdout", ".", "info", ")", "if", "format_msg", "!=", "\"\"", ":", "if", "Prefix", ...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
verbose
print format_msg to stdout, taking into account --verbose flag
captain/echo.py
def verbose(format_msg="", *args, **kwargs): '''print format_msg to stdout, taking into account --verbose flag''' kwargs["logmethod"] = stdout.debug out(format_msg, *args, **kwargs)
def verbose(format_msg="", *args, **kwargs): '''print format_msg to stdout, taking into account --verbose flag''' kwargs["logmethod"] = stdout.debug out(format_msg, *args, **kwargs)
[ "print", "format_msg", "to", "stdout", "taking", "into", "account", "--", "verbose", "flag" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/echo.py#L225-L228
[ "def", "verbose", "(", "format_msg", "=", "\"\"", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "\"logmethod\"", "]", "=", "stdout", ".", "debug", "out", "(", "format_msg", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
4297f32961d423a10d0f053bc252e29fbe939a47
valid
banner
prints a banner sep -- string -- the character that will be on the line on the top and bottom and before any of the lines, defaults to * count -- integer -- the line width, defaults to 80
captain/echo.py
def banner(*lines, **kwargs): """prints a banner sep -- string -- the character that will be on the line on the top and bottom and before any of the lines, defaults to * count -- integer -- the line width, defaults to 80 """ sep = kwargs.get("sep", "*") count = kwargs.get("width", globa...
def banner(*lines, **kwargs): """prints a banner sep -- string -- the character that will be on the line on the top and bottom and before any of the lines, defaults to * count -- integer -- the line width, defaults to 80 """ sep = kwargs.get("sep", "*") count = kwargs.get("width", globa...
[ "prints", "a", "banner" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/echo.py#L321-L339
[ "def", "banner", "(", "*", "lines", ",", "*", "*", "kwargs", ")", ":", "sep", "=", "kwargs", ".", "get", "(", "\"sep\"", ",", "\"*\"", ")", "count", "=", "kwargs", ".", "get", "(", "\"width\"", ",", "globals", "(", ")", "[", "\"WIDTH\"", "]", ")"...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
table
format columned data so we can easily print it out on a console, this just takes columns of data and it will format it into properly aligned columns, it's not fancy, but it works for most type of strings that I need it for, like server name lists. other formatting options: http://stackoverflow....
captain/echo.py
def table(*columns, **kwargs): """ format columned data so we can easily print it out on a console, this just takes columns of data and it will format it into properly aligned columns, it's not fancy, but it works for most type of strings that I need it for, like server name lists. other format...
def table(*columns, **kwargs): """ format columned data so we can easily print it out on a console, this just takes columns of data and it will format it into properly aligned columns, it's not fancy, but it works for most type of strings that I need it for, like server name lists. other format...
[ "format", "columned", "data", "so", "we", "can", "easily", "print", "it", "out", "on", "a", "console", "this", "just", "takes", "columns", "of", "data", "and", "it", "will", "format", "it", "into", "properly", "aligned", "columns", "it", "s", "not", "fan...
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/echo.py#L353-L454
[ "def", "table", "(", "*", "columns", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "[", "]", "prefix", "=", "kwargs", ".", "get", "(", "'prefix'", ",", "''", ")", "buf_count", "=", "kwargs", ".", "get", "(", "'buf_count'", ",", "2", ")", "if", ...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
prompt
echo a prompt to the user and wait for an answer question -- string -- the prompt for the user choices -- list -- if given, only exit when prompt matches one of the choices return -- string -- the answer that was given by the user
captain/echo.py
def prompt(question, choices=None): """echo a prompt to the user and wait for an answer question -- string -- the prompt for the user choices -- list -- if given, only exit when prompt matches one of the choices return -- string -- the answer that was given by the user """ if not re.match("\s$...
def prompt(question, choices=None): """echo a prompt to the user and wait for an answer question -- string -- the prompt for the user choices -- list -- if given, only exit when prompt matches one of the choices return -- string -- the answer that was given by the user """ if not re.match("\s$...
[ "echo", "a", "prompt", "to", "the", "user", "and", "wait", "for", "an", "answer" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/echo.py#L458-L479
[ "def", "prompt", "(", "question", ",", "choices", "=", "None", ")", ":", "if", "not", "re", ".", "match", "(", "\"\\s$\"", ",", "question", ")", ":", "question", "=", "\"{}: \"", ".", "format", "(", "question", ")", "while", "True", ":", "if", "sys",...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
SpringerCrawler.get_records
Returns the records listed in the webpage given as parameter as a xml String. @param url: the url of the Journal, Book, Protocol or Reference work
harvestingkit/springer_crawler.py
def get_records(self, url): """ Returns the records listed in the webpage given as parameter as a xml String. @param url: the url of the Journal, Book, Protocol or Reference work """ page = urllib2.urlopen(url) pages = [BeautifulSoup(page)] #content sprea...
def get_records(self, url): """ Returns the records listed in the webpage given as parameter as a xml String. @param url: the url of the Journal, Book, Protocol or Reference work """ page = urllib2.urlopen(url) pages = [BeautifulSoup(page)] #content sprea...
[ "Returns", "the", "records", "listed", "in", "the", "webpage", "given", "as", "parameter", "as", "a", "xml", "String", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/springer_crawler.py#L55-L82
[ "def", "get_records", "(", "self", ",", "url", ")", ":", "page", "=", "urllib2", ".", "urlopen", "(", "url", ")", "pages", "=", "[", "BeautifulSoup", "(", "page", ")", "]", "#content spread over several pages?", "numpag", "=", "pages", "[", "0", "]", "."...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
inject_quiet
see --quiet flag help for what this does
captain/logging.py
def inject_quiet(levels): """see --quiet flag help for what this does""" loggers = list(Logger.manager.loggerDict.items()) loggers.append(("root", getLogger())) level_filter = LevelFilter(levels) for logger_name, logger in loggers: for handler in getattr(logger, "handlers", []): ...
def inject_quiet(levels): """see --quiet flag help for what this does""" loggers = list(Logger.manager.loggerDict.items()) loggers.append(("root", getLogger())) level_filter = LevelFilter(levels) for logger_name, logger in loggers: for handler in getattr(logger, "handlers", []): ...
[ "see", "--", "quiet", "flag", "help", "for", "what", "this", "does" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/logging.py#L55-L63
[ "def", "inject_quiet", "(", "levels", ")", ":", "loggers", "=", "list", "(", "Logger", ".", "manager", ".", "loggerDict", ".", "items", "(", ")", ")", "loggers", ".", "append", "(", "(", "\"root\"", ",", "getLogger", "(", ")", ")", ")", "level_filter",...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
OxfordPackage.connect
Logs into the specified ftp server and returns connector.
harvestingkit/oup_package.py
def connect(self): """Logs into the specified ftp server and returns connector.""" for tried_connection_count in range(CFG_FTP_CONNECTION_ATTEMPTS): try: self.ftp = FtpHandler(self.config.OXFORD.URL, self.config.OXFORD.LOGIN, ...
def connect(self): """Logs into the specified ftp server and returns connector.""" for tried_connection_count in range(CFG_FTP_CONNECTION_ATTEMPTS): try: self.ftp = FtpHandler(self.config.OXFORD.URL, self.config.OXFORD.LOGIN, ...
[ "Logs", "into", "the", "specified", "ftp", "server", "and", "returns", "connector", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/oup_package.py#L79-L101
[ "def", "connect", "(", "self", ")", ":", "for", "tried_connection_count", "in", "range", "(", "CFG_FTP_CONNECTION_ATTEMPTS", ")", ":", "try", ":", "self", ".", "ftp", "=", "FtpHandler", "(", "self", ".", "config", ".", "OXFORD", ".", "URL", ",", "self", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
OxfordPackage._extract_packages
Extract a package in a new directory.
harvestingkit/oup_package.py
def _extract_packages(self): """ Extract a package in a new directory. """ if not hasattr(self, "retrieved_packages_unpacked"): self.retrieved_packages_unpacked = [self.package_name] for path in self.retrieved_packages_unpacked: package_name = basename(pat...
def _extract_packages(self): """ Extract a package in a new directory. """ if not hasattr(self, "retrieved_packages_unpacked"): self.retrieved_packages_unpacked = [self.package_name] for path in self.retrieved_packages_unpacked: package_name = basename(pat...
[ "Extract", "a", "package", "in", "a", "new", "directory", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/oup_package.py#L197-L225
[ "def", "_extract_packages", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"retrieved_packages_unpacked\"", ")", ":", "self", ".", "retrieved_packages_unpacked", "=", "[", "self", ".", "package_name", "]", "for", "path", "in", "self", ".", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
OxfordPackage._crawl_oxford_and_find_main_xml
A package contains several subdirectory corresponding to each article. An article is actually identified by the existence of a main.pdf and a main.xml in a given directory.
harvestingkit/oup_package.py
def _crawl_oxford_and_find_main_xml(self): """ A package contains several subdirectory corresponding to each article. An article is actually identified by the existence of a main.pdf and a main.xml in a given directory. """ self.found_articles = [] def visit(arg,...
def _crawl_oxford_and_find_main_xml(self): """ A package contains several subdirectory corresponding to each article. An article is actually identified by the existence of a main.pdf and a main.xml in a given directory. """ self.found_articles = [] def visit(arg,...
[ "A", "package", "contains", "several", "subdirectory", "corresponding", "to", "each", "article", ".", "An", "article", "is", "actually", "identified", "by", "the", "existence", "of", "a", "main", ".", "pdf", "and", "a", "main", ".", "xml", "in", "a", "give...
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/oup_package.py#L227-L252
[ "def", "_crawl_oxford_and_find_main_xml", "(", "self", ")", ":", "self", ".", "found_articles", "=", "[", "]", "def", "visit", "(", "arg", ",", "dirname", ",", "names", ")", ":", "files", "=", "[", "filename", "for", "filename", "in", "names", "if", "\"....
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
NuHeatThermostat.get_data
Fetch/refresh the current instance's data from the NuHeat API
nuheat/thermostat.py
def get_data(self): """ Fetch/refresh the current instance's data from the NuHeat API """ params = { "serialnumber": self.serial_number } data = self._session.request(config.THERMOSTAT_URL, params=params) self._data = data self.heating = data...
def get_data(self): """ Fetch/refresh the current instance's data from the NuHeat API """ params = { "serialnumber": self.serial_number } data = self._session.request(config.THERMOSTAT_URL, params=params) self._data = data self.heating = data...
[ "Fetch", "/", "refresh", "the", "current", "instance", "s", "data", "from", "the", "NuHeat", "API" ]
broox/python-nuheat
python
https://github.com/broox/python-nuheat/blob/3a18852dc9465c34cb96eb3a0c84f1a6caa70707/nuheat/thermostat.py#L133-L152
[ "def", "get_data", "(", "self", ")", ":", "params", "=", "{", "\"serialnumber\"", ":", "self", ".", "serial_number", "}", "data", "=", "self", ".", "_session", ".", "request", "(", "config", ".", "THERMOSTAT_URL", ",", "params", "=", "params", ")", "self...
3a18852dc9465c34cb96eb3a0c84f1a6caa70707
valid
NuHeatThermostat.schedule_mode
Set the thermostat mode :param mode: The desired mode integer value. Auto = 1 Temporary hold = 2 Permanent hold = 3
nuheat/thermostat.py
def schedule_mode(self, mode): """ Set the thermostat mode :param mode: The desired mode integer value. Auto = 1 Temporary hold = 2 Permanent hold = 3 """ modes = [config.SCHEDULE_RUN, config.SCHEDULE_TEMPORARY_HOLD,...
def schedule_mode(self, mode): """ Set the thermostat mode :param mode: The desired mode integer value. Auto = 1 Temporary hold = 2 Permanent hold = 3 """ modes = [config.SCHEDULE_RUN, config.SCHEDULE_TEMPORARY_HOLD,...
[ "Set", "the", "thermostat", "mode" ]
broox/python-nuheat
python
https://github.com/broox/python-nuheat/blob/3a18852dc9465c34cb96eb3a0c84f1a6caa70707/nuheat/thermostat.py#L162-L175
[ "def", "schedule_mode", "(", "self", ",", "mode", ")", ":", "modes", "=", "[", "config", ".", "SCHEDULE_RUN", ",", "config", ".", "SCHEDULE_TEMPORARY_HOLD", ",", "config", ".", "SCHEDULE_HOLD", "]", "if", "mode", "not", "in", "modes", ":", "raise", "Except...
3a18852dc9465c34cb96eb3a0c84f1a6caa70707
valid
NuHeatThermostat.set_target_fahrenheit
Set the target temperature to the desired fahrenheit, with more granular control of the hold mode :param fahrenheit: The desired temperature in F :param mode: The desired mode to operate in
nuheat/thermostat.py
def set_target_fahrenheit(self, fahrenheit, mode=config.SCHEDULE_HOLD): """ Set the target temperature to the desired fahrenheit, with more granular control of the hold mode :param fahrenheit: The desired temperature in F :param mode: The desired mode to operate in """ ...
def set_target_fahrenheit(self, fahrenheit, mode=config.SCHEDULE_HOLD): """ Set the target temperature to the desired fahrenheit, with more granular control of the hold mode :param fahrenheit: The desired temperature in F :param mode: The desired mode to operate in """ ...
[ "Set", "the", "target", "temperature", "to", "the", "desired", "fahrenheit", "with", "more", "granular", "control", "of", "the", "hold", "mode" ]
broox/python-nuheat
python
https://github.com/broox/python-nuheat/blob/3a18852dc9465c34cb96eb3a0c84f1a6caa70707/nuheat/thermostat.py#L183-L192
[ "def", "set_target_fahrenheit", "(", "self", ",", "fahrenheit", ",", "mode", "=", "config", ".", "SCHEDULE_HOLD", ")", ":", "temperature", "=", "fahrenheit_to_nuheat", "(", "fahrenheit", ")", "self", ".", "set_target_temperature", "(", "temperature", ",", "mode", ...
3a18852dc9465c34cb96eb3a0c84f1a6caa70707
valid
NuHeatThermostat.set_target_celsius
Set the target temperature to the desired celsius, with more granular control of the hold mode :param celsius: The desired temperature in C :param mode: The desired mode to operate in
nuheat/thermostat.py
def set_target_celsius(self, celsius, mode=config.SCHEDULE_HOLD): """ Set the target temperature to the desired celsius, with more granular control of the hold mode :param celsius: The desired temperature in C :param mode: The desired mode to operate in """ tempe...
def set_target_celsius(self, celsius, mode=config.SCHEDULE_HOLD): """ Set the target temperature to the desired celsius, with more granular control of the hold mode :param celsius: The desired temperature in C :param mode: The desired mode to operate in """ tempe...
[ "Set", "the", "target", "temperature", "to", "the", "desired", "celsius", "with", "more", "granular", "control", "of", "the", "hold", "mode" ]
broox/python-nuheat
python
https://github.com/broox/python-nuheat/blob/3a18852dc9465c34cb96eb3a0c84f1a6caa70707/nuheat/thermostat.py#L194-L203
[ "def", "set_target_celsius", "(", "self", ",", "celsius", ",", "mode", "=", "config", ".", "SCHEDULE_HOLD", ")", ":", "temperature", "=", "celsius_to_nuheat", "(", "celsius", ")", "self", ".", "set_target_temperature", "(", "temperature", ",", "mode", ")" ]
3a18852dc9465c34cb96eb3a0c84f1a6caa70707
valid
NuHeatThermostat.set_target_temperature
Updates the target temperature on the NuHeat API :param temperature: The desired temperature in NuHeat format :param permanent: Permanently hold the temperature. If set to False, the schedule will resume at the next programmed event
nuheat/thermostat.py
def set_target_temperature(self, temperature, mode=config.SCHEDULE_HOLD): """ Updates the target temperature on the NuHeat API :param temperature: The desired temperature in NuHeat format :param permanent: Permanently hold the temperature. If set to False, the schedule will ...
def set_target_temperature(self, temperature, mode=config.SCHEDULE_HOLD): """ Updates the target temperature on the NuHeat API :param temperature: The desired temperature in NuHeat format :param permanent: Permanently hold the temperature. If set to False, the schedule will ...
[ "Updates", "the", "target", "temperature", "on", "the", "NuHeat", "API" ]
broox/python-nuheat
python
https://github.com/broox/python-nuheat/blob/3a18852dc9465c34cb96eb3a0c84f1a6caa70707/nuheat/thermostat.py#L205-L226
[ "def", "set_target_temperature", "(", "self", ",", "temperature", ",", "mode", "=", "config", ".", "SCHEDULE_HOLD", ")", ":", "if", "temperature", "<", "self", ".", "min_temperature", ":", "temperature", "=", "self", ".", "min_temperature", "if", "temperature", ...
3a18852dc9465c34cb96eb3a0c84f1a6caa70707
valid
NuHeatThermostat.set_data
Update (patch) the current instance's data on the NuHeat API
nuheat/thermostat.py
def set_data(self, post_data): """ Update (patch) the current instance's data on the NuHeat API """ params = { "serialnumber": self.serial_number } self._session.request(config.THERMOSTAT_URL, method="POST", data=post_data, params=params)
def set_data(self, post_data): """ Update (patch) the current instance's data on the NuHeat API """ params = { "serialnumber": self.serial_number } self._session.request(config.THERMOSTAT_URL, method="POST", data=post_data, params=params)
[ "Update", "(", "patch", ")", "the", "current", "instance", "s", "data", "on", "the", "NuHeat", "API" ]
broox/python-nuheat
python
https://github.com/broox/python-nuheat/blob/3a18852dc9465c34cb96eb3a0c84f1a6caa70707/nuheat/thermostat.py#L228-L235
[ "def", "set_data", "(", "self", ",", "post_data", ")", ":", "params", "=", "{", "\"serialnumber\"", ":", "self", ".", "serial_number", "}", "self", ".", "_session", ".", "request", "(", "config", ".", "THERMOSTAT_URL", ",", "method", "=", "\"POST\"", ",", ...
3a18852dc9465c34cb96eb3a0c84f1a6caa70707
valid
load_config
This function returns a Bunch object from the stated config file. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOTE: The values are not evaluated by default. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! filename: The desired...
harvestingkit/configparser.py
def load_config(filename=None, section_option_dict={}): """ This function returns a Bunch object from the stated config file. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOTE: The values are not evaluated by default. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!...
def load_config(filename=None, section_option_dict={}): """ This function returns a Bunch object from the stated config file. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOTE: The values are not evaluated by default. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!...
[ "This", "function", "returns", "a", "Bunch", "object", "from", "the", "stated", "config", "file", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/configparser.py#L35-L83
[ "def", "load_config", "(", "filename", "=", "None", ",", "section_option_dict", "=", "{", "}", ")", ":", "config", "=", "ConfigParser", "(", ")", "config", ".", "read", "(", "filename", ")", "working_dict", "=", "_prepare_working_dict", "(", "config", ",", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
NuHeat.authenticate
Authenticate against the NuHeat API
nuheat/api.py
def authenticate(self): """ Authenticate against the NuHeat API """ if self._session_id: _LOGGER.debug("Using existing NuHeat session") return _LOGGER.debug("Creating NuHeat session") post_data = { "Email": self.username, "...
def authenticate(self): """ Authenticate against the NuHeat API """ if self._session_id: _LOGGER.debug("Using existing NuHeat session") return _LOGGER.debug("Creating NuHeat session") post_data = { "Email": self.username, "...
[ "Authenticate", "against", "the", "NuHeat", "API" ]
broox/python-nuheat
python
https://github.com/broox/python-nuheat/blob/3a18852dc9465c34cb96eb3a0c84f1a6caa70707/nuheat/api.py#L27-L46
[ "def", "authenticate", "(", "self", ")", ":", "if", "self", ".", "_session_id", ":", "_LOGGER", ".", "debug", "(", "\"Using existing NuHeat session\"", ")", "return", "_LOGGER", ".", "debug", "(", "\"Creating NuHeat session\"", ")", "post_data", "=", "{", "\"Ema...
3a18852dc9465c34cb96eb3a0c84f1a6caa70707