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
NuHeat.request
Make a request to the NuHeat API :param url: The URL to request :param method: The type of request to make (GET, POST) :param data: Data to be sent along with POST requests :param params: Querystring parameters :param retry: Attempt to re-authenticate and retry request if necess...
nuheat/api.py
def request(self, url, method="GET", data=None, params=None, retry=True): """ Make a request to the NuHeat API :param url: The URL to request :param method: The type of request to make (GET, POST) :param data: Data to be sent along with POST requests :param params: Query...
def request(self, url, method="GET", data=None, params=None, retry=True): """ Make a request to the NuHeat API :param url: The URL to request :param method: The type of request to make (GET, POST) :param data: Data to be sent along with POST requests :param params: Query...
[ "Make", "a", "request", "to", "the", "NuHeat", "API" ]
broox/python-nuheat
python
https://github.com/broox/python-nuheat/blob/3a18852dc9465c34cb96eb3a0c84f1a6caa70707/nuheat/api.py#L56-L88
[ "def", "request", "(", "self", ",", "url", ",", "method", "=", "\"GET\"", ",", "data", "=", "None", ",", "params", "=", "None", ",", "retry", "=", "True", ")", ":", "headers", "=", "config", ".", "REQUEST_HEADERS", "if", "params", "and", "self", ".",...
3a18852dc9465c34cb96eb3a0c84f1a6caa70707
valid
MathMLParser.handle_starttag
Return representation of html start tag and attributes.
harvestingkit/html_utils.py
def handle_starttag(self, tag, attrs): """Return representation of html start tag and attributes.""" if tag in self.mathml_elements: final_attr = "" for key, value in attrs: final_attr += ' {0}="{1}"'.format(key, value) self.fed.append("<{0}{1}>".forma...
def handle_starttag(self, tag, attrs): """Return representation of html start tag and attributes.""" if tag in self.mathml_elements: final_attr = "" for key, value in attrs: final_attr += ' {0}="{1}"'.format(key, value) self.fed.append("<{0}{1}>".forma...
[ "Return", "representation", "of", "html", "start", "tag", "and", "attributes", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/html_utils.py#L64-L70
[ "def", "handle_starttag", "(", "self", ",", "tag", ",", "attrs", ")", ":", "if", "tag", "in", "self", ".", "mathml_elements", ":", "final_attr", "=", "\"\"", "for", "key", ",", "value", "in", "attrs", ":", "final_attr", "+=", "' {0}=\"{1}\"'", ".", "form...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
MathMLParser.handle_endtag
Return representation of html end tag.
harvestingkit/html_utils.py
def handle_endtag(self, tag): """Return representation of html end tag.""" if tag in self.mathml_elements: self.fed.append("</{0}>".format(tag))
def handle_endtag(self, tag): """Return representation of html end tag.""" if tag in self.mathml_elements: self.fed.append("</{0}>".format(tag))
[ "Return", "representation", "of", "html", "end", "tag", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/html_utils.py#L72-L75
[ "def", "handle_endtag", "(", "self", ",", "tag", ")", ":", "if", "tag", "in", "self", ".", "mathml_elements", ":", "self", ".", "fed", ".", "append", "(", "\"</{0}>\"", ".", "format", "(", "tag", ")", ")" ]
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
MathMLParser.html_to_text
Return stripped HTML, keeping only MathML.
harvestingkit/html_utils.py
def html_to_text(cls, html): """Return stripped HTML, keeping only MathML.""" s = cls() s.feed(html) unescaped_data = s.unescape(s.get_data()) return escape_for_xml(unescaped_data, tags_to_keep=s.mathml_elements)
def html_to_text(cls, html): """Return stripped HTML, keeping only MathML.""" s = cls() s.feed(html) unescaped_data = s.unescape(s.get_data()) return escape_for_xml(unescaped_data, tags_to_keep=s.mathml_elements)
[ "Return", "stripped", "HTML", "keeping", "only", "MathML", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/html_utils.py#L90-L95
[ "def", "html_to_text", "(", "cls", ",", "html", ")", ":", "s", "=", "cls", "(", ")", "s", ".", "feed", "(", "html", ")", "unescaped_data", "=", "s", ".", "unescape", "(", "s", ".", "get_data", "(", ")", ")", "return", "escape_for_xml", "(", "unesca...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CallbackInspect.is_instance
return True if callback is an instance of a class
captain/parse.py
def is_instance(self): """return True if callback is an instance of a class""" ret = False val = self.callback if self.is_class(): return False ret = not inspect.isfunction(val) and not inspect.ismethod(val) # if is_py2: # ret = isinstance(val, types.Instance...
def is_instance(self): """return True if callback is an instance of a class""" ret = False val = self.callback if self.is_class(): return False ret = not inspect.isfunction(val) and not inspect.ismethod(val) # if is_py2: # ret = isinstance(val, types.Instance...
[ "return", "True", "if", "callback", "is", "an", "instance", "of", "a", "class" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/parse.py#L97-L111
[ "def", "is_instance", "(", "self", ")", ":", "ret", "=", "False", "val", "=", "self", ".", "callback", "if", "self", ".", "is_class", "(", ")", ":", "return", "False", "ret", "=", "not", "inspect", ".", "isfunction", "(", "val", ")", "and", "not", ...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
CallbackInspect.is_function
return True if callback is a vanilla plain jane function
captain/parse.py
def is_function(self): """return True if callback is a vanilla plain jane function""" if self.is_instance() or self.is_class(): return False return isinstance(self.callback, (Callable, classmethod))
def is_function(self): """return True if callback is a vanilla plain jane function""" if self.is_instance() or self.is_class(): return False return isinstance(self.callback, (Callable, classmethod))
[ "return", "True", "if", "callback", "is", "a", "vanilla", "plain", "jane", "function" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/parse.py#L113-L116
[ "def", "is_function", "(", "self", ")", ":", "if", "self", ".", "is_instance", "(", ")", "or", "self", ".", "is_class", "(", ")", ":", "return", "False", "return", "isinstance", "(", "self", ".", "callback", ",", "(", "Callable", ",", "classmethod", ")...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
ScriptKwarg.merge_kwargs
these kwargs come from the @arg decorator, they are then merged into any keyword arguments that were automatically generated from the main function introspection
captain/parse.py
def merge_kwargs(self, kwargs): """these kwargs come from the @arg decorator, they are then merged into any keyword arguments that were automatically generated from the main function introspection""" if kwargs: self.parser_kwargs.update(kwargs) #self.parser_kwargs['d...
def merge_kwargs(self, kwargs): """these kwargs come from the @arg decorator, they are then merged into any keyword arguments that were automatically generated from the main function introspection""" if kwargs: self.parser_kwargs.update(kwargs) #self.parser_kwargs['d...
[ "these", "kwargs", "come", "from", "the" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/parse.py#L200-L228
[ "def", "merge_kwargs", "(", "self", ",", "kwargs", ")", ":", "if", "kwargs", ":", "self", ".", "parser_kwargs", ".", "update", "(", "kwargs", ")", "#self.parser_kwargs['dest'] = self.name", "self", ".", "parser_kwargs", ".", "setdefault", "(", "'dest'", ",", "...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
ScriptKwarg.merge_from_list
find any matching parser_args from list_args and merge them into this instance list_args -- list -- an array of (args, kwargs) tuples
captain/parse.py
def merge_from_list(self, list_args): """find any matching parser_args from list_args and merge them into this instance list_args -- list -- an array of (args, kwargs) tuples """ def xs(name, parser_args, list_args): """build the generator of matching list_args""" ...
def merge_from_list(self, list_args): """find any matching parser_args from list_args and merge them into this instance list_args -- list -- an array of (args, kwargs) tuples """ def xs(name, parser_args, list_args): """build the generator of matching list_args""" ...
[ "find", "any", "matching", "parser_args", "from", "list_args", "and", "merge", "them", "into", "this", "instance" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/parse.py#L230-L249
[ "def", "merge_from_list", "(", "self", ",", "list_args", ")", ":", "def", "xs", "(", "name", ",", "parser_args", ",", "list_args", ")", ":", "\"\"\"build the generator of matching list_args\"\"\"", "for", "args", ",", "kwargs", "in", "list_args", ":", "if", "len...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
ScriptKwarg.set_default
this is used for introspection from the main() method when there is an argument with a default value, this figures out how to set up the ArgParse arguments
captain/parse.py
def set_default(self, na): """this is used for introspection from the main() method when there is an argument with a default value, this figures out how to set up the ArgParse arguments""" kwargs = {} if isinstance(na, (type, types.FunctionType)): # if foo=some_func t...
def set_default(self, na): """this is used for introspection from the main() method when there is an argument with a default value, this figures out how to set up the ArgParse arguments""" kwargs = {} if isinstance(na, (type, types.FunctionType)): # if foo=some_func t...
[ "this", "is", "used", "for", "introspection", "from", "the", "main", "()", "method", "when", "there", "is", "an", "argument", "with", "a", "default", "value", "this", "figures", "out", "how", "to", "set", "up", "the", "ArgParse", "arguments" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/parse.py#L251-L305
[ "def", "set_default", "(", "self", ",", "na", ")", ":", "kwargs", "=", "{", "}", "if", "isinstance", "(", "na", ",", "(", "type", ",", "types", ".", "FunctionType", ")", ")", ":", "# if foo=some_func then some_func(foo) will be ran if foo is passed in", "kwargs"...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
HelpFormatter._fill_text
Overridden to not get rid of newlines https://github.com/python/cpython/blob/2.7/Lib/argparse.py#L620
captain/parse.py
def _fill_text(self, text, width, indent): """Overridden to not get rid of newlines https://github.com/python/cpython/blob/2.7/Lib/argparse.py#L620""" lines = [] for line in text.splitlines(False): if line: # https://docs.python.org/2/library/textwrap.html ...
def _fill_text(self, text, width, indent): """Overridden to not get rid of newlines https://github.com/python/cpython/blob/2.7/Lib/argparse.py#L620""" lines = [] for line in text.splitlines(False): if line: # https://docs.python.org/2/library/textwrap.html ...
[ "Overridden", "to", "not", "get", "rid", "of", "newlines" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/parse.py#L382-L401
[ "def", "_fill_text", "(", "self", ",", "text", ",", "width", ",", "indent", ")", ":", "lines", "=", "[", "]", "for", "line", "in", "text", ".", "splitlines", "(", "False", ")", ":", "if", "line", ":", "# https://docs.python.org/2/library/textwrap.html", "l...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
ArgParser.parse_callback_args
This is the method that is called from Script.run(), this is the insertion point for parsing all the arguments though on init this will find all args it can, so this method pulls already found args from class variables
captain/parse.py
def parse_callback_args(self, raw_args): """This is the method that is called from Script.run(), this is the insertion point for parsing all the arguments though on init this will find all args it can, so this method pulls already found args from class variables""" args = [] arg_...
def parse_callback_args(self, raw_args): """This is the method that is called from Script.run(), this is the insertion point for parsing all the arguments though on init this will find all args it can, so this method pulls already found args from class variables""" args = [] arg_...
[ "This", "is", "the", "method", "that", "is", "called", "from", "Script", ".", "run", "()", "this", "is", "the", "insertion", "point", "for", "parsing", "all", "the", "arguments", "though", "on", "init", "this", "will", "find", "all", "args", "it", "can",...
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/parse.py#L454-L497
[ "def", "parse_callback_args", "(", "self", ",", "raw_args", ")", ":", "args", "=", "[", "]", "arg_info", "=", "self", ".", "arg_info", "kwargs", "=", "dict", "(", "arg_info", "[", "'optional'", "]", ")", "parsed_args", "=", "[", "]", "unknown_args", "=",...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
ArgParser.find_args
when a new parser is created this is the method that is called from its __init__ method to find all the arguments
captain/parse.py
def find_args(self): """when a new parser is created this is the method that is called from its __init__ method to find all the arguments""" arg_info = self.arg_info main = self.callback cbi = CallbackInspect(main) all_arg_names = set() decorator_args = cbi.args ...
def find_args(self): """when a new parser is created this is the method that is called from its __init__ method to find all the arguments""" arg_info = self.arg_info main = self.callback cbi = CallbackInspect(main) all_arg_names = set() decorator_args = cbi.args ...
[ "when", "a", "new", "parser", "is", "created", "this", "is", "the", "method", "that", "is", "called", "from", "its", "__init__", "method", "to", "find", "all", "the", "arguments" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/parse.py#L503-L589
[ "def", "find_args", "(", "self", ")", ":", "arg_info", "=", "self", ".", "arg_info", "main", "=", "self", ".", "callback", "cbi", "=", "CallbackInspect", "(", "main", ")", "all_arg_names", "=", "set", "(", ")", "decorator_args", "=", "cbi", ".", "args", ...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
Parser.normalize_quiet_arg
This is a hack to allow `--quiet` and `--quiet DI` to work correctly, basically it goes through all arg_strings and if it finds --quiet it checks the next argument to see if it is some combination of DIWEC, if it is then it combines it to `--quiet=ARG` and returns the modified arg_strings list ...
captain/parse.py
def normalize_quiet_arg(self, arg_strings): """This is a hack to allow `--quiet` and `--quiet DI` to work correctly, basically it goes through all arg_strings and if it finds --quiet it checks the next argument to see if it is some combination of DIWEC, if it is then it combines it to `-...
def normalize_quiet_arg(self, arg_strings): """This is a hack to allow `--quiet` and `--quiet DI` to work correctly, basically it goes through all arg_strings and if it finds --quiet it checks the next argument to see if it is some combination of DIWEC, if it is then it combines it to `-...
[ "This", "is", "a", "hack", "to", "allow", "--", "quiet", "and", "--", "quiet", "DI", "to", "work", "correctly", "basically", "it", "goes", "through", "all", "arg_strings", "and", "if", "it", "finds", "--", "quiet", "it", "checks", "the", "next", "argumen...
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/parse.py#L640-L683
[ "def", "normalize_quiet_arg", "(", "self", ",", "arg_strings", ")", ":", "if", "not", "self", ".", "has_injected_quiet", "(", ")", ":", "return", "arg_strings", "action", "=", "self", ".", "_option_string_actions", ".", "get", "(", "self", ".", "quiet_flags", ...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
make_user_agent
create string suitable for HTTP User-Agent header
harvestingkit/utils.py
def make_user_agent(component=None): """ create string suitable for HTTP User-Agent header """ packageinfo = pkg_resources.require("harvestingkit")[0] useragent = "{0}/{1}".format(packageinfo.project_name, packageinfo.version) if component is not None: useragent += " {0}".format(component) r...
def make_user_agent(component=None): """ create string suitable for HTTP User-Agent header """ packageinfo = pkg_resources.require("harvestingkit")[0] useragent = "{0}/{1}".format(packageinfo.project_name, packageinfo.version) if component is not None: useragent += " {0}".format(component) r...
[ "create", "string", "suitable", "for", "HTTP", "User", "-", "Agent", "header" ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L40-L46
[ "def", "make_user_agent", "(", "component", "=", "None", ")", ":", "packageinfo", "=", "pkg_resources", ".", "require", "(", "\"harvestingkit\"", ")", "[", "0", "]", "useragent", "=", "\"{0}/{1}\"", ".", "format", "(", "packageinfo", ".", "project_name", ",", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
record_add_field
Add a MARCXML datafield as a new child to a XML document.
harvestingkit/utils.py
def record_add_field(rec, tag, ind1='', ind2='', subfields=[], controlfield_value=''): """Add a MARCXML datafield as a new child to a XML document.""" if controlfield_value: doc = etree.Element("controlfield", attrib={ "tag...
def record_add_field(rec, tag, ind1='', ind2='', subfields=[], controlfield_value=''): """Add a MARCXML datafield as a new child to a XML document.""" if controlfield_value: doc = etree.Element("controlfield", attrib={ "tag...
[ "Add", "a", "MARCXML", "datafield", "as", "a", "new", "child", "to", "a", "XML", "document", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L54-L74
[ "def", "record_add_field", "(", "rec", ",", "tag", ",", "ind1", "=", "''", ",", "ind2", "=", "''", ",", "subfields", "=", "[", "]", ",", "controlfield_value", "=", "''", ")", ":", "if", "controlfield_value", ":", "doc", "=", "etree", ".", "Element", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
record_xml_output
Given a document, return XML prettified.
harvestingkit/utils.py
def record_xml_output(rec, pretty=True): """Given a document, return XML prettified.""" from .html_utils import MathMLParser ret = etree.tostring(rec, xml_declaration=False) # Special MathML handling ret = re.sub("(&lt;)(([\/]?{0}))".format("|[\/]?".join(MathMLParser.mathml_elements)), '<\g<2>', re...
def record_xml_output(rec, pretty=True): """Given a document, return XML prettified.""" from .html_utils import MathMLParser ret = etree.tostring(rec, xml_declaration=False) # Special MathML handling ret = re.sub("(&lt;)(([\/]?{0}))".format("|[\/]?".join(MathMLParser.mathml_elements)), '<\g<2>', re...
[ "Given", "a", "document", "return", "XML", "prettified", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L77-L92
[ "def", "record_xml_output", "(", "rec", ",", "pretty", "=", "True", ")", ":", "from", ".", "html_utils", "import", "MathMLParser", "ret", "=", "etree", ".", "tostring", "(", "rec", ",", "xml_declaration", "=", "False", ")", "# Special MathML handling", "ret", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
escape_for_xml
Transform & and < to XML valid &amp; and &lt. Pass a list of tags as string to enable replacement of '<' globally but keep any XML tags in the list.
harvestingkit/utils.py
def escape_for_xml(data, tags_to_keep=None): """Transform & and < to XML valid &amp; and &lt. Pass a list of tags as string to enable replacement of '<' globally but keep any XML tags in the list. """ data = re.sub("&", "&amp;", data) if tags_to_keep: data = re.sub(r"(<)(?![\/]?({0})\b)...
def escape_for_xml(data, tags_to_keep=None): """Transform & and < to XML valid &amp; and &lt. Pass a list of tags as string to enable replacement of '<' globally but keep any XML tags in the list. """ data = re.sub("&", "&amp;", data) if tags_to_keep: data = re.sub(r"(<)(?![\/]?({0})\b)...
[ "Transform", "&", "and", "<", "to", "XML", "valid", "&amp", ";", "and", "&lt", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L95-L106
[ "def", "escape_for_xml", "(", "data", ",", "tags_to_keep", "=", "None", ")", ":", "data", "=", "re", ".", "sub", "(", "\"&\"", ",", "\"&amp;\"", ",", "data", ")", "if", "tags_to_keep", ":", "data", "=", "re", ".", "sub", "(", "r\"(<)(?![\\/]?({0})\\b)\""...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
format_arxiv_id
Properly format arXiv IDs.
harvestingkit/utils.py
def format_arxiv_id(arxiv_id): """Properly format arXiv IDs.""" if arxiv_id and "/" not in arxiv_id and "arXiv" not in arxiv_id: return "arXiv:%s" % (arxiv_id,) elif arxiv_id and '.' not in arxiv_id and arxiv_id.lower().startswith('arxiv:'): return arxiv_id[6:] # strip away arxiv: for old i...
def format_arxiv_id(arxiv_id): """Properly format arXiv IDs.""" if arxiv_id and "/" not in arxiv_id and "arXiv" not in arxiv_id: return "arXiv:%s" % (arxiv_id,) elif arxiv_id and '.' not in arxiv_id and arxiv_id.lower().startswith('arxiv:'): return arxiv_id[6:] # strip away arxiv: for old i...
[ "Properly", "format", "arXiv", "IDs", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L138-L145
[ "def", "format_arxiv_id", "(", "arxiv_id", ")", ":", "if", "arxiv_id", "and", "\"/\"", "not", "in", "arxiv_id", "and", "\"arXiv\"", "not", "in", "arxiv_id", ":", "return", "\"arXiv:%s\"", "%", "(", "arxiv_id", ",", ")", "elif", "arxiv_id", "and", "'.'", "n...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
collapse_initials
Remove the space between initials, eg T. A. --> T.A.
harvestingkit/utils.py
def collapse_initials(name): """Remove the space between initials, eg T. A. --> T.A.""" if len(name.split(".")) > 1: name = re.sub(r'([A-Z]\.)[\s\-]+(?=[A-Z]\.)', r'\1', name) return name
def collapse_initials(name): """Remove the space between initials, eg T. A. --> T.A.""" if len(name.split(".")) > 1: name = re.sub(r'([A-Z]\.)[\s\-]+(?=[A-Z]\.)', r'\1', name) return name
[ "Remove", "the", "space", "between", "initials", "eg", "T", ".", "A", ".", "--", ">", "T", ".", "A", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L153-L157
[ "def", "collapse_initials", "(", "name", ")", ":", "if", "len", "(", "name", ".", "split", "(", "\".\"", ")", ")", ">", "1", ":", "name", "=", "re", ".", "sub", "(", "r'([A-Z]\\.)[\\s\\-]+(?=[A-Z]\\.)'", ",", "r'\\1'", ",", "name", ")", "return", "name...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
fix_journal_name
Convert journal name to Inspire's short form.
harvestingkit/utils.py
def fix_journal_name(journal, knowledge_base): """Convert journal name to Inspire's short form.""" if not journal: return '', '' if not knowledge_base: return journal, '' if len(journal) < 2: return journal, '' volume = '' if (journal[-1] <= 'Z' and journal[-1] >= 'A') \ ...
def fix_journal_name(journal, knowledge_base): """Convert journal name to Inspire's short form.""" if not journal: return '', '' if not knowledge_base: return journal, '' if len(journal) < 2: return journal, '' volume = '' if (journal[-1] <= 'Z' and journal[-1] >= 'A') \ ...
[ "Convert", "journal", "name", "to", "Inspire", "s", "short", "form", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L160-L186
[ "def", "fix_journal_name", "(", "journal", ",", "knowledge_base", ")", ":", "if", "not", "journal", ":", "return", "''", ",", "''", "if", "not", "knowledge_base", ":", "return", "journal", ",", "''", "if", "len", "(", "journal", ")", "<", "2", ":", "re...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
add_nations_field
Add correct nations field according to mapping in NATIONS_DEFAULT_MAP.
harvestingkit/utils.py
def add_nations_field(authors_subfields): """Add correct nations field according to mapping in NATIONS_DEFAULT_MAP.""" from .config import NATIONS_DEFAULT_MAP result = [] for field in authors_subfields: if field[0] == 'v': values = [x.replace('.', '') for x in field[1].split(', ')] ...
def add_nations_field(authors_subfields): """Add correct nations field according to mapping in NATIONS_DEFAULT_MAP.""" from .config import NATIONS_DEFAULT_MAP result = [] for field in authors_subfields: if field[0] == 'v': values = [x.replace('.', '') for x in field[1].split(', ')] ...
[ "Add", "correct", "nations", "field", "according", "to", "mapping", "in", "NATIONS_DEFAULT_MAP", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L189-L210
[ "def", "add_nations_field", "(", "authors_subfields", ")", ":", "from", ".", "config", "import", "NATIONS_DEFAULT_MAP", "result", "=", "[", "]", "for", "field", "in", "authors_subfields", ":", "if", "field", "[", "0", "]", "==", "'v'", ":", "values", "=", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
fix_dashes
Fix bad Unicode special dashes in string.
harvestingkit/utils.py
def fix_dashes(string): """Fix bad Unicode special dashes in string.""" string = string.replace(u'\u05BE', '-') string = string.replace(u'\u1806', '-') string = string.replace(u'\u2E3A', '-') string = string.replace(u'\u2E3B', '-') string = unidecode(string) return re.sub(r'--+', '-', string...
def fix_dashes(string): """Fix bad Unicode special dashes in string.""" string = string.replace(u'\u05BE', '-') string = string.replace(u'\u1806', '-') string = string.replace(u'\u2E3A', '-') string = string.replace(u'\u2E3B', '-') string = unidecode(string) return re.sub(r'--+', '-', string...
[ "Fix", "bad", "Unicode", "special", "dashes", "in", "string", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L213-L220
[ "def", "fix_dashes", "(", "string", ")", ":", "string", "=", "string", ".", "replace", "(", "u'\\u05BE'", ",", "'-'", ")", "string", "=", "string", ".", "replace", "(", "u'\\u1806'", ",", "'-'", ")", "string", "=", "string", ".", "replace", "(", "u'\\u...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
fix_title_capitalization
Try to capitalize properly a title string.
harvestingkit/utils.py
def fix_title_capitalization(title): """Try to capitalize properly a title string.""" if re.search("[A-Z]", title) and re.search("[a-z]", title): return title word_list = re.split(' +', title) final = [word_list[0].capitalize()] for word in word_list[1:]: if word.upper() in COMMON_AC...
def fix_title_capitalization(title): """Try to capitalize properly a title string.""" if re.search("[A-Z]", title) and re.search("[a-z]", title): return title word_list = re.split(' +', title) final = [word_list[0].capitalize()] for word in word_list[1:]: if word.upper() in COMMON_AC...
[ "Try", "to", "capitalize", "properly", "a", "title", "string", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L223-L236
[ "def", "fix_title_capitalization", "(", "title", ")", ":", "if", "re", ".", "search", "(", "\"[A-Z]\"", ",", "title", ")", "and", "re", ".", "search", "(", "\"[a-z]\"", ",", "title", ")", ":", "return", "title", "word_list", "=", "re", ".", "split", "(...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
convert_html_subscripts_to_latex
Convert some HTML tags to latex equivalents.
harvestingkit/utils.py
def convert_html_subscripts_to_latex(text): """Convert some HTML tags to latex equivalents.""" text = re.sub("<sub>(.*?)</sub>", r"$_{\1}$", text) text = re.sub("<sup>(.*?)</sup>", r"$^{\1}$", text) return text
def convert_html_subscripts_to_latex(text): """Convert some HTML tags to latex equivalents.""" text = re.sub("<sub>(.*?)</sub>", r"$_{\1}$", text) text = re.sub("<sup>(.*?)</sup>", r"$^{\1}$", text) return text
[ "Convert", "some", "HTML", "tags", "to", "latex", "equivalents", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L239-L243
[ "def", "convert_html_subscripts_to_latex", "(", "text", ")", ":", "text", "=", "re", ".", "sub", "(", "\"<sub>(.*?)</sub>\"", ",", "r\"$_{\\1}$\"", ",", "text", ")", "text", "=", "re", ".", "sub", "(", "\"<sup>(.*?)</sup>\"", ",", "r\"$^{\\1}$\"", ",", "text",...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
download_file
Download URL to a file.
harvestingkit/utils.py
def download_file(from_url, to_filename=None, chunk_size=1024 * 8, retry_count=3): """Download URL to a file.""" if not to_filename: to_filename = get_temporary_file() session = requests.Session() adapter = requests.adapters.HTTPAdapter(max_retries=retry_count) session.mou...
def download_file(from_url, to_filename=None, chunk_size=1024 * 8, retry_count=3): """Download URL to a file.""" if not to_filename: to_filename = get_temporary_file() session = requests.Session() adapter = requests.adapters.HTTPAdapter(max_retries=retry_count) session.mou...
[ "Download", "URL", "to", "a", "file", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L246-L259
[ "def", "download_file", "(", "from_url", ",", "to_filename", "=", "None", ",", "chunk_size", "=", "1024", "*", "8", ",", "retry_count", "=", "3", ")", ":", "if", "not", "to_filename", ":", "to_filename", "=", "get_temporary_file", "(", ")", "session", "=",...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
run_shell_command
Run a shell command.
harvestingkit/utils.py
def run_shell_command(commands, **kwargs): """Run a shell command.""" p = subprocess.Popen(commands, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs) output, error = p.communicate() return p.returncode, output, error
def run_shell_command(commands, **kwargs): """Run a shell command.""" p = subprocess.Popen(commands, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs) output, error = p.communicate() return p.returncode, output, error
[ "Run", "a", "shell", "command", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L262-L269
[ "def", "run_shell_command", "(", "commands", ",", "*", "*", "kwargs", ")", ":", "p", "=", "subprocess", ".", "Popen", "(", "commands", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "subprocess", ".", "PIPE", ",", "*", "*", "kwargs"...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
create_logger
Create a logger object.
harvestingkit/utils.py
def create_logger(name, filename=None, logging_level=logging.DEBUG): """Create a logger object.""" logger = logging.getLogger(name) formatter = logging.Formatter(('%(asctime)s - %(name)s - ' '%(levelname)-8s - %(message)s')) if file...
def create_logger(name, filename=None, logging_level=logging.DEBUG): """Create a logger object.""" logger = logging.getLogger(name) formatter = logging.Formatter(('%(asctime)s - %(name)s - ' '%(levelname)-8s - %(message)s')) if file...
[ "Create", "a", "logger", "object", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L272-L291
[ "def", "create_logger", "(", "name", ",", "filename", "=", "None", ",", "logging_level", "=", "logging", ".", "DEBUG", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "name", ")", "formatter", "=", "logging", ".", "Formatter", "(", "(", "'%(as...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
unzip
Uncompress a zipped file from given filepath to an (optional) location. If no location is given, a temporary folder will be generated inside CFG_TMPDIR, prefixed with "apsharvest_unzip_".
harvestingkit/utils.py
def unzip(zipped_file, output_directory=None, prefix="harvestingkit_unzip_", suffix=""): """Uncompress a zipped file from given filepath to an (optional) location. If no location is given, a temporary folder will be generated inside CFG_TMPDIR, prefixed with "apsharvest_unzip_". """ if no...
def unzip(zipped_file, output_directory=None, prefix="harvestingkit_unzip_", suffix=""): """Uncompress a zipped file from given filepath to an (optional) location. If no location is given, a temporary folder will be generated inside CFG_TMPDIR, prefixed with "apsharvest_unzip_". """ if no...
[ "Uncompress", "a", "zipped", "file", "from", "given", "filepath", "to", "an", "(", "optional", ")", "location", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L294-L312
[ "def", "unzip", "(", "zipped_file", ",", "output_directory", "=", "None", ",", "prefix", "=", "\"harvestingkit_unzip_\"", ",", "suffix", "=", "\"\"", ")", ":", "if", "not", "output_directory", ":", "# We create a temporary directory to extract our stuff in", "try", ":...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
_do_unzip
Perform the actual uncompression.
harvestingkit/utils.py
def _do_unzip(zipped_file, output_directory): """Perform the actual uncompression.""" z = zipfile.ZipFile(zipped_file) for path in z.namelist(): relative_path = os.path.join(output_directory, path) dirname, dummy = os.path.split(relative_path) try: if relative_path.endswi...
def _do_unzip(zipped_file, output_directory): """Perform the actual uncompression.""" z = zipfile.ZipFile(zipped_file) for path in z.namelist(): relative_path = os.path.join(output_directory, path) dirname, dummy = os.path.split(relative_path) try: if relative_path.endswi...
[ "Perform", "the", "actual", "uncompression", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L315-L333
[ "def", "_do_unzip", "(", "zipped_file", ",", "output_directory", ")", ":", "z", "=", "zipfile", ".", "ZipFile", "(", "zipped_file", ")", "for", "path", "in", "z", ".", "namelist", "(", ")", ":", "relative_path", "=", "os", ".", "path", ".", "join", "("...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
locate
Locate all files matching supplied filename pattern recursively.
harvestingkit/utils.py
def locate(pattern, root=os.curdir): """Locate all files matching supplied filename pattern recursively.""" for path, dummy, files in os.walk(os.path.abspath(root)): for filename in fnmatch.filter(files, pattern): yield os.path.join(path, filename)
def locate(pattern, root=os.curdir): """Locate all files matching supplied filename pattern recursively.""" for path, dummy, files in os.walk(os.path.abspath(root)): for filename in fnmatch.filter(files, pattern): yield os.path.join(path, filename)
[ "Locate", "all", "files", "matching", "supplied", "filename", "pattern", "recursively", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L336-L340
[ "def", "locate", "(", "pattern", ",", "root", "=", "os", ".", "curdir", ")", ":", "for", "path", ",", "dummy", ",", "files", "in", "os", ".", "walk", "(", "os", ".", "path", ".", "abspath", "(", "root", ")", ")", ":", "for", "filename", "in", "...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
punctuate_authorname
Punctuate author names properly. Expects input in the form 'Bloggs, J K' and will return 'Bloggs, J. K.'.
harvestingkit/utils.py
def punctuate_authorname(an): """Punctuate author names properly. Expects input in the form 'Bloggs, J K' and will return 'Bloggs, J. K.'. """ name = an.strip() parts = [x for x in name.split(',') if x != ''] ret_str = '' for idx, part in enumerate(parts): subparts = part.strip().sp...
def punctuate_authorname(an): """Punctuate author names properly. Expects input in the form 'Bloggs, J K' and will return 'Bloggs, J. K.'. """ name = an.strip() parts = [x for x in name.split(',') if x != ''] ret_str = '' for idx, part in enumerate(parts): subparts = part.strip().sp...
[ "Punctuate", "author", "names", "properly", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L343-L361
[ "def", "punctuate_authorname", "(", "an", ")", ":", "name", "=", "an", ".", "strip", "(", ")", "parts", "=", "[", "x", "for", "x", "in", "name", ".", "split", "(", "','", ")", "if", "x", "!=", "''", "]", "ret_str", "=", "''", "for", "idx", ",",...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
convert_date_to_iso
Convert a date-value to the ISO date standard.
harvestingkit/utils.py
def convert_date_to_iso(value): """Convert a date-value to the ISO date standard.""" date_formats = ["%d %b %Y", "%Y/%m/%d"] for dformat in date_formats: try: date = datetime.strptime(value, dformat) return date.strftime("%Y-%m-%d") except ValueError: pass...
def convert_date_to_iso(value): """Convert a date-value to the ISO date standard.""" date_formats = ["%d %b %Y", "%Y/%m/%d"] for dformat in date_formats: try: date = datetime.strptime(value, dformat) return date.strftime("%Y-%m-%d") except ValueError: pass...
[ "Convert", "a", "date", "-", "value", "to", "the", "ISO", "date", "standard", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L364-L373
[ "def", "convert_date_to_iso", "(", "value", ")", ":", "date_formats", "=", "[", "\"%d %b %Y\"", ",", "\"%Y/%m/%d\"", "]", "for", "dformat", "in", "date_formats", ":", "try", ":", "date", "=", "datetime", ".", "strptime", "(", "value", ",", "dformat", ")", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
convert_date_from_iso_to_human
Convert a date-value to the ISO date standard for humans.
harvestingkit/utils.py
def convert_date_from_iso_to_human(value): """Convert a date-value to the ISO date standard for humans.""" try: year, month, day = value.split("-") except ValueError: # Not separated by "-". Space? try: year, month, day = value.split(" ") except ValueError: ...
def convert_date_from_iso_to_human(value): """Convert a date-value to the ISO date standard for humans.""" try: year, month, day = value.split("-") except ValueError: # Not separated by "-". Space? try: year, month, day = value.split(" ") except ValueError: ...
[ "Convert", "a", "date", "-", "value", "to", "the", "ISO", "date", "standard", "for", "humans", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L376-L392
[ "def", "convert_date_from_iso_to_human", "(", "value", ")", ":", "try", ":", "year", ",", "month", ",", "day", "=", "value", ".", "split", "(", "\"-\"", ")", "except", "ValueError", ":", "# Not separated by \"-\". Space?", "try", ":", "year", ",", "month", "...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
convert_images
Convert list of images to PNG format. @param: image_list ([string, string, ...]): the list of image files extracted from the tarball in step 1 @return: image_list ([str, str, ...]): The list of image files when all have been converted to PNG format.
harvestingkit/utils.py
def convert_images(image_list): """Convert list of images to PNG format. @param: image_list ([string, string, ...]): the list of image files extracted from the tarball in step 1 @return: image_list ([str, str, ...]): The list of image files when all have been converted to PNG format. "...
def convert_images(image_list): """Convert list of images to PNG format. @param: image_list ([string, string, ...]): the list of image files extracted from the tarball in step 1 @return: image_list ([str, str, ...]): The list of image files when all have been converted to PNG format. "...
[ "Convert", "list", "of", "images", "to", "PNG", "format", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L425-L455
[ "def", "convert_images", "(", "image_list", ")", ":", "png_output_contains", "=", "'PNG image'", "ret_list", "=", "[", "]", "for", "image_file", "in", "image_list", ":", "if", "os", ".", "path", ".", "isdir", "(", "image_file", ")", ":", "continue", "dummy1"...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
get_temporary_file
Generate a safe and closed filepath.
harvestingkit/utils.py
def get_temporary_file(prefix="tmp_", suffix="", directory=None): """Generate a safe and closed filepath.""" try: file_fd, filepath = mkstemp(prefix=prefix, suffix=suffix, dir=directory)...
def get_temporary_file(prefix="tmp_", suffix="", directory=None): """Generate a safe and closed filepath.""" try: file_fd, filepath = mkstemp(prefix=prefix, suffix=suffix, dir=directory)...
[ "Generate", "a", "safe", "and", "closed", "filepath", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L458-L473
[ "def", "get_temporary_file", "(", "prefix", "=", "\"tmp_\"", ",", "suffix", "=", "\"\"", ",", "directory", "=", "None", ")", ":", "try", ":", "file_fd", ",", "filepath", "=", "mkstemp", "(", "prefix", "=", "prefix", ",", "suffix", "=", "suffix", ",", "...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
return_letters_from_string
Get letters from string only.
harvestingkit/utils.py
def return_letters_from_string(text): """Get letters from string only.""" out = "" for letter in text: if letter.isalpha(): out += letter return out
def return_letters_from_string(text): """Get letters from string only.""" out = "" for letter in text: if letter.isalpha(): out += letter return out
[ "Get", "letters", "from", "string", "only", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L476-L482
[ "def", "return_letters_from_string", "(", "text", ")", ":", "out", "=", "\"\"", "for", "letter", "in", "text", ":", "if", "letter", ".", "isalpha", "(", ")", ":", "out", "+=", "letter", "return", "out" ]
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
license_is_oa
Return True if license is compatible with Open Access
harvestingkit/utils.py
def license_is_oa(license): """Return True if license is compatible with Open Access""" for oal in OA_LICENSES: if re.search(oal, license): return True return False
def license_is_oa(license): """Return True if license is compatible with Open Access""" for oal in OA_LICENSES: if re.search(oal, license): return True return False
[ "Return", "True", "if", "license", "is", "compatible", "with", "Open", "Access" ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L484-L489
[ "def", "license_is_oa", "(", "license", ")", ":", "for", "oal", "in", "OA_LICENSES", ":", "if", "re", ".", "search", "(", "oal", ",", "license", ")", ":", "return", "True", "return", "False" ]
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
ElsevierPackage._extract_package
Extract a package in a new temporary directory.
harvestingkit/elsevier_package.py
def _extract_package(self): """ Extract a package in a new temporary directory. """ self.path = mkdtemp(prefix="scoap3_package_", dir=CFG_TMPSHAREDDIR) self.logger.debug("Extracting package: %s" % (self.package_name,)) scoap3utils_extract_package(self.package_name, self.p...
def _extract_package(self): """ Extract a package in a new temporary directory. """ self.path = mkdtemp(prefix="scoap3_package_", dir=CFG_TMPSHAREDDIR) self.logger.debug("Extracting package: %s" % (self.package_name,)) scoap3utils_extract_package(self.package_name, self.p...
[ "Extract", "a", "package", "in", "a", "new", "temporary", "directory", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/elsevier_package.py#L159-L165
[ "def", "_extract_package", "(", "self", ")", ":", "self", ".", "path", "=", "mkdtemp", "(", "prefix", "=", "\"scoap3_package_\"", ",", "dir", "=", "CFG_TMPSHAREDDIR", ")", "self", ".", "logger", ".", "debug", "(", "\"Extracting package: %s\"", "%", "(", "sel...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
ElsevierPackage._crawl_elsevier_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/elsevier_package.py
def _crawl_elsevier_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 = [] if not self.p...
def _crawl_elsevier_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 = [] if not self.p...
[ "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/elsevier_package.py#L167-L192
[ "def", "_crawl_elsevier_and_find_main_xml", "(", "self", ")", ":", "self", ".", "found_articles", "=", "[", "]", "if", "not", "self", ".", "path", "and", "not", "self", ".", "package_name", ":", "for", "doc", "in", "self", ".", "conn", ".", "found_articles...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
ElsevierPackage._crawl_elsevier_and_find_issue_xml
Information about the current volume, issue, etc. is available in a file called issue.xml that is available in a higher directory.
harvestingkit/elsevier_package.py
def _crawl_elsevier_and_find_issue_xml(self): """ Information about the current volume, issue, etc. is available in a file called issue.xml that is available in a higher directory. """ self._found_issues = [] if not self.path and not self.package_name: for iss...
def _crawl_elsevier_and_find_issue_xml(self): """ Information about the current volume, issue, etc. is available in a file called issue.xml that is available in a higher directory. """ self._found_issues = [] if not self.path and not self.package_name: for iss...
[ "Information", "about", "the", "current", "volume", "issue", "etc", ".", "is", "available", "in", "a", "file", "called", "issue", ".", "xml", "that", "is", "available", "in", "a", "higher", "directory", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/elsevier_package.py#L194-L219
[ "def", "_crawl_elsevier_and_find_issue_xml", "(", "self", ")", ":", "self", ".", "_found_issues", "=", "[", "]", "if", "not", "self", ".", "path", "and", "not", "self", ".", "package_name", ":", "for", "issue", "in", "self", ".", "conn", ".", "_get_issues"...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
ElsevierPackage._normalize_issue_dir_with_dtd
issue.xml from Elsevier assume the existence of a local DTD. This procedure install the DTDs next to the issue.xml file and normalize it using xmllint in order to resolve all namespaces and references.
harvestingkit/elsevier_package.py
def _normalize_issue_dir_with_dtd(self, path): """ issue.xml from Elsevier assume the existence of a local DTD. This procedure install the DTDs next to the issue.xml file and normalize it using xmllint in order to resolve all namespaces and references. """ if exis...
def _normalize_issue_dir_with_dtd(self, path): """ issue.xml from Elsevier assume the existence of a local DTD. This procedure install the DTDs next to the issue.xml file and normalize it using xmllint in order to resolve all namespaces and references. """ if exis...
[ "issue", ".", "xml", "from", "Elsevier", "assume", "the", "existence", "of", "a", "local", "DTD", ".", "This", "procedure", "install", "the", "DTDs", "next", "to", "the", "issue", ".", "xml", "file", "and", "normalize", "it", "using", "xmllint", "in", "o...
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/elsevier_package.py#L231-L261
[ "def", "_normalize_issue_dir_with_dtd", "(", "self", ",", "path", ")", ":", "if", "exists", "(", "join", "(", "path", ",", "'resolved_issue.xml'", ")", ")", ":", "return", "issue_xml_content", "=", "open", "(", "join", "(", "path", ",", "'issue.xml'", ")", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
ElsevierPackage._normalize_article_dir_with_dtd
main.xml from Elsevier assume the existence of a local DTD. This procedure install the DTDs next to the main.xml file and normalize it using xmllint in order to resolve all namespaces and references.
harvestingkit/elsevier_package.py
def _normalize_article_dir_with_dtd(self, path): """ main.xml from Elsevier assume the existence of a local DTD. This procedure install the DTDs next to the main.xml file and normalize it using xmllint in order to resolve all namespaces and references. """ if exis...
def _normalize_article_dir_with_dtd(self, path): """ main.xml from Elsevier assume the existence of a local DTD. This procedure install the DTDs next to the main.xml file and normalize it using xmllint in order to resolve all namespaces and references. """ if exis...
[ "main", ".", "xml", "from", "Elsevier", "assume", "the", "existence", "of", "a", "local", "DTD", ".", "This", "procedure", "install", "the", "DTDs", "next", "to", "the", "main", ".", "xml", "file", "and", "normalize", "it", "using", "xmllint", "in", "ord...
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/elsevier_package.py#L263-L293
[ "def", "_normalize_article_dir_with_dtd", "(", "self", ",", "path", ")", ":", "if", "exists", "(", "join", "(", "path", ",", "'resolved_main.xml'", ")", ")", ":", "return", "main_xml_content", "=", "open", "(", "join", "(", "path", ",", "'main.xml'", ")", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
ElsevierPackage.get_publication_date
Return the best effort start_date.
harvestingkit/elsevier_package.py
def get_publication_date(self, xml_doc): """Return the best effort start_date.""" start_date = get_value_in_tag(xml_doc, "prism:coverDate") if not start_date: start_date = get_value_in_tag(xml_doc, "prism:coverDisplayDate") if not start_date: start_date = ...
def get_publication_date(self, xml_doc): """Return the best effort start_date.""" start_date = get_value_in_tag(xml_doc, "prism:coverDate") if not start_date: start_date = get_value_in_tag(xml_doc, "prism:coverDisplayDate") if not start_date: start_date = ...
[ "Return", "the", "best", "effort", "start_date", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/elsevier_package.py#L632-L665
[ "def", "get_publication_date", "(", "self", ",", "xml_doc", ")", ":", "start_date", "=", "get_value_in_tag", "(", "xml_doc", ",", "\"prism:coverDate\"", ")", "if", "not", "start_date", ":", "start_date", "=", "get_value_in_tag", "(", "xml_doc", ",", "\"prism:cover...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
ElsevierPackage.get_record
Convert a record to MARCXML format. :param path: path to a record. :type path: string :param test: flag to determine if it is a test call. :type test: bool :param refextract_callback: callback to be used to extract unstructured references. It ...
harvestingkit/elsevier_package.py
def get_record(self, path=None, no_pdf=False, test=False, refextract_callback=None): """Convert a record to MARCXML format. :param path: path to a record. :type path: string :param test: flag to determine if it is a test call. :type test: bool :param r...
def get_record(self, path=None, no_pdf=False, test=False, refextract_callback=None): """Convert a record to MARCXML format. :param path: path to a record. :type path: string :param test: flag to determine if it is a test call. :type test: bool :param r...
[ "Convert", "a", "record", "to", "MARCXML", "format", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/elsevier_package.py#L864-L1083
[ "def", "get_record", "(", "self", ",", "path", "=", "None", ",", "no_pdf", "=", "False", ",", "test", "=", "False", ",", "refextract_callback", "=", "None", ")", ":", "xml_doc", "=", "self", ".", "get_article", "(", "path", ")", "rec", "=", "create_rec...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
extract_oembeds
Extract oembed resources from a block of text. Returns a list of dictionaries. Max width & height can be specified: {% for embed in block_of_text|extract_oembeds:"400x300" %} Resource type can be specified: {% for photo_embed in block_of_text|extract_oembeds:"photo" %} Or both: {% for em...
oembed/templatetags/oembed_tags.py
def extract_oembeds(text, args=None): """ Extract oembed resources from a block of text. Returns a list of dictionaries. Max width & height can be specified: {% for embed in block_of_text|extract_oembeds:"400x300" %} Resource type can be specified: {% for photo_embed in block_of_text|extr...
def extract_oembeds(text, args=None): """ Extract oembed resources from a block of text. Returns a list of dictionaries. Max width & height can be specified: {% for embed in block_of_text|extract_oembeds:"400x300" %} Resource type can be specified: {% for photo_embed in block_of_text|extr...
[ "Extract", "oembed", "resources", "from", "a", "block", "of", "text", ".", "Returns", "a", "list", "of", "dictionaries", "." ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/templatetags/oembed_tags.py#L31-L55
[ "def", "extract_oembeds", "(", "text", ",", "args", "=", "None", ")", ":", "resource_type", "=", "width", "=", "height", "=", "None", "if", "args", ":", "dimensions", "=", "args", ".", "lower", "(", ")", ".", "split", "(", "'x'", ")", "if", "len", ...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
strip_oembeds
Take a block of text and strip all the embeds from it, optionally taking a maxwidth, maxheight / resource_type Usage: {{ post.content|strip_embeds }} {{ post.content|strip_embeds:"600x600xphoto" }} {{ post.content|strip_embeds:"video" }}
oembed/templatetags/oembed_tags.py
def strip_oembeds(text, args=None): """ Take a block of text and strip all the embeds from it, optionally taking a maxwidth, maxheight / resource_type Usage: {{ post.content|strip_embeds }} {{ post.content|strip_embeds:"600x600xphoto" }} {{ post.content|strip_embeds:"video" }}...
def strip_oembeds(text, args=None): """ Take a block of text and strip all the embeds from it, optionally taking a maxwidth, maxheight / resource_type Usage: {{ post.content|strip_embeds }} {{ post.content|strip_embeds:"600x600xphoto" }} {{ post.content|strip_embeds:"video" }}...
[ "Take", "a", "block", "of", "text", "and", "strip", "all", "the", "embeds", "from", "it", "optionally", "taking", "a", "maxwidth", "maxheight", "/", "resource_type", "Usage", ":", "{{", "post", ".", "content|strip_embeds", "}}", "{{", "post", ".", "content|s...
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/templatetags/oembed_tags.py#L59-L81
[ "def", "strip_oembeds", "(", "text", ",", "args", "=", "None", ")", ":", "resource_type", "=", "width", "=", "height", "=", "None", "if", "args", ":", "dimensions", "=", "args", ".", "lower", "(", ")", ".", "split", "(", "'x'", ")", "if", "len", "(...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
do_oembed
A node which parses everything between its two nodes, and replaces any links with OEmbed-provided objects, if possible. Supports two optional argument, which is the maximum width and height, specified like so: {% oembed 640x480 %}http://www.viddler.com/explore/SYSTM/videos/49/{% endoembed %} and ...
oembed/templatetags/oembed_tags.py
def do_oembed(parser, token): """ A node which parses everything between its two nodes, and replaces any links with OEmbed-provided objects, if possible. Supports two optional argument, which is the maximum width and height, specified like so: {% oembed 640x480 %}http://www.viddler.com/explore...
def do_oembed(parser, token): """ A node which parses everything between its two nodes, and replaces any links with OEmbed-provided objects, if possible. Supports two optional argument, which is the maximum width and height, specified like so: {% oembed 640x480 %}http://www.viddler.com/explore...
[ "A", "node", "which", "parses", "everything", "between", "its", "two", "nodes", "and", "replaces", "any", "links", "with", "OEmbed", "-", "provided", "objects", "if", "possible", "." ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/templatetags/oembed_tags.py#L108-L167
[ "def", "do_oembed", "(", "parser", ",", "token", ")", ":", "args", "=", "token", ".", "split_contents", "(", ")", "template_dir", "=", "None", "var_name", "=", "None", "if", "len", "(", "args", ")", ">", "2", ":", "if", "len", "(", "args", ")", "==...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
do_autodiscover
Generates a &lt;link&gt; tag with oembed autodiscovery bits for an object. {% oembed_autodiscover video %}
oembed/templatetags/oembed_tags.py
def do_autodiscover(parser, token): """ Generates a &lt;link&gt; tag with oembed autodiscovery bits for an object. {% oembed_autodiscover video %} """ args = token.split_contents() if len(args) != 2: raise template.TemplateSyntaxError('%s takes an object as its parameter.' % args[0]) ...
def do_autodiscover(parser, token): """ Generates a &lt;link&gt; tag with oembed autodiscovery bits for an object. {% oembed_autodiscover video %} """ args = token.split_contents() if len(args) != 2: raise template.TemplateSyntaxError('%s takes an object as its parameter.' % args[0]) ...
[ "Generates", "a", "&lt", ";", "link&gt", ";", "tag", "with", "oembed", "autodiscovery", "bits", "for", "an", "object", "." ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/templatetags/oembed_tags.py#L188-L199
[ "def", "do_autodiscover", "(", "parser", ",", "token", ")", ":", "args", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "args", ")", "!=", "2", ":", "raise", "template", ".", "TemplateSyntaxError", "(", "'%s takes an object as its parameter.'...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
do_url_scheme
Generates a &lt;link&gt; tag with oembed autodiscovery bits. {% oembed_url_scheme %}
oembed/templatetags/oembed_tags.py
def do_url_scheme(parser, token): """ Generates a &lt;link&gt; tag with oembed autodiscovery bits. {% oembed_url_scheme %} """ args = token.split_contents() if len(args) != 1: raise template.TemplateSyntaxError('%s takes no parameters.' % args[0]) return OEmbedURLSchemeNode()
def do_url_scheme(parser, token): """ Generates a &lt;link&gt; tag with oembed autodiscovery bits. {% oembed_url_scheme %} """ args = token.split_contents() if len(args) != 1: raise template.TemplateSyntaxError('%s takes no parameters.' % args[0]) return OEmbedURLSchemeNode()
[ "Generates", "a", "&lt", ";", "link&gt", ";", "tag", "with", "oembed", "autodiscovery", "bits", "." ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/templatetags/oembed_tags.py#L214-L223
[ "def", "do_url_scheme", "(", "parser", ",", "token", ")", ":", "args", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "args", ")", "!=", "1", ":", "raise", "template", ".", "TemplateSyntaxError", "(", "'%s takes no parameters.'", "%", "ar...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
exit
A stand-in for the normal sys.exit() all the magic happens here, when this is called at the end of a script it will figure out all the available commands and arguments that can be passed in, then handle exiting the script and returning the status code. :Example: from captain import exit ...
captain/__init__.py
def exit(mod_name=""): """A stand-in for the normal sys.exit() all the magic happens here, when this is called at the end of a script it will figure out all the available commands and arguments that can be passed in, then handle exiting the script and returning the status code. :Example: ...
def exit(mod_name=""): """A stand-in for the normal sys.exit() all the magic happens here, when this is called at the end of a script it will figure out all the available commands and arguments that can be passed in, then handle exiting the script and returning the status code. :Example: ...
[ "A", "stand", "-", "in", "for", "the", "normal", "sys", ".", "exit", "()" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/__init__.py#L79-L116
[ "def", "exit", "(", "mod_name", "=", "\"\"", ")", ":", "if", "mod_name", "and", "mod_name", "==", "\"__main__\"", ":", "calling_mod", "=", "sys", ".", "modules", ".", "get", "(", "\"__main__\"", ",", "None", ")", "else", ":", "calling_mod", "=", "discove...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
Script.parser
return the parser for the current name
captain/__init__.py
def parser(self): """return the parser for the current name""" module = self.module subcommands = self.subcommands if subcommands: module_desc = inspect.getdoc(module) parser = Parser(description=module_desc, module=module) subparsers = parser.add_sub...
def parser(self): """return the parser for the current name""" module = self.module subcommands = self.subcommands if subcommands: module_desc = inspect.getdoc(module) parser = Parser(description=module_desc, module=module) subparsers = parser.add_sub...
[ "return", "the", "parser", "for", "the", "current", "name" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/__init__.py#L127-L149
[ "def", "parser", "(", "self", ")", ":", "module", "=", "self", ".", "module", "subcommands", "=", "self", ".", "subcommands", "if", "subcommands", ":", "module_desc", "=", "inspect", ".", "getdoc", "(", "module", ")", "parser", "=", "Parser", "(", "descr...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
Script.module
load the module so we can actually run the script's function
captain/__init__.py
def module(self): """load the module so we can actually run the script's function""" # we have to guard this value because: # https://thingspython.wordpress.com/2010/09/27/another-super-wrinkle-raising-typeerror/ if not hasattr(self, '_module'): if "__main__" in sys.modules: ...
def module(self): """load the module so we can actually run the script's function""" # we have to guard this value because: # https://thingspython.wordpress.com/2010/09/27/another-super-wrinkle-raising-typeerror/ if not hasattr(self, '_module'): if "__main__" in sys.modules: ...
[ "load", "the", "module", "so", "we", "can", "actually", "run", "the", "script", "s", "function" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/__init__.py#L179-L195
[ "def", "module", "(", "self", ")", ":", "# we have to guard this value because:", "# https://thingspython.wordpress.com/2010/09/27/another-super-wrinkle-raising-typeerror/", "if", "not", "hasattr", "(", "self", ",", "'_module'", ")", ":", "if", "\"__main__\"", "in", "sys", ...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
Script.body
get the contents of the script
captain/__init__.py
def body(self): """get the contents of the script""" if not hasattr(self, '_body'): self._body = inspect.getsource(self.module) return self._body
def body(self): """get the contents of the script""" if not hasattr(self, '_body'): self._body = inspect.getsource(self.module) return self._body
[ "get", "the", "contents", "of", "the", "script" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/__init__.py#L198-L202
[ "def", "body", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_body'", ")", ":", "self", ".", "_body", "=", "inspect", ".", "getsource", "(", "self", ".", "module", ")", "return", "self", ".", "_body" ]
4297f32961d423a10d0f053bc252e29fbe939a47
valid
Script.run
parse and import the script, and then run the script's main function
captain/__init__.py
def run(self, raw_args): """parse and import the script, and then run the script's main function""" parser = self.parser args, kwargs = parser.parse_callback_args(raw_args) callback = kwargs.pop("main_callback") if parser.has_injected_quiet(): levels = kwargs.pop("qu...
def run(self, raw_args): """parse and import the script, and then run the script's main function""" parser = self.parser args, kwargs = parser.parse_callback_args(raw_args) callback = kwargs.pop("main_callback") if parser.has_injected_quiet(): levels = kwargs.pop("qu...
[ "parse", "and", "import", "the", "script", "and", "then", "run", "the", "script", "s", "main", "function" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/__init__.py#L229-L248
[ "def", "run", "(", "self", ",", "raw_args", ")", ":", "parser", "=", "self", ".", "parser", "args", ",", "kwargs", "=", "parser", ".", "parse_callback_args", "(", "raw_args", ")", "callback", "=", "kwargs", ".", "pop", "(", "\"main_callback\"", ")", "if"...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
Script.call_path
return that path to be able to call this script from the passed in basename example -- basepath = /foo/bar self.path = /foo/bar/che/baz.py self.call_path(basepath) # che/baz.py basepath -- string -- the directory you would be calling this script in ...
captain/__init__.py
def call_path(self, basepath): """return that path to be able to call this script from the passed in basename example -- basepath = /foo/bar self.path = /foo/bar/che/baz.py self.call_path(basepath) # che/baz.py basepath -- string -- the directory yo...
def call_path(self, basepath): """return that path to be able to call this script from the passed in basename example -- basepath = /foo/bar self.path = /foo/bar/che/baz.py self.call_path(basepath) # che/baz.py basepath -- string -- the directory yo...
[ "return", "that", "path", "to", "be", "able", "to", "call", "this", "script", "from", "the", "passed", "in", "basename" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/__init__.py#L250-L271
[ "def", "call_path", "(", "self", ",", "basepath", ")", ":", "rel_filepath", "=", "self", ".", "path", "if", "basepath", ":", "rel_filepath", "=", "os", ".", "path", ".", "relpath", "(", "self", ".", "path", ",", "basepath", ")", "basename", "=", "self"...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
Script.parse
load the script and set the parser and argument info I feel that this is way too brittle to be used long term, I think it just might be best to import the stupid module, the thing I don't like about that is then we import basically everything, which seems bad?
captain/__init__.py
def parse(self): """load the script and set the parser and argument info I feel that this is way too brittle to be used long term, I think it just might be best to import the stupid module, the thing I don't like about that is then we import basically everything, which seems bad? ...
def parse(self): """load the script and set the parser and argument info I feel that this is way too brittle to be used long term, I think it just might be best to import the stupid module, the thing I don't like about that is then we import basically everything, which seems bad? ...
[ "load", "the", "script", "and", "set", "the", "parser", "and", "argument", "info" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/__init__.py#L273-L327
[ "def", "parse", "(", "self", ")", ":", "if", "self", ".", "parsed", ":", "return", "self", ".", "callbacks", "=", "{", "}", "# search for main and any main_* callable objects", "regex", "=", "re", ".", "compile", "(", "\"^{}_?\"", ".", "format", "(", "self",...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
Script.can_run_from_cli
return True if this script can be run from the command line
captain/__init__.py
def can_run_from_cli(self): """return True if this script can be run from the command line""" ret = False ast_tree = ast.parse(self.body, self.path) calls = self._find_calls(ast_tree, __name__, "exit") for call in calls: if re.search("{}\(".format(re.escape(call)), se...
def can_run_from_cli(self): """return True if this script can be run from the command line""" ret = False ast_tree = ast.parse(self.body, self.path) calls = self._find_calls(ast_tree, __name__, "exit") for call in calls: if re.search("{}\(".format(re.escape(call)), se...
[ "return", "True", "if", "this", "script", "can", "be", "run", "from", "the", "command", "line" ]
Jaymon/captain
python
https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/__init__.py#L329-L339
[ "def", "can_run_from_cli", "(", "self", ")", ":", "ret", "=", "False", "ast_tree", "=", "ast", ".", "parse", "(", "self", ".", "body", ",", "self", ".", "path", ")", "calls", "=", "self", ".", "_find_calls", "(", "ast_tree", ",", "__name__", ",", "\"...
4297f32961d423a10d0f053bc252e29fbe939a47
valid
register_field
Handles registering the fields with the FieldRegistry and creating a post-save signal for the model.
oembed/fields.py
def register_field(cls, field): """ Handles registering the fields with the FieldRegistry and creating a post-save signal for the model. """ FieldRegistry.add_field(cls, field) signals.post_save.connect(handle_save_embeds, sender=cls, dispatch_uid='%s.%s.%s' % \ (cl...
def register_field(cls, field): """ Handles registering the fields with the FieldRegistry and creating a post-save signal for the model. """ FieldRegistry.add_field(cls, field) signals.post_save.connect(handle_save_embeds, sender=cls, dispatch_uid='%s.%s.%s' % \ (cl...
[ "Handles", "registering", "the", "fields", "with", "the", "FieldRegistry", "and", "creating", "a", "post", "-", "save", "signal", "for", "the", "model", "." ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/fields.py#L66-L75
[ "def", "register_field", "(", "cls", ",", "field", ")", ":", "FieldRegistry", ".", "add_field", "(", "cls", ",", "field", ")", "signals", ".", "post_save", ".", "connect", "(", "handle_save_embeds", ",", "sender", "=", "cls", ",", "dispatch_uid", "=", "'%s...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
EmbeddedMediaField.contribute_to_class
I need a way to ensure that this signal gets created for all child models, and since model inheritance doesn't have a 'contrubite_to_class' style hook, I am creating a fake virtual field which will be added to all subclasses and handles creating the signal
oembed/fields.py
def contribute_to_class(self, cls, name): """ I need a way to ensure that this signal gets created for all child models, and since model inheritance doesn't have a 'contrubite_to_class' style hook, I am creating a fake virtual field which will be added to all subclasses and handl...
def contribute_to_class(self, cls, name): """ I need a way to ensure that this signal gets created for all child models, and since model inheritance doesn't have a 'contrubite_to_class' style hook, I am creating a fake virtual field which will be added to all subclasses and handl...
[ "I", "need", "a", "way", "to", "ensure", "that", "this", "signal", "gets", "created", "for", "all", "child", "models", "and", "since", "model", "inheritance", "doesn", "t", "have", "a", "contrubite_to_class", "style", "hook", "I", "am", "creating", "a", "f...
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/fields.py#L52-L63
[ "def", "contribute_to_class", "(", "self", ",", "cls", ",", "name", ")", ":", "super", "(", "EmbeddedMediaField", ",", "self", ")", ".", "contribute_to_class", "(", "cls", ",", "name", ")", "register_field", "(", "cls", ",", "self", ")", "# add a virtual fie...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
BaseParser.render_oembed
Render the oembed resource and return as a string. Template directory will always fall back to 'oembed/[type].html', but a custom template dir can be passed in using the kwargs. Templates are given two context variables: - response: an OEmbedResource - original_...
oembed/parsers/base.py
def render_oembed(self, oembed_resource, original_url, template_dir=None, context=None): """ Render the oembed resource and return as a string. Template directory will always fall back to 'oembed/[type].html', but a custom template dir can be passed in usin...
def render_oembed(self, oembed_resource, original_url, template_dir=None, context=None): """ Render the oembed resource and return as a string. Template directory will always fall back to 'oembed/[type].html', but a custom template dir can be passed in usin...
[ "Render", "the", "oembed", "resource", "and", "return", "as", "a", "string", ".", "Template", "directory", "will", "always", "fall", "back", "to", "oembed", "/", "[", "type", "]", ".", "html", "but", "a", "custom", "template", "dir", "can", "be", "passed...
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/parsers/base.py#L11-L45
[ "def", "render_oembed", "(", "self", ",", "oembed_resource", ",", "original_url", ",", "template_dir", "=", "None", ",", "context", "=", "None", ")", ":", "provided_context", "=", "context", "or", "Context", "(", ")", "context", "=", "RequestContext", "(", "...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
BaseParser.parse
Scans a block of text, replacing anything matching a provider pattern with an OEmbed html snippet, if possible. Templates should be stored at oembed/{format}.html, so for example: oembed/video.html An optional template_dir can be provided, allowing for ...
oembed/parsers/base.py
def parse(self, text, maxwidth=None, maxheight=None, template_dir=None, context=None, urlize_all_links=CONSUMER_URLIZE_ALL): """ Scans a block of text, replacing anything matching a provider pattern with an OEmbed html snippet, if possible. Templates should be stor...
def parse(self, text, maxwidth=None, maxheight=None, template_dir=None, context=None, urlize_all_links=CONSUMER_URLIZE_ALL): """ Scans a block of text, replacing anything matching a provider pattern with an OEmbed html snippet, if possible. Templates should be stor...
[ "Scans", "a", "block", "of", "text", "replacing", "anything", "matching", "a", "provider", "pattern", "with", "an", "OEmbed", "html", "snippet", "if", "possible", ".", "Templates", "should", "be", "stored", "at", "oembed", "/", "{", "format", "}", ".", "ht...
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/parsers/base.py#L47-L74
[ "def", "parse", "(", "self", ",", "text", ",", "maxwidth", "=", "None", ",", "maxheight", "=", "None", ",", "template_dir", "=", "None", ",", "context", "=", "None", ",", "urlize_all_links", "=", "CONSUMER_URLIZE_ALL", ")", ":", "context", "=", "context", ...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
size_to_nearest
Generate some dimensions for resizing an object. This function DOES NOT handle scaling, it simply calculates maximums. These values should then be passed to the resize() method which will scale it and return the scaled width & height.
oembed/utils.py
def size_to_nearest(width=None, height=None, allowed_sizes=OEMBED_ALLOWED_SIZES, force_fit=False): """ Generate some dimensions for resizing an object. This function DOES NOT handle scaling, it simply calculates maximums. These values should then be passed to the resize() method wh...
def size_to_nearest(width=None, height=None, allowed_sizes=OEMBED_ALLOWED_SIZES, force_fit=False): """ Generate some dimensions for resizing an object. This function DOES NOT handle scaling, it simply calculates maximums. These values should then be passed to the resize() method wh...
[ "Generate", "some", "dimensions", "for", "resizing", "an", "object", ".", "This", "function", "DOES", "NOT", "handle", "scaling", "it", "simply", "calculates", "maximums", ".", "These", "values", "should", "then", "be", "passed", "to", "the", "resize", "()", ...
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/utils.py#L13-L62
[ "def", "size_to_nearest", "(", "width", "=", "None", ",", "height", "=", "None", ",", "allowed_sizes", "=", "OEMBED_ALLOWED_SIZES", ",", "force_fit", "=", "False", ")", ":", "minwidth", ",", "minheight", "=", "min", "(", "allowed_sizes", ")", "maxwidth", ","...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
fetch_url
Fetch response headers and data from a URL, raising a generic exception for any kind of failure.
oembed/utils.py
def fetch_url(url, method='GET', user_agent='django-oembed', timeout=SOCKET_TIMEOUT): """ Fetch response headers and data from a URL, raising a generic exception for any kind of failure. """ sock = httplib2.Http(timeout=timeout) request_headers = { 'User-Agent': user_agent, 'Acce...
def fetch_url(url, method='GET', user_agent='django-oembed', timeout=SOCKET_TIMEOUT): """ Fetch response headers and data from a URL, raising a generic exception for any kind of failure. """ sock = httplib2.Http(timeout=timeout) request_headers = { 'User-Agent': user_agent, 'Acce...
[ "Fetch", "response", "headers", "and", "data", "from", "a", "URL", "raising", "a", "generic", "exception", "for", "any", "kind", "of", "failure", "." ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/utils.py#L82-L95
[ "def", "fetch_url", "(", "url", ",", "method", "=", "'GET'", ",", "user_agent", "=", "'django-oembed'", ",", "timeout", "=", "SOCKET_TIMEOUT", ")", ":", "sock", "=", "httplib2", ".", "Http", "(", "timeout", "=", "timeout", ")", "request_headers", "=", "{",...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
relative_to_full
Given a url which may or may not be a relative url, convert it to a full url path given another full url as an example
oembed/utils.py
def relative_to_full(url, example_url): """ Given a url which may or may not be a relative url, convert it to a full url path given another full url as an example """ if re.match('https?:\/\/', url): return url domain = get_domain(example_url) if domain: return '%s%s' % (doma...
def relative_to_full(url, example_url): """ Given a url which may or may not be a relative url, convert it to a full url path given another full url as an example """ if re.match('https?:\/\/', url): return url domain = get_domain(example_url) if domain: return '%s%s' % (doma...
[ "Given", "a", "url", "which", "may", "or", "may", "not", "be", "a", "relative", "url", "convert", "it", "to", "a", "full", "url", "path", "given", "another", "full", "url", "as", "an", "example" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/utils.py#L103-L113
[ "def", "relative_to_full", "(", "url", ",", "example_url", ")", ":", "if", "re", ".", "match", "(", "'https?:\\/\\/'", ",", "url", ")", ":", "return", "url", "domain", "=", "get_domain", "(", "example_url", ")", "if", "domain", ":", "return", "'%s%s'", "...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
mock_request
Generate a fake request object to allow oEmbeds to use context processors.
oembed/utils.py
def mock_request(): """ Generate a fake request object to allow oEmbeds to use context processors. """ current_site = Site.objects.get_current() request = HttpRequest() request.META['SERVER_NAME'] = current_site.domain return request
def mock_request(): """ Generate a fake request object to allow oEmbeds to use context processors. """ current_site = Site.objects.get_current() request = HttpRequest() request.META['SERVER_NAME'] = current_site.domain return request
[ "Generate", "a", "fake", "request", "object", "to", "allow", "oEmbeds", "to", "use", "context", "processors", "." ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/utils.py#L115-L122
[ "def", "mock_request", "(", ")", ":", "current_site", "=", "Site", ".", "objects", ".", "get_current", "(", ")", "request", "=", "HttpRequest", "(", ")", "request", ".", "META", "[", "'SERVER_NAME'", "]", "=", "current_site", ".", "domain", "return", "requ...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
load_class
dynamically load a class given a string of the format package.Class
oembed/utils.py
def load_class(path): """ dynamically load a class given a string of the format package.Class """ package, klass = path.rsplit('.', 1) module = import_module(package) return getattr(module, klass)
def load_class(path): """ dynamically load a class given a string of the format package.Class """ package, klass = path.rsplit('.', 1) module = import_module(package) return getattr(module, klass)
[ "dynamically", "load", "a", "class", "given", "a", "string", "of", "the", "format", "package", ".", "Class" ]
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/utils.py#L124-L132
[ "def", "load_class", "(", "path", ")", ":", "package", ",", "klass", "=", "path", ".", "rsplit", "(", "'.'", ",", "1", ")", "module", "=", "import_module", "(", "package", ")", "return", "getattr", "(", "module", ",", "klass", ")" ]
f3f2be283441d91d1f89db780444dc75f7b51902
valid
cleaned_sites
Create a list of tuples mapping domains from the sites table to their site name. The domains will be cleaned into regexes that may be more permissive than the site domain is in the db. [(domain_regex, domain_name, domain_string), ...]
oembed/utils.py
def cleaned_sites(): """ Create a list of tuples mapping domains from the sites table to their site name. The domains will be cleaned into regexes that may be more permissive than the site domain is in the db. [(domain_regex, domain_name, domain_string), ...] """ mappings = {} for ...
def cleaned_sites(): """ Create a list of tuples mapping domains from the sites table to their site name. The domains will be cleaned into regexes that may be more permissive than the site domain is in the db. [(domain_regex, domain_name, domain_string), ...] """ mappings = {} for ...
[ "Create", "a", "list", "of", "tuples", "mapping", "domains", "from", "the", "sites", "table", "to", "their", "site", "name", ".", "The", "domains", "will", "be", "cleaned", "into", "regexes", "that", "may", "be", "more", "permissive", "than", "the", "site"...
worldcompany/djangoembed
python
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/utils.py#L134-L165
[ "def", "cleaned_sites", "(", ")", ":", "mappings", "=", "{", "}", "for", "site", "in", "Site", ".", "objects", ".", "all", "(", ")", ":", "# match the site domain, breaking it into several pieces", "match", "=", "re", ".", "match", "(", "r'(https?://)?(www[^\\.]...
f3f2be283441d91d1f89db780444dc75f7b51902
valid
EDPSciencesPackage.get_record
Gets the Marc xml of the files in xaml_jp directory :param fileName: the name of the file to parse. :type fileName: string :param refextract_callback: callback to be used to extract unstructured references. It should return...
harvestingkit/edpsciences_package.py
def get_record(self, fileName, ref_extract_callback=None): """ Gets the Marc xml of the files in xaml_jp directory :param fileName: the name of the file to parse. :type fileName: string :param refextract_callback: callback to be used to extract ...
def get_record(self, fileName, ref_extract_callback=None): """ Gets the Marc xml of the files in xaml_jp directory :param fileName: the name of the file to parse. :type fileName: string :param refextract_callback: callback to be used to extract ...
[ "Gets", "the", "Marc", "xml", "of", "the", "files", "in", "xaml_jp", "directory" ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/edpsciences_package.py#L156-L266
[ "def", "get_record", "(", "self", ",", "fileName", ",", "ref_extract_callback", "=", "None", ")", ":", "self", ".", "document", "=", "parse", "(", "fileName", ")", "article_type", "=", "self", ".", "_get_article_type", "(", ")", "if", "article_type", "not", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
EDPSciencesPackage.get_record_rich
Gets the Marc xml of the files in xaml_rich directory :param fileName: the name of the file to parse. :type fileName: string :returns: a string with the marc xml version of the file.
harvestingkit/edpsciences_package.py
def get_record_rich(self, filename, ref_extract_callback=None): """ Gets the Marc xml of the files in xaml_rich directory :param fileName: the name of the file to parse. :type fileName: string :returns: a string with the marc xml version of the file. """ self.do...
def get_record_rich(self, filename, ref_extract_callback=None): """ Gets the Marc xml of the files in xaml_rich directory :param fileName: the name of the file to parse. :type fileName: string :returns: a string with the marc xml version of the file. """ self.do...
[ "Gets", "the", "Marc", "xml", "of", "the", "files", "in", "xaml_rich", "directory" ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/edpsciences_package.py#L268-L440
[ "def", "get_record_rich", "(", "self", ",", "filename", ",", "ref_extract_callback", "=", "None", ")", ":", "self", ".", "document", "=", "parse", "(", "filename", ")", "rec", "=", "create_record", "(", ")", "articles", "=", "self", ".", "document", ".", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.get_record
Override the base get_record.
harvestingkit/inspire_cds_package/from_cds.py
def get_record(self): """Override the base get_record.""" self.update_system_numbers() self.add_systemnumber("CDS") self.fields_list = [ "024", "041", "035", "037", "088", "100", "110", "111", "242", "245", "246", "260", "269", "300", "502", "650", "65...
def get_record(self): """Override the base get_record.""" self.update_system_numbers() self.add_systemnumber("CDS") self.fields_list = [ "024", "041", "035", "037", "088", "100", "110", "111", "242", "245", "246", "260", "269", "300", "502", "650", "65...
[ "Override", "the", "base", "get_record", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L70-L109
[ "def", "get_record", "(", "self", ")", ":", "self", ".", "update_system_numbers", "(", ")", "self", ".", "add_systemnumber", "(", "\"CDS\"", ")", "self", ".", "fields_list", "=", "[", "\"024\"", ",", "\"041\"", ",", "\"035\"", ",", "\"037\"", ",", "\"088\"...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.determine_collections
Try to determine which collections this record should belong to.
harvestingkit/inspire_cds_package/from_cds.py
def determine_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 determine_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_cds.py#L111-L157
[ "def", "determine_collections", "(", "self", ")", ":", "for", "value", "in", "record_get_field_values", "(", "self", ".", "record", ",", "'980'", ",", "code", "=", "'a'", ")", ":", "if", "'NOTE'", "in", "value", ".", "upper", "(", ")", ":", "self", "."...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.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_cds.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 """ field980 = record_get_field_instances(self.record, '980') field773 = record_get_field_instances(self.record, '773') for f980 in...
def is_published(self): """Check fields 980 and 773 to see if the record has already been published. :return: True is published, else False """ field980 = record_get_field_instances(self.record, '980') field773 = record_get_field_instances(self.record, '773') for f980 in...
[ "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_cds.py#L159-L171
[ "def", "is_published", "(", "self", ")", ":", "field980", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'980'", ")", "field773", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'773'", ")", "for", "f980", "in", "fi...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.add_cms_link
Special handling if record is a CMS NOTE.
harvestingkit/inspire_cds_package/from_cds.py
def add_cms_link(self): """Special handling if record is a CMS NOTE.""" intnote = record_get_field_values(self.record, '690', filter_subfield_code="a", filter_subfield_value='INTNOTE') if intnote: val...
def add_cms_link(self): """Special handling if record is a CMS NOTE.""" intnote = record_get_field_values(self.record, '690', filter_subfield_code="a", filter_subfield_value='INTNOTE') if intnote: val...
[ "Special", "handling", "if", "record", "is", "a", "CMS", "NOTE", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L173-L189
[ "def", "add_cms_link", "(", "self", ")", ":", "intnote", "=", "record_get_field_values", "(", "self", ".", "record", ",", "'690'", ",", "filter_subfield_code", "=", "\"a\"", ",", "filter_subfield_value", "=", "'INTNOTE'", ")", "if", "intnote", ":", "val_088", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.update_system_numbers
035 Externals.
harvestingkit/inspire_cds_package/from_cds.py
def update_system_numbers(self): """035 Externals.""" scn_035_fields = record_get_field_instances(self.record, '035') forbidden_values = ["cercer", "inspire", "xx", "cern annual report", ...
def update_system_numbers(self): """035 Externals.""" scn_035_fields = record_get_field_instances(self.record, '035') forbidden_values = ["cercer", "inspire", "xx", "cern annual report", ...
[ "035", "Externals", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L191-L220
[ "def", "update_system_numbers", "(", "self", ")", ":", "scn_035_fields", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'035'", ")", "forbidden_values", "=", "[", "\"cercer\"", ",", "\"inspire\"", ",", "\"xx\"", ",", "\"cern annual report\"", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.update_reportnumbers
Handle reportnumbers.
harvestingkit/inspire_cds_package/from_cds.py
def update_reportnumbers(self): """Handle reportnumbers. """ rep_088_fields = record_get_field_instances(self.record, '088') for field in rep_088_fields: subs = field_get_subfields(field) if '9' in subs: for val in subs['9']: if val.sta...
def update_reportnumbers(self): """Handle reportnumbers. """ rep_088_fields = record_get_field_instances(self.record, '088') for field in rep_088_fields: subs = field_get_subfields(field) if '9' in subs: for val in subs['9']: if val.sta...
[ "Handle", "reportnumbers", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L222-L256
[ "def", "update_reportnumbers", "(", "self", ")", ":", "rep_088_fields", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'088'", ")", "for", "field", "in", "rep_088_fields", ":", "subs", "=", "field_get_subfields", "(", "field", ")", "if", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.update_date
269 Date normalization.
harvestingkit/inspire_cds_package/from_cds.py
def update_date(self): """269 Date normalization.""" for field in record_get_field_instances(self.record, '269'): for idx, (key, value) in enumerate(field[0]): if key == "c": field[0][idx] = ("c", convert_date_to_iso(value)) record_dele...
def update_date(self): """269 Date normalization.""" for field in record_get_field_instances(self.record, '269'): for idx, (key, value) in enumerate(field[0]): if key == "c": field[0][idx] = ("c", convert_date_to_iso(value)) record_dele...
[ "269", "Date", "normalization", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L258-L269
[ "def", "update_date", "(", "self", ")", ":", "for", "field", "in", "record_get_field_instances", "(", "self", ".", "record", ",", "'269'", ")", ":", "for", "idx", ",", "(", "key", ",", "value", ")", "in", "enumerate", "(", "field", "[", "0", "]", ")"...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.update_pagenumber
300 page number.
harvestingkit/inspire_cds_package/from_cds.py
def update_pagenumber(self): """300 page number.""" for field in record_get_field_instances(self.record, '300'): for idx, (key, value) in enumerate(field[0]): if key == 'a': if "mult." not in value and value != " p": field[0][idx] =...
def update_pagenumber(self): """300 page number.""" for field in record_get_field_instances(self.record, '300'): for idx, (key, value) in enumerate(field[0]): if key == 'a': if "mult." not in value and value != " p": field[0][idx] =...
[ "300", "page", "number", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L271-L281
[ "def", "update_pagenumber", "(", "self", ")", ":", "for", "field", "in", "record_get_field_instances", "(", "self", ".", "record", ",", "'300'", ")", ":", "for", "idx", ",", "(", "key", ",", "value", ")", "in", "enumerate", "(", "field", "[", "0", "]",...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.update_authors
100 & 700 punctuate author names.
harvestingkit/inspire_cds_package/from_cds.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) if 'i' ...
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) if 'i' ...
[ "100", "&", "700", "punctuate", "author", "names", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L283-L293
[ "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
CDS2Inspire.update_thesis_supervisors
700 -> 701 Thesis supervisors.
harvestingkit/inspire_cds_package/from_cds.py
def update_thesis_supervisors(self): """700 -> 701 Thesis supervisors.""" for field in record_get_field_instances(self.record, '700'): record_add_field(self.record, '701', subfields=field[0]) record_delete_fields(self.record, '700')
def update_thesis_supervisors(self): """700 -> 701 Thesis supervisors.""" for field in record_get_field_instances(self.record, '700'): record_add_field(self.record, '701', subfields=field[0]) record_delete_fields(self.record, '700')
[ "700", "-", ">", "701", "Thesis", "supervisors", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L295-L299
[ "def", "update_thesis_supervisors", "(", "self", ")", ":", "for", "field", "in", "record_get_field_instances", "(", "self", ".", "record", ",", "'700'", ")", ":", "record_add_field", "(", "self", ".", "record", ",", "'701'", ",", "subfields", "=", "field", "...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.update_thesis_information
501 degree info - move subfields.
harvestingkit/inspire_cds_package/from_cds.py
def update_thesis_information(self): """501 degree info - move subfields.""" fields_501 = record_get_field_instances(self.record, '502') for idx, field in enumerate(fields_501): new_subs = [] for key, value in field[0]: if key == 'a': n...
def update_thesis_information(self): """501 degree info - move subfields.""" fields_501 = record_get_field_instances(self.record, '502') for idx, field in enumerate(fields_501): new_subs = [] for key, value in field[0]: if key == 'a': n...
[ "501", "degree", "info", "-", "move", "subfields", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L301-L315
[ "def", "update_thesis_information", "(", "self", ")", ":", "fields_501", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'502'", ")", "for", "idx", ",", "field", "in", "enumerate", "(", "fields_501", ")", ":", "new_subs", "=", "[", "]", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.update_keywords
653 Free Keywords.
harvestingkit/inspire_cds_package/from_cds.py
def update_keywords(self): """653 Free Keywords.""" for field in record_get_field_instances(self.record, '653', ind1='1'): subs = field_get_subfields(field) new_subs = [] if 'a' in subs: for val in subs['a']: new_subs.extend([('9', ...
def update_keywords(self): """653 Free Keywords.""" for field in record_get_field_instances(self.record, '653', ind1='1'): subs = field_get_subfields(field) new_subs = [] if 'a' in subs: for val in subs['a']: new_subs.extend([('9', ...
[ "653", "Free", "Keywords", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L317-L327
[ "def", "update_keywords", "(", "self", ")", ":", "for", "field", "in", "record_get_field_instances", "(", "self", ".", "record", ",", "'653'", ",", "ind1", "=", "'1'", ")", ":", "subs", "=", "field_get_subfields", "(", "field", ")", "new_subs", "=", "[", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.update_experiments
Experiment mapping.
harvestingkit/inspire_cds_package/from_cds.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) all_subs = subs.get('a', []) + subs.get('e', []) if 'not applicable' in [x.l...
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) all_subs = subs.get('a', []) + subs.get('e', []) if 'not applicable' in [x.l...
[ "Experiment", "mapping", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L329-L354
[ "def", "update_experiments", "(", "self", ")", ":", "# 693 Remove if 'not applicable'", "for", "field", "in", "record_get_field_instances", "(", "self", ".", "record", ",", "'693'", ")", ":", "subs", "=", "field_get_subfields", "(", "field", ")", "all_subs", "=", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.update_collaboration
710 Collaboration.
harvestingkit/inspire_cds_package/from_cds.py
def update_collaboration(self): """710 Collaboration.""" for field in record_get_field_instances(self.record, '710'): subs = field_get_subfield_instances(field) for idx, (key, value) in enumerate(subs[:]): if key == '5': subs.pop(idx) ...
def update_collaboration(self): """710 Collaboration.""" for field in record_get_field_instances(self.record, '710'): subs = field_get_subfield_instances(field) for idx, (key, value) in enumerate(subs[:]): if key == '5': subs.pop(idx) ...
[ "710", "Collaboration", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L356-L368
[ "def", "update_collaboration", "(", "self", ")", ":", "for", "field", "in", "record_get_field_instances", "(", "self", ".", "record", ",", "'710'", ")", ":", "subs", "=", "field_get_subfield_instances", "(", "field", ")", "for", "idx", ",", "(", "key", ",", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.update_journals
773 journal translations.
harvestingkit/inspire_cds_package/from_cds.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 = [] for idx, (key, value) in enumerate(subs): if key == 'p': ...
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 = [] for idx, (key, value) in enumerate(subs): if key == 'p': ...
[ "773", "journal", "translations", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L370-L384
[ "def", "update_journals", "(", "self", ")", ":", "for", "field", "in", "record_get_field_instances", "(", "self", ".", "record", ",", "'773'", ")", ":", "subs", "=", "field_get_subfield_instances", "(", "field", ")", "new_subs", "=", "[", "]", "for", "idx", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
CDS2Inspire.update_links_and_ffts
FFT (856) Dealing with graphs.
harvestingkit/inspire_cds_package/from_cds.py
def update_links_and_ffts(self): """FFT (856) Dealing with graphs.""" figure_counter = 0 for field in record_get_field_instances(self.record, tag='856', ind1='4'): subs = field_get_subfiel...
def update_links_and_ffts(self): """FFT (856) Dealing with graphs.""" figure_counter = 0 for field in record_get_field_instances(self.record, tag='856', ind1='4'): subs = field_get_subfiel...
[ "FFT", "(", "856", ")", "Dealing", "with", "graphs", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L386-L500
[ "def", "update_links_and_ffts", "(", "self", ")", ":", "figure_counter", "=", "0", "for", "field", "in", "record_get_field_instances", "(", "self", ".", "record", ",", "tag", "=", "'856'", ",", "ind1", "=", "'4'", ")", ":", "subs", "=", "field_get_subfields"...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
SpringerPackage._extract_packages
Extract a package in a new directory.
harvestingkit/springer_package.py
def _extract_packages(self): """ Extract a package in a new directory. """ self.path_unpacked = [] if not hasattr(self, "retrieved_packages_unpacked"): self.retrieved_packages_unpacked = [self.package_name] for path in self.retrieved_packages_unpacked: ...
def _extract_packages(self): """ Extract a package in a new directory. """ self.path_unpacked = [] if not hasattr(self, "retrieved_packages_unpacked"): self.retrieved_packages_unpacked = [self.package_name] for path in self.retrieved_packages_unpacked: ...
[ "Extract", "a", "package", "in", "a", "new", "directory", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/springer_package.py#L208-L232
[ "def", "_extract_packages", "(", "self", ")", ":", "self", ".", "path_unpacked", "=", "[", "]", "if", "not", "hasattr", "(", "self", ",", "\"retrieved_packages_unpacked\"", ")", ":", "self", ".", "retrieved_packages_unpacked", "=", "[", "self", ".", "package_n...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
SpringerPackage._crawl_springer_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/springer_package.py
def _crawl_springer_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(ar...
def _crawl_springer_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(ar...
[ "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/springer_package.py#L234-L261
[ "def", "_crawl_springer_and_find_main_xml", "(", "self", ")", ":", "self", ".", "found_articles", "=", "[", "]", "def", "visit", "(", "arg", ",", "dirname", ",", "names", ")", ":", "files", "=", "[", "filename", "for", "filename", "in", "names", "if", "\...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
SpringerPackage._normalize_article_dir_with_dtd
TODO: main.xml from Springer assume the existence of a local DTD. This procedure install the DTDs next to the main.xml file and normalize it using xmllint in order to resolve all namespaces and references.
harvestingkit/springer_package.py
def _normalize_article_dir_with_dtd(self, path): """ TODO: main.xml from Springer assume the existence of a local DTD. This procedure install the DTDs next to the main.xml file and normalize it using xmllint in order to resolve all namespaces and references. """ f...
def _normalize_article_dir_with_dtd(self, path): """ TODO: main.xml from Springer assume the existence of a local DTD. This procedure install the DTDs next to the main.xml file and normalize it using xmllint in order to resolve all namespaces and references. """ f...
[ "TODO", ":", "main", ".", "xml", "from", "Springer", "assume", "the", "existence", "of", "a", "local", "DTD", ".", "This", "procedure", "install", "the", "DTDs", "next", "to", "the", "main", ".", "xml", "file", "and", "normalize", "it", "using", "xmllint...
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/springer_package.py#L263-L303
[ "def", "_normalize_article_dir_with_dtd", "(", "self", ",", "path", ")", ":", "files", "=", "[", "filename", "for", "filename", "in", "listdir", "(", "path", ")", "if", "\"nlm.xml\"", "in", "filename", "]", "if", "not", "files", ":", "files", "=", "[", "...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
add_all_filters
Add (register) all filters to Pelican.
minchin/pelican/jinja_filters/__init__.py
def add_all_filters(pelican): """Add (register) all filters to Pelican.""" pelican.env.filters.update({'datetime': filters.datetime}) pelican.env.filters.update({'article_date': filters.article_date}) pelican.env.filters.update({'breaking_spaces': filters.breaking_spaces}) pelican.env.filters.update...
def add_all_filters(pelican): """Add (register) all filters to Pelican.""" pelican.env.filters.update({'datetime': filters.datetime}) pelican.env.filters.update({'article_date': filters.article_date}) pelican.env.filters.update({'breaking_spaces': filters.breaking_spaces}) pelican.env.filters.update...
[ "Add", "(", "register", ")", "all", "filters", "to", "Pelican", "." ]
MinchinWeb/minchin.pelican.jinja_filters
python
https://github.com/MinchinWeb/minchin.pelican.jinja_filters/blob/94b8b1dd04be49950d660fe11d28f0df0fe49664/minchin/pelican/jinja_filters/__init__.py#L50-L55
[ "def", "add_all_filters", "(", "pelican", ")", ":", "pelican", ".", "env", ".", "filters", ".", "update", "(", "{", "'datetime'", ":", "filters", ".", "datetime", "}", ")", "pelican", ".", "env", ".", "filters", ".", "update", "(", "{", "'article_date'",...
94b8b1dd04be49950d660fe11d28f0df0fe49664
valid
create_field
Return a field created with the provided elements. Global position is set arbitrary to -1.
harvestingkit/bibrecord.py
def create_field(subfields=None, ind1=' ', ind2=' ', controlfield_value='', global_position=-1): """ Return a field created with the provided elements. Global position is set arbitrary to -1. """ if subfields is None: subfields = [] ind1, ind2 = _wash_indicators(ind1, ...
def create_field(subfields=None, ind1=' ', ind2=' ', controlfield_value='', global_position=-1): """ Return a field created with the provided elements. Global position is set arbitrary to -1. """ if subfields is None: subfields = [] ind1, ind2 = _wash_indicators(ind1, ...
[ "Return", "a", "field", "created", "with", "the", "provided", "elements", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/bibrecord.py#L193-L206
[ "def", "create_field", "(", "subfields", "=", "None", ",", "ind1", "=", "' '", ",", "ind2", "=", "' '", ",", "controlfield_value", "=", "''", ",", "global_position", "=", "-", "1", ")", ":", "if", "subfields", "is", "None", ":", "subfields", "=", "[", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
create_records
Create a list of records from the marcxml description. :returns: a list of objects initiated by the function create_record(). Please see that function's docstring.
harvestingkit/bibrecord.py
def create_records(marcxml, verbose=CFG_BIBRECORD_DEFAULT_VERBOSE_LEVEL, correct=CFG_BIBRECORD_DEFAULT_CORRECT, parser='', keep_singletons=CFG_BIBRECORD_KEEP_SINGLETONS): """ Create a list of records from the marcxml description. :returns: a list of objects initiated b...
def create_records(marcxml, verbose=CFG_BIBRECORD_DEFAULT_VERBOSE_LEVEL, correct=CFG_BIBRECORD_DEFAULT_CORRECT, parser='', keep_singletons=CFG_BIBRECORD_KEEP_SINGLETONS): """ Create a list of records from the marcxml description. :returns: a list of objects initiated b...
[ "Create", "a", "list", "of", "records", "from", "the", "marcxml", "description", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/bibrecord.py#L209-L224
[ "def", "create_records", "(", "marcxml", ",", "verbose", "=", "CFG_BIBRECORD_DEFAULT_VERBOSE_LEVEL", ",", "correct", "=", "CFG_BIBRECORD_DEFAULT_CORRECT", ",", "parser", "=", "''", ",", "keep_singletons", "=", "CFG_BIBRECORD_KEEP_SINGLETONS", ")", ":", "# Use the DOTALL f...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
create_record
Create a record object from the marcxml description. Uses the lxml parser. The returned object is a tuple (record, status_code, list_of_errors), where status_code is 0 when there are errors, 1 when no errors. The return record structure is as follows:: Record := {tag : [Field]} Field...
harvestingkit/bibrecord.py
def create_record(marcxml=None, verbose=CFG_BIBRECORD_DEFAULT_VERBOSE_LEVEL, correct=CFG_BIBRECORD_DEFAULT_CORRECT, parser='', sort_fields_by_indicators=False, keep_singletons=CFG_BIBRECORD_KEEP_SINGLETONS): """Create a record object from the marcxml description...
def create_record(marcxml=None, verbose=CFG_BIBRECORD_DEFAULT_VERBOSE_LEVEL, correct=CFG_BIBRECORD_DEFAULT_CORRECT, parser='', sort_fields_by_indicators=False, keep_singletons=CFG_BIBRECORD_KEEP_SINGLETONS): """Create a record object from the marcxml description...
[ "Create", "a", "record", "object", "from", "the", "marcxml", "description", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/bibrecord.py#L227-L297
[ "def", "create_record", "(", "marcxml", "=", "None", ",", "verbose", "=", "CFG_BIBRECORD_DEFAULT_VERBOSE_LEVEL", ",", "correct", "=", "CFG_BIBRECORD_DEFAULT_CORRECT", ",", "parser", "=", "''", ",", "sort_fields_by_indicators", "=", "False", ",", "keep_singletons", "="...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
filter_field_instances
Filter the given field. Filters given field and returns only that field instances that contain filter_subcode with given filter_value. As an input for search function accepts output from record_get_field_instances function. Function can be run in three modes: - 'e' - looking for exact match in sub...
harvestingkit/bibrecord.py
def filter_field_instances(field_instances, filter_subcode, filter_value, filter_mode='e'): """Filter the given field. Filters given field and returns only that field instances that contain filter_subcode with given filter_value. As an input for search function accepts output...
def filter_field_instances(field_instances, filter_subcode, filter_value, filter_mode='e'): """Filter the given field. Filters given field and returns only that field instances that contain filter_subcode with given filter_value. As an input for search function accepts output...
[ "Filter", "the", "given", "field", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/bibrecord.py#L300-L348
[ "def", "filter_field_instances", "(", "field_instances", ",", "filter_subcode", ",", "filter_value", ",", "filter_mode", "=", "'e'", ")", ":", "matched", "=", "[", "]", "if", "filter_mode", "==", "'e'", ":", "to_match", "=", "(", "filter_subcode", ",", "filter...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
record_drop_duplicate_fields
Return a record where all the duplicate fields have been removed. Fields are considered identical considering also the order of their subfields.
harvestingkit/bibrecord.py
def record_drop_duplicate_fields(record): """ Return a record where all the duplicate fields have been removed. Fields are considered identical considering also the order of their subfields. """ out = {} position = 0 tags = sorted(record.keys()) for tag in tags: fields = rec...
def record_drop_duplicate_fields(record): """ Return a record where all the duplicate fields have been removed. Fields are considered identical considering also the order of their subfields. """ out = {} position = 0 tags = sorted(record.keys()) for tag in tags: fields = rec...
[ "Return", "a", "record", "where", "all", "the", "duplicate", "fields", "have", "been", "removed", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/bibrecord.py#L351-L371
[ "def", "record_drop_duplicate_fields", "(", "record", ")", ":", "out", "=", "{", "}", "position", "=", "0", "tags", "=", "sorted", "(", "record", ".", "keys", "(", ")", ")", "for", "tag", "in", "tags", ":", "fields", "=", "record", "[", "tag", "]", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
records_identical
Return True if rec1 is identical to rec2. It does so regardless of a difference in the 005 tag (i.e. the timestamp).
harvestingkit/bibrecord.py
def records_identical(rec1, rec2, skip_005=True, ignore_field_order=False, ignore_subfield_order=False, ignore_duplicate_subfields=False, ignore_duplicate_controlfields=False): """ Return True if rec1 is identical to rec2. It does so regardl...
def records_identical(rec1, rec2, skip_005=True, ignore_field_order=False, ignore_subfield_order=False, ignore_duplicate_subfields=False, ignore_duplicate_controlfields=False): """ Return True if rec1 is identical to rec2. It does so regardl...
[ "Return", "True", "if", "rec1", "is", "identical", "to", "rec2", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/bibrecord.py#L374-L430
[ "def", "records_identical", "(", "rec1", ",", "rec2", ",", "skip_005", "=", "True", ",", "ignore_field_order", "=", "False", ",", "ignore_subfield_order", "=", "False", ",", "ignore_duplicate_subfields", "=", "False", ",", "ignore_duplicate_controlfields", "=", "Fal...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
record_get_field_instances
Return the list of field instances for the specified tag and indications. Return empty list if not found. If tag is empty string, returns all fields Parameters (tag, ind1, ind2) can contain wildcard %. :param rec: a record structure as returned by create_record() :param tag: a 3 characters long s...
harvestingkit/bibrecord.py
def record_get_field_instances(rec, tag="", ind1=" ", ind2=" "): """ Return the list of field instances for the specified tag and indications. Return empty list if not found. If tag is empty string, returns all fields Parameters (tag, ind1, ind2) can contain wildcard %. :param rec: a record s...
def record_get_field_instances(rec, tag="", ind1=" ", ind2=" "): """ Return the list of field instances for the specified tag and indications. Return empty list if not found. If tag is empty string, returns all fields Parameters (tag, ind1, ind2) can contain wildcard %. :param rec: a record s...
[ "Return", "the", "list", "of", "field", "instances", "for", "the", "specified", "tag", "and", "indications", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/bibrecord.py#L433-L472
[ "def", "record_get_field_instances", "(", "rec", ",", "tag", "=", "\"\"", ",", "ind1", "=", "\" \"", ",", "ind2", "=", "\" \"", ")", ":", "if", "not", "rec", ":", "return", "[", "]", "if", "not", "tag", ":", "return", "rec", ".", "items", "(", ")",...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
record_add_field
Add a new field into the record. If field_position_global or field_position_local is specified then this method will insert the new field at the desired position. Otherwise a global field position will be computed in order to insert the field at the best position (first we try to keep the order of ...
harvestingkit/bibrecord.py
def record_add_field(rec, tag, ind1=' ', ind2=' ', controlfield_value='', subfields=None, field_position_global=None, field_position_local=None): """ Add a new field into the record. If field_position_global or field_position_local is specified then this method...
def record_add_field(rec, tag, ind1=' ', ind2=' ', controlfield_value='', subfields=None, field_position_global=None, field_position_local=None): """ Add a new field into the record. If field_position_global or field_position_local is specified then this method...
[ "Add", "a", "new", "field", "into", "the", "record", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/bibrecord.py#L475-L610
[ "def", "record_add_field", "(", "rec", ",", "tag", ",", "ind1", "=", "' '", ",", "ind2", "=", "' '", ",", "controlfield_value", "=", "''", ",", "subfields", "=", "None", ",", "field_position_global", "=", "None", ",", "field_position_local", "=", "None", "...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
record_delete_field
Delete the field with the given position. If global field position is specified, deletes the field with the corresponding global field position. If field_position_local is specified, deletes the field with the corresponding local field position and tag. Else deletes all the fields matching tag and ...
harvestingkit/bibrecord.py
def record_delete_field(rec, tag, ind1=' ', ind2=' ', field_position_global=None, field_position_local=None): """ Delete the field with the given position. If global field position is specified, deletes the field with the corresponding global field position. If field_positio...
def record_delete_field(rec, tag, ind1=' ', ind2=' ', field_position_global=None, field_position_local=None): """ Delete the field with the given position. If global field position is specified, deletes the field with the corresponding global field position. If field_positio...
[ "Delete", "the", "field", "with", "the", "given", "position", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/bibrecord.py#L624-L688
[ "def", "record_delete_field", "(", "rec", ",", "tag", ",", "ind1", "=", "' '", ",", "ind2", "=", "' '", ",", "field_position_global", "=", "None", ",", "field_position_local", "=", "None", ")", ":", "error", "=", "_validate_record_field_positions_global", "(", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
record_delete_fields
Delete all/some fields defined with MARC tag 'tag' from record 'rec'. :param rec: a record structure. :type rec: tuple :param tag: three letter field. :type tag: string :param field_position_local: if set, it is the list of local positions within all the fields with the specified tag, that ...
harvestingkit/bibrecord.py
def record_delete_fields(rec, tag, field_positions_local=None): """ Delete all/some fields defined with MARC tag 'tag' from record 'rec'. :param rec: a record structure. :type rec: tuple :param tag: three letter field. :type tag: string :param field_position_local: if set, it is the list of...
def record_delete_fields(rec, tag, field_positions_local=None): """ Delete all/some fields defined with MARC tag 'tag' from record 'rec'. :param rec: a record structure. :type rec: tuple :param tag: three letter field. :type tag: string :param field_position_local: if set, it is the list of...
[ "Delete", "all", "/", "some", "fields", "defined", "with", "MARC", "tag", "tag", "from", "record", "rec", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/bibrecord.py#L691-L723
[ "def", "record_delete_fields", "(", "rec", ",", "tag", ",", "field_positions_local", "=", "None", ")", ":", "if", "tag", "not", "in", "rec", ":", "return", "[", "]", "new_fields", ",", "deleted_fields", "=", "[", "]", ",", "[", "]", "for", "position", ...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f
valid
record_add_fields
Add the fields into the record at the required position. The position is specified by the tag and the field_position_local in the list of fields. :param rec: a record structure :param tag: the tag of the fields to be moved :param field_position_local: the field_position_local to which the field ...
harvestingkit/bibrecord.py
def record_add_fields(rec, tag, fields, field_position_local=None, field_position_global=None): """ Add the fields into the record at the required position. The position is specified by the tag and the field_position_local in the list of fields. :param rec: a record structure...
def record_add_fields(rec, tag, fields, field_position_local=None, field_position_global=None): """ Add the fields into the record at the required position. The position is specified by the tag and the field_position_local in the list of fields. :param rec: a record structure...
[ "Add", "the", "fields", "into", "the", "record", "at", "the", "required", "position", "." ]
inspirehep/harvesting-kit
python
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/bibrecord.py#L726-L758
[ "def", "record_add_fields", "(", "rec", ",", "tag", ",", "fields", ",", "field_position_local", "=", "None", ",", "field_position_global", "=", "None", ")", ":", "if", "field_position_local", "is", "None", "and", "field_position_global", "is", "None", ":", "for"...
33a7f8aa9dade1d863110c6d8b27dfd955cb471f