repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
Othernet-Project/squery-pg
squery_pg/pool.py
gevent_wait_callback
def gevent_wait_callback(conn, timeout=None): """A wait callback useful to allow gevent to work with Psycopg.""" while 1: state = conn.poll() if state == extensions.POLL_OK: break elif state == extensions.POLL_READ: wait_read(conn.fileno(), timeout=timeout) ...
python
def gevent_wait_callback(conn, timeout=None): """A wait callback useful to allow gevent to work with Psycopg.""" while 1: state = conn.poll() if state == extensions.POLL_OK: break elif state == extensions.POLL_READ: wait_read(conn.fileno(), timeout=timeout) ...
[ "def", "gevent_wait_callback", "(", "conn", ",", "timeout", "=", "None", ")", ":", "while", "1", ":", "state", "=", "conn", ".", "poll", "(", ")", "if", "state", "==", "extensions", ".", "POLL_OK", ":", "break", "elif", "state", "==", "extensions", "."...
A wait callback useful to allow gevent to work with Psycopg.
[ "A", "wait", "callback", "useful", "to", "allow", "gevent", "to", "work", "with", "Psycopg", "." ]
train
https://github.com/Othernet-Project/squery-pg/blob/eaa695c3719e2d2b7e1b049bb58c987c132b6b34/squery_pg/pool.py#L24-L36
neithere/django-navigation
navigation/templatetags/navigation_tags.py
_get_sections
def _get_sections(request): """ Returns list of sections (horizontal cut, base level). """ sections = [] for section_url in SECTIONS: crumb = find_crumb(request, section_url) if crumb: if section_url == '/': if request.path == section_url: ...
python
def _get_sections(request): """ Returns list of sections (horizontal cut, base level). """ sections = [] for section_url in SECTIONS: crumb = find_crumb(request, section_url) if crumb: if section_url == '/': if request.path == section_url: ...
[ "def", "_get_sections", "(", "request", ")", ":", "sections", "=", "[", "]", "for", "section_url", "in", "SECTIONS", ":", "crumb", "=", "find_crumb", "(", "request", ",", "section_url", ")", "if", "crumb", ":", "if", "section_url", "==", "'/'", ":", "if"...
Returns list of sections (horizontal cut, base level).
[ "Returns", "list", "of", "sections", "(", "horizontal", "cut", "base", "level", ")", "." ]
train
https://github.com/neithere/django-navigation/blob/aff8d671a8431c84dde65cba6236ea8c16a08b4d/navigation/templatetags/navigation_tags.py#L100-L116
neithere/django-navigation
navigation/templatetags/navigation_tags.py
_get_trail
def _get_trail(request, exclude_section=False): """ Returns trail of breadcrumbs (vertical cut, excluding base level) """ trail = [] url = request.path while url: if url == '/': break if exclude_section and url in SECTIONS: break crumb = find_crumb...
python
def _get_trail(request, exclude_section=False): """ Returns trail of breadcrumbs (vertical cut, excluding base level) """ trail = [] url = request.path while url: if url == '/': break if exclude_section and url in SECTIONS: break crumb = find_crumb...
[ "def", "_get_trail", "(", "request", ",", "exclude_section", "=", "False", ")", ":", "trail", "=", "[", "]", "url", "=", "request", ".", "path", "while", "url", ":", "if", "url", "==", "'/'", ":", "break", "if", "exclude_section", "and", "url", "in", ...
Returns trail of breadcrumbs (vertical cut, excluding base level)
[ "Returns", "trail", "of", "breadcrumbs", "(", "vertical", "cut", "excluding", "base", "level", ")" ]
train
https://github.com/neithere/django-navigation/blob/aff8d671a8431c84dde65cba6236ea8c16a08b4d/navigation/templatetags/navigation_tags.py#L118-L139
neithere/django-navigation
navigation/templatetags/navigation_tags.py
get_navigation
def get_navigation(request): """ Returns the rendered navigation block. Requires that the `navigation.html` template exists. Two context variables are passed to it: * sections (see :func:`get_breadcrumb_sections`) * trail (see :func:`get_breadcrumb_trail`) """ sections = _get_sections(request)...
python
def get_navigation(request): """ Returns the rendered navigation block. Requires that the `navigation.html` template exists. Two context variables are passed to it: * sections (see :func:`get_breadcrumb_sections`) * trail (see :func:`get_breadcrumb_trail`) """ sections = _get_sections(request)...
[ "def", "get_navigation", "(", "request", ")", ":", "sections", "=", "_get_sections", "(", "request", ")", "trail", "=", "_get_trail", "(", "request", ",", "exclude_section", "=", "True", ")", "return", "mark_safe", "(", "render_to_string", "(", "'navigation.html...
Returns the rendered navigation block. Requires that the `navigation.html` template exists. Two context variables are passed to it: * sections (see :func:`get_breadcrumb_sections`) * trail (see :func:`get_breadcrumb_trail`)
[ "Returns", "the", "rendered", "navigation", "block", ".", "Requires", "that", "the", "navigation", ".", "html", "template", "exists", ".", "Two", "context", "variables", "are", "passed", "to", "it", ":" ]
train
https://github.com/neithere/django-navigation/blob/aff8d671a8431c84dde65cba6236ea8c16a08b4d/navigation/templatetags/navigation_tags.py#L190-L202
neithere/django-navigation
navigation/templatetags/navigation_tags.py
named_crumb
def named_crumb(context, name, *args, **kwargs): """ Resolves given named URL and returns the relevant breadcrumb label (if available). Usage:: <a href="{% url project-detail project.slug %}"> {% named_crumb project-detail project.slug %} </a> """ url = reverse(name, args=a...
python
def named_crumb(context, name, *args, **kwargs): """ Resolves given named URL and returns the relevant breadcrumb label (if available). Usage:: <a href="{% url project-detail project.slug %}"> {% named_crumb project-detail project.slug %} </a> """ url = reverse(name, args=a...
[ "def", "named_crumb", "(", "context", ",", "name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "url", "=", "reverse", "(", "name", ",", "args", "=", "args", ",", "kwargs", "=", "kwargs", ")", "return", "find_crumb", "(", "context", "[", "'...
Resolves given named URL and returns the relevant breadcrumb label (if available). Usage:: <a href="{% url project-detail project.slug %}"> {% named_crumb project-detail project.slug %} </a>
[ "Resolves", "given", "named", "URL", "and", "returns", "the", "relevant", "breadcrumb", "label", "(", "if", "available", ")", ".", "Usage", "::" ]
train
https://github.com/neithere/django-navigation/blob/aff8d671a8431c84dde65cba6236ea8c16a08b4d/navigation/templatetags/navigation_tags.py#L219-L229
neithere/django-navigation
navigation/templatetags/navigation_tags.py
crumb_link
def crumb_link(context, name, *args, **kwargs): """ Acts like :func:`named_crumb` but also wraps the result into a link tag. Usage:: <ul> <li>{% crumb_link 'auth_login' %}</li> <li>{% crumb_link 'project-index' %}</li> </ul> The result:: <ul> <l...
python
def crumb_link(context, name, *args, **kwargs): """ Acts like :func:`named_crumb` but also wraps the result into a link tag. Usage:: <ul> <li>{% crumb_link 'auth_login' %}</li> <li>{% crumb_link 'project-index' %}</li> </ul> The result:: <ul> <l...
[ "def", "crumb_link", "(", "context", ",", "name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "url", "=", "reverse", "(", "name", ",", "args", "=", "args", ",", "kwargs", "=", "kwargs", ")", "label", "=", "find_crumb", "(", "context", "[",...
Acts like :func:`named_crumb` but also wraps the result into a link tag. Usage:: <ul> <li>{% crumb_link 'auth_login' %}</li> <li>{% crumb_link 'project-index' %}</li> </ul> The result:: <ul> <li><a href="/accounts/login/">Log in</a></li> ...
[ "Acts", "like", ":", "func", ":", "named_crumb", "but", "also", "wraps", "the", "result", "into", "a", "link", "tag", ".", "Usage", "::" ]
train
https://github.com/neithere/django-navigation/blob/aff8d671a8431c84dde65cba6236ea8c16a08b4d/navigation/templatetags/navigation_tags.py#L232-L253
steenzout/python-sphinx
steenzout/sphinx/__init__.py
ResourceGenerator.conf
def conf(self): """Generate the Sphinx `conf.py` configuration file Returns: (str): the contents of the `conf.py` file. """ return self.env.get_template('conf.py.j2').render( metadata=self.metadata, package=self.package)
python
def conf(self): """Generate the Sphinx `conf.py` configuration file Returns: (str): the contents of the `conf.py` file. """ return self.env.get_template('conf.py.j2').render( metadata=self.metadata, package=self.package)
[ "def", "conf", "(", "self", ")", ":", "return", "self", ".", "env", ".", "get_template", "(", "'conf.py.j2'", ")", ".", "render", "(", "metadata", "=", "self", ".", "metadata", ",", "package", "=", "self", ".", "package", ")" ]
Generate the Sphinx `conf.py` configuration file Returns: (str): the contents of the `conf.py` file.
[ "Generate", "the", "Sphinx", "conf", ".", "py", "configuration", "file" ]
train
https://github.com/steenzout/python-sphinx/blob/b9767195fba74540c385fdf5f94cc4a24bc5e46d/steenzout/sphinx/__init__.py#L42-L50
steenzout/python-sphinx
steenzout/sphinx/__init__.py
ResourceGenerator.makefile
def makefile(self): """Generate the documentation Makefile. Returns: (str): the contents of the `Makefile`. """ return self.env.get_template('Makefile.j2').render( metadata=self.metadata, package=self.package)
python
def makefile(self): """Generate the documentation Makefile. Returns: (str): the contents of the `Makefile`. """ return self.env.get_template('Makefile.j2').render( metadata=self.metadata, package=self.package)
[ "def", "makefile", "(", "self", ")", ":", "return", "self", ".", "env", ".", "get_template", "(", "'Makefile.j2'", ")", ".", "render", "(", "metadata", "=", "self", ".", "metadata", ",", "package", "=", "self", ".", "package", ")" ]
Generate the documentation Makefile. Returns: (str): the contents of the `Makefile`.
[ "Generate", "the", "documentation", "Makefile", "." ]
train
https://github.com/steenzout/python-sphinx/blob/b9767195fba74540c385fdf5f94cc4a24bc5e46d/steenzout/sphinx/__init__.py#L52-L60
mrstephenneal/dirutility
dirutility/compare.py
unique
def unique(list1, list2): """ Get unique items in list1 that are not in list2 :return: Unique items only in list 1 """ set2 = set(list2) list1_unique = [x for x in tqdm(list1, desc='Unique', total=len(list1)) if x not in set2] return list1_unique
python
def unique(list1, list2): """ Get unique items in list1 that are not in list2 :return: Unique items only in list 1 """ set2 = set(list2) list1_unique = [x for x in tqdm(list1, desc='Unique', total=len(list1)) if x not in set2] return list1_unique
[ "def", "unique", "(", "list1", ",", "list2", ")", ":", "set2", "=", "set", "(", "list2", ")", "list1_unique", "=", "[", "x", "for", "x", "in", "tqdm", "(", "list1", ",", "desc", "=", "'Unique'", ",", "total", "=", "len", "(", "list1", ")", ")", ...
Get unique items in list1 that are not in list2 :return: Unique items only in list 1
[ "Get", "unique", "items", "in", "list1", "that", "are", "not", "in", "list2", ":", "return", ":", "Unique", "items", "only", "in", "list", "1" ]
train
https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/compare.py#L6-L13
mrstephenneal/dirutility
dirutility/compare.py
compare_trees
def compare_trees(dir1, dir2): """Parse two directories and return lists of unique files""" paths1 = DirPaths(dir1).walk() paths2 = DirPaths(dir2).walk() return unique_venn(paths1, paths2)
python
def compare_trees(dir1, dir2): """Parse two directories and return lists of unique files""" paths1 = DirPaths(dir1).walk() paths2 = DirPaths(dir2).walk() return unique_venn(paths1, paths2)
[ "def", "compare_trees", "(", "dir1", ",", "dir2", ")", ":", "paths1", "=", "DirPaths", "(", "dir1", ")", ".", "walk", "(", ")", "paths2", "=", "DirPaths", "(", "dir2", ")", ".", "walk", "(", ")", "return", "unique_venn", "(", "paths1", ",", "paths2",...
Parse two directories and return lists of unique files
[ "Parse", "two", "directories", "and", "return", "lists", "of", "unique", "files" ]
train
https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/compare.py#L21-L25
openknowledge-archive/datapackage-validate-py
datapackage_validate/schema.py
Schema.validate
def validate(self, data): '''Validates a data dict against this schema. Args: data (dict): The data to be validated. Raises: ValidationError: If the data is invalid. ''' try: self._validator.validate(data) except jsonschema.Validation...
python
def validate(self, data): '''Validates a data dict against this schema. Args: data (dict): The data to be validated. Raises: ValidationError: If the data is invalid. ''' try: self._validator.validate(data) except jsonschema.Validation...
[ "def", "validate", "(", "self", ",", "data", ")", ":", "try", ":", "self", ".", "_validator", ".", "validate", "(", "data", ")", "except", "jsonschema", ".", "ValidationError", "as", "e", ":", "six", ".", "raise_from", "(", "ValidationError", ".", "creat...
Validates a data dict against this schema. Args: data (dict): The data to be validated. Raises: ValidationError: If the data is invalid.
[ "Validates", "a", "data", "dict", "against", "this", "schema", "." ]
train
https://github.com/openknowledge-archive/datapackage-validate-py/blob/5f906bd4e0baa78dfd45f48e7fa3c5d649e6846a/datapackage_validate/schema.py#L45-L57
fangpenlin/pyramid-handy
pyramid_handy/tweens/api_headers.py
set_version
def set_version(request, response): """Set version and revision to response """ settings = request.registry.settings resolver = DottedNameResolver() # get version config version_header = settings.get( 'api.version_header', 'X-Version', ) version_header_value = settings....
python
def set_version(request, response): """Set version and revision to response """ settings = request.registry.settings resolver = DottedNameResolver() # get version config version_header = settings.get( 'api.version_header', 'X-Version', ) version_header_value = settings....
[ "def", "set_version", "(", "request", ",", "response", ")", ":", "settings", "=", "request", ".", "registry", ".", "settings", "resolver", "=", "DottedNameResolver", "(", ")", "# get version config", "version_header", "=", "settings", ".", "get", "(", "'api.vers...
Set version and revision to response
[ "Set", "version", "and", "revision", "to", "response" ]
train
https://github.com/fangpenlin/pyramid-handy/blob/e3cbc19224ab1f0a14aab556990bceabd2d1f658/pyramid_handy/tweens/api_headers.py#L7-L39
fangpenlin/pyramid-handy
pyramid_handy/tweens/api_headers.py
api_headers_tween_factory
def api_headers_tween_factory(handler, registry): """This tween provides necessary API headers """ def api_headers_tween(request): response = handler(request) set_version(request, response) set_req_guid(request, response) return response return api_headers_tween
python
def api_headers_tween_factory(handler, registry): """This tween provides necessary API headers """ def api_headers_tween(request): response = handler(request) set_version(request, response) set_req_guid(request, response) return response return api_headers_tween
[ "def", "api_headers_tween_factory", "(", "handler", ",", "registry", ")", ":", "def", "api_headers_tween", "(", "request", ")", ":", "response", "=", "handler", "(", "request", ")", "set_version", "(", "request", ",", "response", ")", "set_req_guid", "(", "req...
This tween provides necessary API headers
[ "This", "tween", "provides", "necessary", "API", "headers" ]
train
https://github.com/fangpenlin/pyramid-handy/blob/e3cbc19224ab1f0a14aab556990bceabd2d1f658/pyramid_handy/tweens/api_headers.py#L62-L73
regardscitoyens/lawfactory_utils
lawfactory_utils/urls.py
download
def download(url, retry=5): """ Proxy function to be used with `enable_requests_cache()` to have the requests cached >>> import timeit >>> clean_cache() >>> enable_requests_cache() >>> url = "https://regardscitoyens.org/" >>> timeit.timeit(lambda: download(url), number=1) < 0.01 Fal...
python
def download(url, retry=5): """ Proxy function to be used with `enable_requests_cache()` to have the requests cached >>> import timeit >>> clean_cache() >>> enable_requests_cache() >>> url = "https://regardscitoyens.org/" >>> timeit.timeit(lambda: download(url), number=1) < 0.01 Fal...
[ "def", "download", "(", "url", ",", "retry", "=", "5", ")", ":", "try", ":", "if", "CACHE_ENABLED", ":", "file", "=", "os", ".", "path", ".", "join", "(", "cache_directory", "(", ")", ",", "hashlib", ".", "sha224", "(", "url", ".", "encode", "(", ...
Proxy function to be used with `enable_requests_cache()` to have the requests cached >>> import timeit >>> clean_cache() >>> enable_requests_cache() >>> url = "https://regardscitoyens.org/" >>> timeit.timeit(lambda: download(url), number=1) < 0.01 False >>> timeit.timeit(lambda: downloa...
[ "Proxy", "function", "to", "be", "used", "with", "enable_requests_cache", "()", "to", "have", "the", "requests", "cached" ]
train
https://github.com/regardscitoyens/lawfactory_utils/blob/d8565c5216f9ef8ce7c91a2409782f2d2636f67e/lawfactory_utils/urls.py#L28-L76
regardscitoyens/lawfactory_utils
lawfactory_utils/urls.py
clean_url
def clean_url(url): """ Normalize the url and clean it >>> clean_url("http://www.assemblee-nationale.fr/15/dossiers/le_nouveau_dossier.asp#deuxieme_partie") 'http://www.assemblee-nationale.fr/dyn/15/dossiers/deuxieme_partie' >>> clean_url("http://www.conseil-constitutionnel.fr/conseil-constitutionn...
python
def clean_url(url): """ Normalize the url and clean it >>> clean_url("http://www.assemblee-nationale.fr/15/dossiers/le_nouveau_dossier.asp#deuxieme_partie") 'http://www.assemblee-nationale.fr/dyn/15/dossiers/deuxieme_partie' >>> clean_url("http://www.conseil-constitutionnel.fr/conseil-constitutionn...
[ "def", "clean_url", "(", "url", ")", ":", "url", "=", "url", ".", "strip", "(", ")", "# fix urls like 'pjl09-518.htmlhttp://www.assemblee-nationale.fr/13/ta/ta051`8.asp'", "if", "url", ".", "find", "(", "'https://'", ")", ">", "0", ":", "url", "=", "'https://'", ...
Normalize the url and clean it >>> clean_url("http://www.assemblee-nationale.fr/15/dossiers/le_nouveau_dossier.asp#deuxieme_partie") 'http://www.assemblee-nationale.fr/dyn/15/dossiers/deuxieme_partie' >>> clean_url("http://www.conseil-constitutionnel.fr/conseil-constitutionnel/francais/les-decisions/acces-...
[ "Normalize", "the", "url", "and", "clean", "it" ]
train
https://github.com/regardscitoyens/lawfactory_utils/blob/d8565c5216f9ef8ce7c91a2409782f2d2636f67e/lawfactory_utils/urls.py#L141-L227
regardscitoyens/lawfactory_utils
lawfactory_utils/urls.py
parse_national_assembly_url
def parse_national_assembly_url(url_an): """Returns the slug and the legislature of an AN url >>> # old format >>> parse_national_assembly_url("http://www.assemblee-nationale.fr/14/dossiers/devoir_vigilance_entreprises_donneuses_ordre.asp") (14, 'devoir_vigilance_entreprises_donneuses_ordre') >>> #...
python
def parse_national_assembly_url(url_an): """Returns the slug and the legislature of an AN url >>> # old format >>> parse_national_assembly_url("http://www.assemblee-nationale.fr/14/dossiers/devoir_vigilance_entreprises_donneuses_ordre.asp") (14, 'devoir_vigilance_entreprises_donneuses_ordre') >>> #...
[ "def", "parse_national_assembly_url", "(", "url_an", ")", ":", "legislature_match", "=", "re", ".", "search", "(", "r\"\\.fr/(dyn/)?(\\d+)/\"", ",", "url_an", ")", "if", "legislature_match", ":", "legislature", "=", "int", "(", "legislature_match", ".", "group", "...
Returns the slug and the legislature of an AN url >>> # old format >>> parse_national_assembly_url("http://www.assemblee-nationale.fr/14/dossiers/devoir_vigilance_entreprises_donneuses_ordre.asp") (14, 'devoir_vigilance_entreprises_donneuses_ordre') >>> # new format >>> parse_national_assembly_url(...
[ "Returns", "the", "slug", "and", "the", "legislature", "of", "an", "AN", "url" ]
train
https://github.com/regardscitoyens/lawfactory_utils/blob/d8565c5216f9ef8ce7c91a2409782f2d2636f67e/lawfactory_utils/urls.py#L230-L263
jhazelwo/python-fileasobj
fileasobj/__init__.py
FileAsObj.read
def read(self, given_file): """ Read given_file to self.contents Will ignoring duplicate lines if self.unique is True Will sort self.contents after reading file if self.sorted is True """ if self.unique is not False and self.unique is not True: raise Attribute...
python
def read(self, given_file): """ Read given_file to self.contents Will ignoring duplicate lines if self.unique is True Will sort self.contents after reading file if self.sorted is True """ if self.unique is not False and self.unique is not True: raise Attribute...
[ "def", "read", "(", "self", ",", "given_file", ")", ":", "if", "self", ".", "unique", "is", "not", "False", "and", "self", ".", "unique", "is", "not", "True", ":", "raise", "AttributeError", "(", "\"Attribute 'unique' is not True or False.\"", ")", "self", "...
Read given_file to self.contents Will ignoring duplicate lines if self.unique is True Will sort self.contents after reading file if self.sorted is True
[ "Read", "given_file", "to", "self", ".", "contents", "Will", "ignoring", "duplicate", "lines", "if", "self", ".", "unique", "is", "True", "Will", "sort", "self", ".", "contents", "after", "reading", "file", "if", "self", ".", "sorted", "is", "True" ]
train
https://github.com/jhazelwo/python-fileasobj/blob/4bdbb575e75da830b88d10d0c1020d787ceba44d/fileasobj/__init__.py#L89-L109
jhazelwo/python-fileasobj
fileasobj/__init__.py
FileAsObj.check
def check(self, line): """ Find first occurrence of 'line' in file. This searches each line as a whole, if you want to see if a substring is in a line, use .grep() or .egrep() If found, return the line; this makes it easier to chain methods. :param line: String; whole line to ...
python
def check(self, line): """ Find first occurrence of 'line' in file. This searches each line as a whole, if you want to see if a substring is in a line, use .grep() or .egrep() If found, return the line; this makes it easier to chain methods. :param line: String; whole line to ...
[ "def", "check", "(", "self", ",", "line", ")", ":", "if", "not", "isinstance", "(", "line", ",", "str", ")", ":", "raise", "TypeError", "(", "\"Parameter 'line' not a 'string', is {0}\"", ".", "format", "(", "type", "(", "line", ")", ")", ")", "if", "lin...
Find first occurrence of 'line' in file. This searches each line as a whole, if you want to see if a substring is in a line, use .grep() or .egrep() If found, return the line; this makes it easier to chain methods. :param line: String; whole line to find. :return: String or False.
[ "Find", "first", "occurrence", "of", "line", "in", "file", "." ]
train
https://github.com/jhazelwo/python-fileasobj/blob/4bdbb575e75da830b88d10d0c1020d787ceba44d/fileasobj/__init__.py#L111-L126
jhazelwo/python-fileasobj
fileasobj/__init__.py
FileAsObj.add
def add(self, line): """ Append 'line' to contents where 'line' is an entire line or a list of lines. If self.unique is False it will add regardless of contents. Multi-line strings are converted to a list delimited by new lines. :param line: String or List of Strin...
python
def add(self, line): """ Append 'line' to contents where 'line' is an entire line or a list of lines. If self.unique is False it will add regardless of contents. Multi-line strings are converted to a list delimited by new lines. :param line: String or List of Strin...
[ "def", "add", "(", "self", ",", "line", ")", ":", "if", "self", ".", "unique", "is", "not", "False", "and", "self", ".", "unique", "is", "not", "True", ":", "raise", "AttributeError", "(", "\"Attribute 'unique' is not True or False.\"", ")", "self", ".", "...
Append 'line' to contents where 'line' is an entire line or a list of lines. If self.unique is False it will add regardless of contents. Multi-line strings are converted to a list delimited by new lines. :param line: String or List of Strings; arbitrary string(s) to append to file...
[ "Append", "line", "to", "contents", "where", "line", "is", "an", "entire", "line", "or", "a", "list", "of", "lines", "." ]
train
https://github.com/jhazelwo/python-fileasobj/blob/4bdbb575e75da830b88d10d0c1020d787ceba44d/fileasobj/__init__.py#L128-L156
jhazelwo/python-fileasobj
fileasobj/__init__.py
FileAsObj.rm
def rm(self, line): """ Remove all occurrences of 'line' from contents where 'line' is an entire line or a list of lines. Return true if the file was changed by rm(), False otherwise. Multi-line strings are converted to a list delimited by new lines. :param line: S...
python
def rm(self, line): """ Remove all occurrences of 'line' from contents where 'line' is an entire line or a list of lines. Return true if the file was changed by rm(), False otherwise. Multi-line strings are converted to a list delimited by new lines. :param line: S...
[ "def", "rm", "(", "self", ",", "line", ")", ":", "self", ".", "log", "(", "'rm({0})'", ".", "format", "(", "line", ")", ")", "if", "line", "is", "False", ":", "return", "False", "if", "isinstance", "(", "line", ",", "str", ")", ":", "line", "=", ...
Remove all occurrences of 'line' from contents where 'line' is an entire line or a list of lines. Return true if the file was changed by rm(), False otherwise. Multi-line strings are converted to a list delimited by new lines. :param line: String, or List of Strings; each string r...
[ "Remove", "all", "occurrences", "of", "line", "from", "contents", "where", "line", "is", "an", "entire", "line", "or", "a", "list", "of", "lines", "." ]
train
https://github.com/jhazelwo/python-fileasobj/blob/4bdbb575e75da830b88d10d0c1020d787ceba44d/fileasobj/__init__.py#L158-L188
jhazelwo/python-fileasobj
fileasobj/__init__.py
FileAsObj.write
def write(self): """ write self.contents to self.filename self.filename was defined during .read() There is no self.changed check because we need to let the caller decide whether or not to write. This is useful if you want to force an overwrite of a file that might have been...
python
def write(self): """ write self.contents to self.filename self.filename was defined during .read() There is no self.changed check because we need to let the caller decide whether or not to write. This is useful if you want to force an overwrite of a file that might have been...
[ "def", "write", "(", "self", ")", ":", "self", ".", "log", "(", "'Writing {0}'", ".", "format", "(", "self", ".", "filename", ")", ")", "with", "open", "(", "self", ".", "filename", ",", "'w'", ")", "as", "handle", ":", "for", "this_line", "in", "s...
write self.contents to self.filename self.filename was defined during .read() There is no self.changed check because we need to let the caller decide whether or not to write. This is useful if you want to force an overwrite of a file that might have been changed on disk even if ...
[ "write", "self", ".", "contents", "to", "self", ".", "filename", "self", ".", "filename", "was", "defined", "during", ".", "read", "()" ]
train
https://github.com/jhazelwo/python-fileasobj/blob/4bdbb575e75da830b88d10d0c1020d787ceba44d/fileasobj/__init__.py#L190-L204
jhazelwo/python-fileasobj
fileasobj/__init__.py
FileAsObj.grep
def grep(self, needle): """ Search all lines in file for substring 'needle'. equiv to: `grep "needle" ./file` Return matching lines as a List of Strings. If no matches returns False :param needle: String; word or phrase to search for. :return: List of String...
python
def grep(self, needle): """ Search all lines in file for substring 'needle'. equiv to: `grep "needle" ./file` Return matching lines as a List of Strings. If no matches returns False :param needle: String; word or phrase to search for. :return: List of String...
[ "def", "grep", "(", "self", ",", "needle", ")", ":", "result", "=", "[", "]", "for", "line", "in", "self", ".", "contents", ":", "if", "needle", "in", "line", ":", "result", ".", "append", "(", "line", ")", "if", "result", ":", "return", "result", ...
Search all lines in file for substring 'needle'. equiv to: `grep "needle" ./file` Return matching lines as a List of Strings. If no matches returns False :param needle: String; word or phrase to search for. :return: List of Strings, or False.
[ "Search", "all", "lines", "in", "file", "for", "substring", "needle", ".", "equiv", "to", ":", "grep", "needle", ".", "/", "file" ]
train
https://github.com/jhazelwo/python-fileasobj/blob/4bdbb575e75da830b88d10d0c1020d787ceba44d/fileasobj/__init__.py#L206-L223
jhazelwo/python-fileasobj
fileasobj/__init__.py
FileAsObj.egrep
def egrep(self, pattern): """ REGEX search for pattern in file equiv to: `egrep "^asdf.*[0-9]+$" ./file` Return matching lines as a List of Strings. If no matches returns False :param pattern: String; regex pattern to search for. :return: List of Strings, or...
python
def egrep(self, pattern): """ REGEX search for pattern in file equiv to: `egrep "^asdf.*[0-9]+$" ./file` Return matching lines as a List of Strings. If no matches returns False :param pattern: String; regex pattern to search for. :return: List of Strings, or...
[ "def", "egrep", "(", "self", ",", "pattern", ")", ":", "pattern", "=", "re", ".", "compile", "(", "pattern", ")", "result", "=", "[", "]", "for", "line", "in", "self", ".", "contents", ":", "if", "pattern", ".", "search", "(", "line", ")", ":", "...
REGEX search for pattern in file equiv to: `egrep "^asdf.*[0-9]+$" ./file` Return matching lines as a List of Strings. If no matches returns False :param pattern: String; regex pattern to search for. :return: List of Strings, or False.
[ "REGEX", "search", "for", "pattern", "in", "file", "equiv", "to", ":", "egrep", "^asdf", ".", "*", "[", "0", "-", "9", "]", "+", "$", ".", "/", "file" ]
train
https://github.com/jhazelwo/python-fileasobj/blob/4bdbb575e75da830b88d10d0c1020d787ceba44d/fileasobj/__init__.py#L225-L243
jhazelwo/python-fileasobj
fileasobj/__init__.py
FileAsObj.replace
def replace(self, old, new): """ Replace all lines of file that match 'old' with 'new' Will replace duplicates if found. :param old: String, List of Strings, a multi-line String, or False; what to replace. :param new: String; what to use as replacement. :return: Boolea...
python
def replace(self, old, new): """ Replace all lines of file that match 'old' with 'new' Will replace duplicates if found. :param old: String, List of Strings, a multi-line String, or False; what to replace. :param new: String; what to use as replacement. :return: Boolea...
[ "def", "replace", "(", "self", ",", "old", ",", "new", ")", ":", "self", ".", "log", "(", "'replace({0}, {1})'", ".", "format", "(", "old", ",", "new", ")", ")", "if", "old", "is", "False", ":", "return", "False", "if", "isinstance", "(", "old", ",...
Replace all lines of file that match 'old' with 'new' Will replace duplicates if found. :param old: String, List of Strings, a multi-line String, or False; what to replace. :param new: String; what to use as replacement. :return: Boolean; whether contents changed during method call.
[ "Replace", "all", "lines", "of", "file", "that", "match", "old", "with", "new" ]
train
https://github.com/jhazelwo/python-fileasobj/blob/4bdbb575e75da830b88d10d0c1020d787ceba44d/fileasobj/__init__.py#L245-L276
jhazelwo/python-fileasobj
fileasobj/__init__.py
FileAsObj.sort
def sort(self, key=None, reverse=False): """ Sort contents using sort() method available to list() :return: None (because list().sort() doesn't return anything) """ self.log('sort()') self.contents.sort(key=key, reverse=reverse) return None
python
def sort(self, key=None, reverse=False): """ Sort contents using sort() method available to list() :return: None (because list().sort() doesn't return anything) """ self.log('sort()') self.contents.sort(key=key, reverse=reverse) return None
[ "def", "sort", "(", "self", ",", "key", "=", "None", ",", "reverse", "=", "False", ")", ":", "self", ".", "log", "(", "'sort()'", ")", "self", ".", "contents", ".", "sort", "(", "key", "=", "key", ",", "reverse", "=", "reverse", ")", "return", "N...
Sort contents using sort() method available to list() :return: None (because list().sort() doesn't return anything)
[ "Sort", "contents", "using", "sort", "()", "method", "available", "to", "list", "()", ":", "return", ":", "None", "(", "because", "list", "()", ".", "sort", "()", "doesn", "t", "return", "anything", ")" ]
train
https://github.com/jhazelwo/python-fileasobj/blob/4bdbb575e75da830b88d10d0c1020d787ceba44d/fileasobj/__init__.py#L286-L293
Archived-Object/ligament
ligament/helpers.py
partition
def partition(pred, iterable): """ split the results of an iterable based on a predicate """ trues = [] falses = [] for item in iterable: if pred(item): trues.append(item) else: falses.append(item) return trues, falses
python
def partition(pred, iterable): """ split the results of an iterable based on a predicate """ trues = [] falses = [] for item in iterable: if pred(item): trues.append(item) else: falses.append(item) return trues, falses
[ "def", "partition", "(", "pred", ",", "iterable", ")", ":", "trues", "=", "[", "]", "falses", "=", "[", "]", "for", "item", "in", "iterable", ":", "if", "pred", "(", "item", ")", ":", "trues", ".", "append", "(", "item", ")", "else", ":", "falses...
split the results of an iterable based on a predicate
[ "split", "the", "results", "of", "an", "iterable", "based", "on", "a", "predicate" ]
train
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/helpers.py#L17-L26
Archived-Object/ligament
ligament/helpers.py
zip_with_output
def zip_with_output(skip_args=[]): """decorater that zips the input of a function with its output only zips positional arguments. skip_args : list a list of indexes of arguments to exclude from the skip @zip_with_output(skip_args=[0]) def foo(bar, baz): ...
python
def zip_with_output(skip_args=[]): """decorater that zips the input of a function with its output only zips positional arguments. skip_args : list a list of indexes of arguments to exclude from the skip @zip_with_output(skip_args=[0]) def foo(bar, baz): ...
[ "def", "zip_with_output", "(", "skip_args", "=", "[", "]", ")", ":", "def", "decorator", "(", "fn", ")", ":", "def", "wrapped", "(", "*", "args", ",", "*", "*", "vargs", ")", ":", "g", "=", "[", "arg", "for", "i", ",", "arg", "in", "enumerate", ...
decorater that zips the input of a function with its output only zips positional arguments. skip_args : list a list of indexes of arguments to exclude from the skip @zip_with_output(skip_args=[0]) def foo(bar, baz): return baz will decorate...
[ "decorater", "that", "zips", "the", "input", "of", "a", "function", "with", "its", "output", "only", "zips", "positional", "arguments", "." ]
train
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/helpers.py#L29-L52
Archived-Object/ligament
ligament/helpers.py
capture_exception
def capture_exception(fn): """decorator that catches and returns an exception from wrapped function""" def wrapped(*args): try: return fn(*args) except Exception as e: return e return wrapped
python
def capture_exception(fn): """decorator that catches and returns an exception from wrapped function""" def wrapped(*args): try: return fn(*args) except Exception as e: return e return wrapped
[ "def", "capture_exception", "(", "fn", ")", ":", "def", "wrapped", "(", "*", "args", ")", ":", "try", ":", "return", "fn", "(", "*", "args", ")", "except", "Exception", "as", "e", ":", "return", "e", "return", "wrapped" ]
decorator that catches and returns an exception from wrapped function
[ "decorator", "that", "catches", "and", "returns", "an", "exception", "from", "wrapped", "function" ]
train
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/helpers.py#L55-L62
Archived-Object/ligament
ligament/helpers.py
compose
def compose(*funcs): """compose a list of functions""" return lambda x: reduce(lambda v, f: f(v), reversed(funcs), x)
python
def compose(*funcs): """compose a list of functions""" return lambda x: reduce(lambda v, f: f(v), reversed(funcs), x)
[ "def", "compose", "(", "*", "funcs", ")", ":", "return", "lambda", "x", ":", "reduce", "(", "lambda", "v", ",", "f", ":", "f", "(", "v", ")", ",", "reversed", "(", "funcs", ")", ",", "x", ")" ]
compose a list of functions
[ "compose", "a", "list", "of", "functions" ]
train
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/helpers.py#L65-L67
Archived-Object/ligament
ligament/helpers.py
build_lst
def build_lst(a, b): """ function to be folded over a list (with initial value `None`) produces one of: 1. `None` 2. A single value 3. A list of all values """ if type(a) is list: return a + [b] elif a: return [a, b] else: return b
python
def build_lst(a, b): """ function to be folded over a list (with initial value `None`) produces one of: 1. `None` 2. A single value 3. A list of all values """ if type(a) is list: return a + [b] elif a: return [a, b] else: return b
[ "def", "build_lst", "(", "a", ",", "b", ")", ":", "if", "type", "(", "a", ")", "is", "list", ":", "return", "a", "+", "[", "b", "]", "elif", "a", ":", "return", "[", "a", ",", "b", "]", "else", ":", "return", "b" ]
function to be folded over a list (with initial value `None`) produces one of: 1. `None` 2. A single value 3. A list of all values
[ "function", "to", "be", "folded", "over", "a", "list", "(", "with", "initial", "value", "None", ")", "produces", "one", "of", ":" ]
train
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/helpers.py#L70-L83
Archived-Object/ligament
ligament/helpers.py
map_over_glob
def map_over_glob(fn, path, pattern): """map a function over a glob pattern, relative to a directory""" return [fn(x) for x in glob.glob(os.path.join(path, pattern))]
python
def map_over_glob(fn, path, pattern): """map a function over a glob pattern, relative to a directory""" return [fn(x) for x in glob.glob(os.path.join(path, pattern))]
[ "def", "map_over_glob", "(", "fn", ",", "path", ",", "pattern", ")", ":", "return", "[", "fn", "(", "x", ")", "for", "x", "in", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "path", ",", "pattern", ")", ")", "]" ]
map a function over a glob pattern, relative to a directory
[ "map", "a", "function", "over", "a", "glob", "pattern", "relative", "to", "a", "directory" ]
train
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/helpers.py#L100-L102
Archived-Object/ligament
ligament/helpers.py
mkdir_recursive
def mkdir_recursive(dirname): """makes all the directories along a given path, if they do not exist""" parent = os.path.dirname(dirname) if parent != "": if not os.path.exists(parent): mkdir_recursive(parent) if not os.path.exists(dirname): os.mkdir(dirname) elif ...
python
def mkdir_recursive(dirname): """makes all the directories along a given path, if they do not exist""" parent = os.path.dirname(dirname) if parent != "": if not os.path.exists(parent): mkdir_recursive(parent) if not os.path.exists(dirname): os.mkdir(dirname) elif ...
[ "def", "mkdir_recursive", "(", "dirname", ")", ":", "parent", "=", "os", ".", "path", ".", "dirname", "(", "dirname", ")", "if", "parent", "!=", "\"\"", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "parent", ")", ":", "mkdir_recursive", "...
makes all the directories along a given path, if they do not exist
[ "makes", "all", "the", "directories", "along", "a", "given", "path", "if", "they", "do", "not", "exist" ]
train
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/helpers.py#L105-L114
Archived-Object/ligament
ligament/helpers.py
indent_text
def indent_text(*strs, **kwargs): """ indents text according to an operater string and a global indentation level. returns a tuple of all passed args, indented according to the operator string indent: [defaults to +0] The operator string, of the form ++n : increment...
python
def indent_text(*strs, **kwargs): """ indents text according to an operater string and a global indentation level. returns a tuple of all passed args, indented according to the operator string indent: [defaults to +0] The operator string, of the form ++n : increment...
[ "def", "indent_text", "(", "*", "strs", ",", "*", "*", "kwargs", ")", ":", "# python 2.7 workaround", "indent", "=", "kwargs", "[", "\"indent\"", "]", "if", "\"indent\"", "in", "kwargs", "else", "\"+0\"", "autobreak", "=", "kwargs", ".", "get", "(", "\"aut...
indents text according to an operater string and a global indentation level. returns a tuple of all passed args, indented according to the operator string indent: [defaults to +0] The operator string, of the form ++n : increments the global indentation level by n and in...
[ "indents", "text", "according", "to", "an", "operater", "string", "and", "a", "global", "indentation", "level", ".", "returns", "a", "tuple", "of", "all", "passed", "args", "indented", "according", "to", "the", "operator", "string" ]
train
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/helpers.py#L142-L203
Archived-Object/ligament
ligament/helpers.py
perror
def perror(*args, **kwargs): """print formatted output to stderr with indentation control""" if should_msg(kwargs.get("groups", ["error"])): # initialize colorama only if uninitialized global colorama_init if not colorama_init: colorama_init = True colorama.init(...
python
def perror(*args, **kwargs): """print formatted output to stderr with indentation control""" if should_msg(kwargs.get("groups", ["error"])): # initialize colorama only if uninitialized global colorama_init if not colorama_init: colorama_init = True colorama.init(...
[ "def", "perror", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "should_msg", "(", "kwargs", ".", "get", "(", "\"groups\"", ",", "[", "\"error\"", "]", ")", ")", ":", "# initialize colorama only if uninitialized", "global", "colorama_init", "if",...
print formatted output to stderr with indentation control
[ "print", "formatted", "output", "to", "stderr", "with", "indentation", "control" ]
train
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/helpers.py#L209-L225
Archived-Object/ligament
ligament/helpers.py
pwarning
def pwarning(*args, **kwargs): """print formatted output to stderr with indentation control""" if should_msg(kwargs.get("groups", ["warning"])): # initialize colorama only if uninitialized global colorama_init if not colorama_init: colorama_init = True colorama.i...
python
def pwarning(*args, **kwargs): """print formatted output to stderr with indentation control""" if should_msg(kwargs.get("groups", ["warning"])): # initialize colorama only if uninitialized global colorama_init if not colorama_init: colorama_init = True colorama.i...
[ "def", "pwarning", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "should_msg", "(", "kwargs", ".", "get", "(", "\"groups\"", ",", "[", "\"warning\"", "]", ")", ")", ":", "# initialize colorama only if uninitialized", "global", "colorama_init", "...
print formatted output to stderr with indentation control
[ "print", "formatted", "output", "to", "stderr", "with", "indentation", "control" ]
train
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/helpers.py#L228-L244
Archived-Object/ligament
ligament/helpers.py
pdebug
def pdebug(*args, **kwargs): """print formatted output to stdout with indentation control""" if should_msg(kwargs.get("groups", ["debug"])): # initialize colorama only if uninitialized global colorama_init if not colorama_init: colorama_init = True colorama.init()...
python
def pdebug(*args, **kwargs): """print formatted output to stdout with indentation control""" if should_msg(kwargs.get("groups", ["debug"])): # initialize colorama only if uninitialized global colorama_init if not colorama_init: colorama_init = True colorama.init()...
[ "def", "pdebug", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "should_msg", "(", "kwargs", ".", "get", "(", "\"groups\"", ",", "[", "\"debug\"", "]", ")", ")", ":", "# initialize colorama only if uninitialized", "global", "colorama_init", "if",...
print formatted output to stdout with indentation control
[ "print", "formatted", "output", "to", "stdout", "with", "indentation", "control" ]
train
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/helpers.py#L247-L262
Archived-Object/ligament
ligament/helpers.py
pout
def pout(*args, **kwargs): """print to stdout, maintaining indent level""" if should_msg(kwargs.get("groups", ["normal"])): args = indent_text(*args, **kwargs) # write to stdout sys.stderr.write("".join(args)) sys.stderr.write("\n")
python
def pout(*args, **kwargs): """print to stdout, maintaining indent level""" if should_msg(kwargs.get("groups", ["normal"])): args = indent_text(*args, **kwargs) # write to stdout sys.stderr.write("".join(args)) sys.stderr.write("\n")
[ "def", "pout", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "should_msg", "(", "kwargs", ".", "get", "(", "\"groups\"", ",", "[", "\"normal\"", "]", ")", ")", ":", "args", "=", "indent_text", "(", "*", "args", ",", "*", "*", "kwargs...
print to stdout, maintaining indent level
[ "print", "to", "stdout", "maintaining", "indent", "level" ]
train
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/helpers.py#L265-L272
Archived-Object/ligament
ligament/helpers.py
urlretrieve
def urlretrieve(url, dest, write_mode="w"): """save a file to disk from a given url""" response = urllib2.urlopen(url) mkdir_recursive(os.path.dirname(dest)) with open(dest, write_mode) as f: f.write(response.read()) f.close()
python
def urlretrieve(url, dest, write_mode="w"): """save a file to disk from a given url""" response = urllib2.urlopen(url) mkdir_recursive(os.path.dirname(dest)) with open(dest, write_mode) as f: f.write(response.read()) f.close()
[ "def", "urlretrieve", "(", "url", ",", "dest", ",", "write_mode", "=", "\"w\"", ")", ":", "response", "=", "urllib2", ".", "urlopen", "(", "url", ")", "mkdir_recursive", "(", "os", ".", "path", ".", "dirname", "(", "dest", ")", ")", "with", "open", "...
save a file to disk from a given url
[ "save", "a", "file", "to", "disk", "from", "a", "given", "url" ]
train
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/helpers.py#L275-L281
Archived-Object/ligament
ligament/helpers.py
remove_dups
def remove_dups(seq): """remove duplicates from a sequence, preserving order""" seen = set() seen_add = seen.add return [x for x in seq if not (x in seen or seen_add(x))]
python
def remove_dups(seq): """remove duplicates from a sequence, preserving order""" seen = set() seen_add = seen.add return [x for x in seq if not (x in seen or seen_add(x))]
[ "def", "remove_dups", "(", "seq", ")", ":", "seen", "=", "set", "(", ")", "seen_add", "=", "seen", ".", "add", "return", "[", "x", "for", "x", "in", "seq", "if", "not", "(", "x", "in", "seen", "or", "seen_add", "(", "x", ")", ")", "]" ]
remove duplicates from a sequence, preserving order
[ "remove", "duplicates", "from", "a", "sequence", "preserving", "order" ]
train
https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/helpers.py#L291-L295
rehandalal/buchner
buchner/helpers.py
json_requested
def json_requested(): """Check if json is the preferred output format for the request.""" best = request.accept_mimetypes.best_match( ['application/json', 'text/html']) return (best == 'application/json' and request.accept_mimetypes[best] > request.accept_mimetypes['text/html...
python
def json_requested(): """Check if json is the preferred output format for the request.""" best = request.accept_mimetypes.best_match( ['application/json', 'text/html']) return (best == 'application/json' and request.accept_mimetypes[best] > request.accept_mimetypes['text/html...
[ "def", "json_requested", "(", ")", ":", "best", "=", "request", ".", "accept_mimetypes", ".", "best_match", "(", "[", "'application/json'", ",", "'text/html'", "]", ")", "return", "(", "best", "==", "'application/json'", "and", "request", ".", "accept_mimetypes"...
Check if json is the preferred output format for the request.
[ "Check", "if", "json", "is", "the", "preferred", "output", "format", "for", "the", "request", "." ]
train
https://github.com/rehandalal/buchner/blob/dc22a61c493b9d4a74d76e8b42a319aa13e385f3/buchner/helpers.py#L13-L19
emin63/eyap
setup.py
get_readme
def get_readme(): 'Get the long description from the README file' here = path.abspath(path.dirname(__file__)) with open(path.join(here, 'README.rst'), encoding='utf-8') as my_fd: result = my_fd.read() return result
python
def get_readme(): 'Get the long description from the README file' here = path.abspath(path.dirname(__file__)) with open(path.join(here, 'README.rst'), encoding='utf-8') as my_fd: result = my_fd.read() return result
[ "def", "get_readme", "(", ")", ":", "here", "=", "path", ".", "abspath", "(", "path", ".", "dirname", "(", "__file__", ")", ")", "with", "open", "(", "path", ".", "join", "(", "here", ",", "'README.rst'", ")", ",", "encoding", "=", "'utf-8'", ")", ...
Get the long description from the README file
[ "Get", "the", "long", "description", "from", "the", "README", "file" ]
train
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/setup.py#L14-L21
shaded-enmity/docker-hica
injectors/libs.py
LibraryInjector.inject_config
def inject_config(self, config, from_args): """ :param config: :type config: list :param from_args: :type from_args: dict """ load_libs = self._get_libs() all_libs = {} found_libs = [] for root, dirs, files in os.walk(library_path): for f in files: if not f.e...
python
def inject_config(self, config, from_args): """ :param config: :type config: list :param from_args: :type from_args: dict """ load_libs = self._get_libs() all_libs = {} found_libs = [] for root, dirs, files in os.walk(library_path): for f in files: if not f.e...
[ "def", "inject_config", "(", "self", ",", "config", ",", "from_args", ")", ":", "load_libs", "=", "self", ".", "_get_libs", "(", ")", "all_libs", "=", "{", "}", "found_libs", "=", "[", "]", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", ...
:param config: :type config: list :param from_args: :type from_args: dict
[ ":", "param", "config", ":", ":", "type", "config", ":", "list", ":", "param", "from_args", ":", ":", "type", "from_args", ":", "dict" ]
train
https://github.com/shaded-enmity/docker-hica/blob/bc425586297e1eb228b70ee6fca8c499849ec87d/injectors/libs.py#L27-L63
pacificclimate/cfmeta
cfmeta/cmipfile.py
get_nc_attrs
def get_nc_attrs(nc): """Gets netCDF file metadata attributes. Arguments: nc (netCDF4.Dataset): an open NetCDF4 Dataset to pull attributes from. Returns: dict: Metadata as extracted from the netCDF file. """ meta = { 'experiment': nc.experiment_id, 'frequency': nc....
python
def get_nc_attrs(nc): """Gets netCDF file metadata attributes. Arguments: nc (netCDF4.Dataset): an open NetCDF4 Dataset to pull attributes from. Returns: dict: Metadata as extracted from the netCDF file. """ meta = { 'experiment': nc.experiment_id, 'frequency': nc....
[ "def", "get_nc_attrs", "(", "nc", ")", ":", "meta", "=", "{", "'experiment'", ":", "nc", ".", "experiment_id", ",", "'frequency'", ":", "nc", ".", "frequency", ",", "'institute'", ":", "nc", ".", "institute_id", ",", "'model'", ":", "nc", ".", "model_id"...
Gets netCDF file metadata attributes. Arguments: nc (netCDF4.Dataset): an open NetCDF4 Dataset to pull attributes from. Returns: dict: Metadata as extracted from the netCDF file.
[ "Gets", "netCDF", "file", "metadata", "attributes", "." ]
train
https://github.com/pacificclimate/cfmeta/blob/a6eef78d0bce523bb44920ba96233f034b60316a/cfmeta/cmipfile.py#L151-L174
pacificclimate/cfmeta
cfmeta/cmipfile.py
get_var_name
def get_var_name(nc): """Guesses the variable_name of an open NetCDF file """ non_variable_names = [ 'lat', 'lat_bnds', 'lon', 'lon_bnds', 'time', 'latitude', 'longitude', 'bnds' ] _vars = set(nc.variables.keys()) _vars.difference...
python
def get_var_name(nc): """Guesses the variable_name of an open NetCDF file """ non_variable_names = [ 'lat', 'lat_bnds', 'lon', 'lon_bnds', 'time', 'latitude', 'longitude', 'bnds' ] _vars = set(nc.variables.keys()) _vars.difference...
[ "def", "get_var_name", "(", "nc", ")", ":", "non_variable_names", "=", "[", "'lat'", ",", "'lat_bnds'", ",", "'lon'", ",", "'lon_bnds'", ",", "'time'", ",", "'latitude'", ",", "'longitude'", ",", "'bnds'", "]", "_vars", "=", "set", "(", "nc", ".", "varia...
Guesses the variable_name of an open NetCDF file
[ "Guesses", "the", "variable_name", "of", "an", "open", "NetCDF", "file" ]
train
https://github.com/pacificclimate/cfmeta/blob/a6eef78d0bce523bb44920ba96233f034b60316a/cfmeta/cmipfile.py#L176-L195
pacificclimate/cfmeta
cfmeta/cmipfile.py
CmipFile._update_known_atts
def _update_known_atts(self, **kwargs): """Updates instance attributes with supplied keyword arguments. """ for k, v in kwargs.items(): if k not in ATTR_KEYS: # Warn if passed in unknown kwargs raise SyntaxWarning('Unknown argument: {}'.format(k)) ...
python
def _update_known_atts(self, **kwargs): """Updates instance attributes with supplied keyword arguments. """ for k, v in kwargs.items(): if k not in ATTR_KEYS: # Warn if passed in unknown kwargs raise SyntaxWarning('Unknown argument: {}'.format(k)) ...
[ "def", "_update_known_atts", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "if", "k", "not", "in", "ATTR_KEYS", ":", "# Warn if passed in unknown kwargs", "raise", "SyntaxWarning", "(", ...
Updates instance attributes with supplied keyword arguments.
[ "Updates", "instance", "attributes", "with", "supplied", "keyword", "arguments", "." ]
train
https://github.com/pacificclimate/cfmeta/blob/a6eef78d0bce523bb44920ba96233f034b60316a/cfmeta/cmipfile.py#L57-L67
pacificclimate/cfmeta
cfmeta/cmipfile.py
CmipFile.get_joined_dir_name
def get_joined_dir_name(self, atts): """Returns a joined path populated with the supplied attribute names """ return os.path.join(*[getattr(self, x) for x in atts])
python
def get_joined_dir_name(self, atts): """Returns a joined path populated with the supplied attribute names """ return os.path.join(*[getattr(self, x) for x in atts])
[ "def", "get_joined_dir_name", "(", "self", ",", "atts", ")", ":", "return", "os", ".", "path", ".", "join", "(", "*", "[", "getattr", "(", "self", ",", "x", ")", "for", "x", "in", "atts", "]", ")" ]
Returns a joined path populated with the supplied attribute names
[ "Returns", "a", "joined", "path", "populated", "with", "the", "supplied", "attribute", "names" ]
train
https://github.com/pacificclimate/cfmeta/blob/a6eef78d0bce523bb44920ba96233f034b60316a/cfmeta/cmipfile.py#L136-L140
pacificclimate/cfmeta
cfmeta/cmipfile.py
CmipFile.get_joined_file_name
def get_joined_file_name(self, atts, optional_atts = None): """Returns a joined path populated with the supplied attribute names """ return '_'.join( [getattr(self, x) for x in atts] + [getattr(self, x) for x in optional_atts if x in self.__dict__] ) + '.nc'
python
def get_joined_file_name(self, atts, optional_atts = None): """Returns a joined path populated with the supplied attribute names """ return '_'.join( [getattr(self, x) for x in atts] + [getattr(self, x) for x in optional_atts if x in self.__dict__] ) + '.nc'
[ "def", "get_joined_file_name", "(", "self", ",", "atts", ",", "optional_atts", "=", "None", ")", ":", "return", "'_'", ".", "join", "(", "[", "getattr", "(", "self", ",", "x", ")", "for", "x", "in", "atts", "]", "+", "[", "getattr", "(", "self", ",...
Returns a joined path populated with the supplied attribute names
[ "Returns", "a", "joined", "path", "populated", "with", "the", "supplied", "attribute", "names" ]
train
https://github.com/pacificclimate/cfmeta/blob/a6eef78d0bce523bb44920ba96233f034b60316a/cfmeta/cmipfile.py#L142-L149
redbridge/molnctrl
molnctrl/cachemaker.py
savecache
def savecache(apicache, json_file): """ Saves apicache dictionary as json_file, returns dictionary as indented str """ if apicache is None or apicache is {}: return "" apicachestr = json.dumps(apicache, indent=2) with open(json_file, 'w') as cache_file: cache_file.write(apicaches...
python
def savecache(apicache, json_file): """ Saves apicache dictionary as json_file, returns dictionary as indented str """ if apicache is None or apicache is {}: return "" apicachestr = json.dumps(apicache, indent=2) with open(json_file, 'w') as cache_file: cache_file.write(apicaches...
[ "def", "savecache", "(", "apicache", ",", "json_file", ")", ":", "if", "apicache", "is", "None", "or", "apicache", "is", "{", "}", ":", "return", "\"\"", "apicachestr", "=", "json", ".", "dumps", "(", "apicache", ",", "indent", "=", "2", ")", "with", ...
Saves apicache dictionary as json_file, returns dictionary as indented str
[ "Saves", "apicache", "dictionary", "as", "json_file", "returns", "dictionary", "as", "indented", "str" ]
train
https://github.com/redbridge/molnctrl/blob/9990ae7e522ce364bb61a735f774dc28de5f8e60/molnctrl/cachemaker.py#L55-L64
redbridge/molnctrl
molnctrl/cachemaker.py
loadcache
def loadcache(json_file): """ Loads json file as dictionary, feeds it to monkeycache and spits result """ f = open(json_file, 'r') data = f.read() f.close() try: apicache = json.loads(data) except ValueError as e: print("Error processing json:", json_file, e) retu...
python
def loadcache(json_file): """ Loads json file as dictionary, feeds it to monkeycache and spits result """ f = open(json_file, 'r') data = f.read() f.close() try: apicache = json.loads(data) except ValueError as e: print("Error processing json:", json_file, e) retu...
[ "def", "loadcache", "(", "json_file", ")", ":", "f", "=", "open", "(", "json_file", ",", "'r'", ")", "data", "=", "f", ".", "read", "(", ")", "f", ".", "close", "(", ")", "try", ":", "apicache", "=", "json", ".", "loads", "(", "data", ")", "exc...
Loads json file as dictionary, feeds it to monkeycache and spits result
[ "Loads", "json", "file", "as", "dictionary", "feeds", "it", "to", "monkeycache", "and", "spits", "result" ]
train
https://github.com/redbridge/molnctrl/blob/9990ae7e522ce364bb61a735f774dc28de5f8e60/molnctrl/cachemaker.py#L67-L79
redbridge/molnctrl
molnctrl/cachemaker.py
monkeycache
def monkeycache(apis): """ Feed this a dictionary of api bananas, it spits out processed cache """ if isinstance(type(apis), type(None)) or apis is None: return {} verbs = set() cache = {} cache['count'] = apis['count'] cache['asyncapis'] = [] apilist = apis['api'] if a...
python
def monkeycache(apis): """ Feed this a dictionary of api bananas, it spits out processed cache """ if isinstance(type(apis), type(None)) or apis is None: return {} verbs = set() cache = {} cache['count'] = apis['count'] cache['asyncapis'] = [] apilist = apis['api'] if a...
[ "def", "monkeycache", "(", "apis", ")", ":", "if", "isinstance", "(", "type", "(", "apis", ")", ",", "type", "(", "None", ")", ")", "or", "apis", "is", "None", ":", "return", "{", "}", "verbs", "=", "set", "(", ")", "cache", "=", "{", "}", "cac...
Feed this a dictionary of api bananas, it spits out processed cache
[ "Feed", "this", "a", "dictionary", "of", "api", "bananas", "it", "spits", "out", "processed", "cache" ]
train
https://github.com/redbridge/molnctrl/blob/9990ae7e522ce364bb61a735f774dc28de5f8e60/molnctrl/cachemaker.py#L82-L132
redbridge/molnctrl
molnctrl/cachemaker.py
main
def main(json_file): """ cachemaker.py creates a precache datastore of all available apis of CloudStack and dumps the precache dictionary in an importable python module. This way we cheat on the runtime overhead of completing commands and help docs. This reduces the overall search and cache_miss...
python
def main(json_file): """ cachemaker.py creates a precache datastore of all available apis of CloudStack and dumps the precache dictionary in an importable python module. This way we cheat on the runtime overhead of completing commands and help docs. This reduces the overall search and cache_miss...
[ "def", "main", "(", "json_file", ")", ":", "f", "=", "open", "(", "\"precache.py\"", ",", "\"w\"", ")", "f", ".", "write", "(", "\"\"\"# -*- coding: utf-8 -*-\n# Auto-generated code by cachemaker.py\n# Licensed to the Apache Software Foundation (ASF) under one\n# or more contribu...
cachemaker.py creates a precache datastore of all available apis of CloudStack and dumps the precache dictionary in an importable python module. This way we cheat on the runtime overhead of completing commands and help docs. This reduces the overall search and cache_miss (computation) complexity from O(...
[ "cachemaker", ".", "py", "creates", "a", "precache", "datastore", "of", "all", "available", "apis", "of", "CloudStack", "and", "dumps", "the", "precache", "dictionary", "in", "an", "importable", "python", "module", ".", "This", "way", "we", "cheat", "on", "t...
train
https://github.com/redbridge/molnctrl/blob/9990ae7e522ce364bb61a735f774dc28de5f8e60/molnctrl/cachemaker.py#L135-L163
zagfai/webtul
webtul/db.py
MySQL.execute
def execute(self, sql, param=(), times=1): """This function is the most use one, with the paramter times it will try x times to execute the sql, default is 1. """ self.log and self.log.debug('%s %s' % ('SQL:', sql)) if param is not (): self.log and self.log.debug('%s ...
python
def execute(self, sql, param=(), times=1): """This function is the most use one, with the paramter times it will try x times to execute the sql, default is 1. """ self.log and self.log.debug('%s %s' % ('SQL:', sql)) if param is not (): self.log and self.log.debug('%s ...
[ "def", "execute", "(", "self", ",", "sql", ",", "param", "=", "(", ")", ",", "times", "=", "1", ")", ":", "self", ".", "log", "and", "self", ".", "log", ".", "debug", "(", "'%s %s'", "%", "(", "'SQL:'", ",", "sql", ")", ")", "if", "param", "i...
This function is the most use one, with the paramter times it will try x times to execute the sql, default is 1.
[ "This", "function", "is", "the", "most", "use", "one", "with", "the", "paramter", "times", "it", "will", "try", "x", "times", "to", "execute", "the", "sql", "default", "is", "1", "." ]
train
https://github.com/zagfai/webtul/blob/58c49928070b56ef54a45b4af20d800b269ad8ce/webtul/db.py#L50-L66
zagfai/webtul
webtul/db.py
MySQL.connect
def connect(self): """obj.connect() => True or raise Error from MySQLdb. You aren't suggested to use this function by your hand, because this func may cause Exception. """ self.conn = self.db_module.connect( host=self.host, port=int(self.port), user=self.user, ...
python
def connect(self): """obj.connect() => True or raise Error from MySQLdb. You aren't suggested to use this function by your hand, because this func may cause Exception. """ self.conn = self.db_module.connect( host=self.host, port=int(self.port), user=self.user, ...
[ "def", "connect", "(", "self", ")", ":", "self", ".", "conn", "=", "self", ".", "db_module", ".", "connect", "(", "host", "=", "self", ".", "host", ",", "port", "=", "int", "(", "self", ".", "port", ")", ",", "user", "=", "self", ".", "user", "...
obj.connect() => True or raise Error from MySQLdb. You aren't suggested to use this function by your hand, because this func may cause Exception.
[ "obj", ".", "connect", "()", "=", ">", "True", "or", "raise", "Error", "from", "MySQLdb", ".", "You", "aren", "t", "suggested", "to", "use", "this", "function", "by", "your", "hand", "because", "this", "func", "may", "cause", "Exception", "." ]
train
https://github.com/zagfai/webtul/blob/58c49928070b56ef54a45b4af20d800b269ad8ce/webtul/db.py#L68-L78
openp2pdesign/makerlabs
makerlabs/fablabs_io.py
get_labs
def get_labs(format): """Gets Fab Lab data from fablabs.io.""" fablabs_json = data_from_fablabs_io(fablabs_io_labs_api_url_v0) fablabs = {} # Load all the FabLabs for i in fablabs_json["labs"]: current_lab = FabLab() current_lab.name = i["name"] current_lab.address_1 = i["a...
python
def get_labs(format): """Gets Fab Lab data from fablabs.io.""" fablabs_json = data_from_fablabs_io(fablabs_io_labs_api_url_v0) fablabs = {} # Load all the FabLabs for i in fablabs_json["labs"]: current_lab = FabLab() current_lab.name = i["name"] current_lab.address_1 = i["a...
[ "def", "get_labs", "(", "format", ")", ":", "fablabs_json", "=", "data_from_fablabs_io", "(", "fablabs_io_labs_api_url_v0", ")", "fablabs", "=", "{", "}", "# Load all the FabLabs", "for", "i", "in", "fablabs_json", "[", "\"labs\"", "]", ":", "current_lab", "=", ...
Gets Fab Lab data from fablabs.io.
[ "Gets", "Fab", "Lab", "data", "from", "fablabs", ".", "io", "." ]
train
https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/fablabs_io.py#L82-L172
openp2pdesign/makerlabs
makerlabs/fablabs_io.py
get_projects
def get_projects(format): """Gets projects data from fablabs.io.""" projects_json = data_from_fablabs_io(fablabs_io_projects_api_url_v0) projects = {} project_url = "https://www.fablabs.io/projects/" fablabs = get_labs(format="object") # Load all the FabLabs for i in projects_json["project...
python
def get_projects(format): """Gets projects data from fablabs.io.""" projects_json = data_from_fablabs_io(fablabs_io_projects_api_url_v0) projects = {} project_url = "https://www.fablabs.io/projects/" fablabs = get_labs(format="object") # Load all the FabLabs for i in projects_json["project...
[ "def", "get_projects", "(", "format", ")", ":", "projects_json", "=", "data_from_fablabs_io", "(", "fablabs_io_projects_api_url_v0", ")", "projects", "=", "{", "}", "project_url", "=", "\"https://www.fablabs.io/projects/\"", "fablabs", "=", "get_labs", "(", "format", ...
Gets projects data from fablabs.io.
[ "Gets", "projects", "data", "from", "fablabs", ".", "io", "." ]
train
https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/fablabs_io.py#L183-L269
boisgera/about
about/__init__.py
get_metadata
def get_metadata(source): """ Extract the metadata from the module or dict argument. It returns a `metadata` dictionary that provides keywords arguments for the setuptools `setup` function. """ if isinstance(source, types.ModuleType): metadata = source.__dict__ else: metadat...
python
def get_metadata(source): """ Extract the metadata from the module or dict argument. It returns a `metadata` dictionary that provides keywords arguments for the setuptools `setup` function. """ if isinstance(source, types.ModuleType): metadata = source.__dict__ else: metadat...
[ "def", "get_metadata", "(", "source", ")", ":", "if", "isinstance", "(", "source", ",", "types", ".", "ModuleType", ")", ":", "metadata", "=", "source", ".", "__dict__", "else", ":", "metadata", "=", "source", "setuptools_kwargs", "=", "{", "}", "for", "...
Extract the metadata from the module or dict argument. It returns a `metadata` dictionary that provides keywords arguments for the setuptools `setup` function.
[ "Extract", "the", "metadata", "from", "the", "module", "or", "dict", "argument", "." ]
train
https://github.com/boisgera/about/blob/ae16b015377250fe9df11848ea11ddaa9df54ffa/about/__init__.py#L87-L149
Apitax/Apitax
apitax/api/controllers/scriptax_controller.py
create_driver_script
def create_driver_script(driver, script_create=None): # noqa: E501 """Create a new script Create a new script # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :param script_create: The data needed to create this script :type script_create: dict | byt...
python
def create_driver_script(driver, script_create=None): # noqa: E501 """Create a new script Create a new script # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :param script_create: The data needed to create this script :type script_create: dict | byt...
[ "def", "create_driver_script", "(", "driver", ",", "script_create", "=", "None", ")", ":", "# noqa: E501", "if", "connexion", ".", "request", ".", "is_json", ":", "script_create", "=", "ScriptCreate", ".", "from_dict", "(", "connexion", ".", "request", ".", "g...
Create a new script Create a new script # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :param script_create: The data needed to create this script :type script_create: dict | bytes :rtype: Response
[ "Create", "a", "new", "script" ]
train
https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/scriptax_controller.py#L20-L44
Apitax/Apitax
apitax/api/controllers/scriptax_controller.py
delete_driver_script
def delete_driver_script(driver, script_delete=None): # noqa: E501 """Delete a script Delete a script # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :param script_delete: The data needed to delete this script :type script_delete: dict | bytes ...
python
def delete_driver_script(driver, script_delete=None): # noqa: E501 """Delete a script Delete a script # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :param script_delete: The data needed to delete this script :type script_delete: dict | bytes ...
[ "def", "delete_driver_script", "(", "driver", ",", "script_delete", "=", "None", ")", ":", "# noqa: E501", "if", "connexion", ".", "request", ".", "is_json", ":", "script_delete", "=", "ScriptDelete", ".", "from_dict", "(", "connexion", ".", "request", ".", "g...
Delete a script Delete a script # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :param script_delete: The data needed to delete this script :type script_delete: dict | bytes :rtype: Response
[ "Delete", "a", "script" ]
train
https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/scriptax_controller.py#L47-L71
Apitax/Apitax
apitax/api/controllers/scriptax_controller.py
get_driver_script
def get_driver_script(driver, script=None): # noqa: E501 """Retrieve the contents of a script Retrieve the contents of a script # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :param script: The script name. :type script: str :rtype: Response ...
python
def get_driver_script(driver, script=None): # noqa: E501 """Retrieve the contents of a script Retrieve the contents of a script # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :param script: The script name. :type script: str :rtype: Response ...
[ "def", "get_driver_script", "(", "driver", ",", "script", "=", "None", ")", ":", "# noqa: E501", "response", "=", "errorIfUnauthorized", "(", "role", "=", "'user'", ")", "if", "response", ":", "return", "response", "else", ":", "response", "=", "ApitaxResponse...
Retrieve the contents of a script Retrieve the contents of a script # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :param script: The script name. :type script: str :rtype: Response
[ "Retrieve", "the", "contents", "of", "a", "script" ]
train
https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/scriptax_controller.py#L74-L97
Apitax/Apitax
apitax/api/controllers/scriptax_controller.py
save_driver_script
def save_driver_script(driver, script_save=None): # noqa: E501 """Save a script Save a script # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :param script_save: The data needed to save this script :type script_save: dict | bytes :rtype: Respon...
python
def save_driver_script(driver, script_save=None): # noqa: E501 """Save a script Save a script # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :param script_save: The data needed to save this script :type script_save: dict | bytes :rtype: Respon...
[ "def", "save_driver_script", "(", "driver", ",", "script_save", "=", "None", ")", ":", "# noqa: E501", "if", "connexion", ".", "request", ".", "is_json", ":", "script_save", "=", "ScriptSave", ".", "from_dict", "(", "connexion", ".", "request", ".", "get_json"...
Save a script Save a script # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :param script_save: The data needed to save this script :type script_save: dict | bytes :rtype: Response
[ "Save", "a", "script" ]
train
https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/scriptax_controller.py#L152-L176
shi-cong/PYSTUDY
PYSTUDY/stringlib.py
to_bytes
def to_bytes(s): """ 将字符串转换成字节数组 :param s: 要转换成字节数组的字符串 :return: 转换成字节数组的字符串 """ if bytes != str: if type(s) == str: return s.encode('utf-8') return s
python
def to_bytes(s): """ 将字符串转换成字节数组 :param s: 要转换成字节数组的字符串 :return: 转换成字节数组的字符串 """ if bytes != str: if type(s) == str: return s.encode('utf-8') return s
[ "def", "to_bytes", "(", "s", ")", ":", "if", "bytes", "!=", "str", ":", "if", "type", "(", "s", ")", "==", "str", ":", "return", "s", ".", "encode", "(", "'utf-8'", ")", "return", "s" ]
将字符串转换成字节数组 :param s: 要转换成字节数组的字符串 :return: 转换成字节数组的字符串
[ "将字符串转换成字节数组", ":", "param", "s", ":", "要转换成字节数组的字符串", ":", "return", ":", "转换成字节数组的字符串" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/stringlib.py#L53-L62
shi-cong/PYSTUDY
PYSTUDY/stringlib.py
to_str
def to_str(s): """ 将字节数组转成成字符串 :param s: 字节数组 :return: 字符串 """ if bytes != str: """ 这里的比较在python2中是True,在Python3中是False """ if type(s) == bytes: return s.decode('utf-8') return s
python
def to_str(s): """ 将字节数组转成成字符串 :param s: 字节数组 :return: 字符串 """ if bytes != str: """ 这里的比较在python2中是True,在Python3中是False """ if type(s) == bytes: return s.decode('utf-8') return s
[ "def", "to_str", "(", "s", ")", ":", "if", "bytes", "!=", "str", ":", "\"\"\"\n 这里的比较在python2中是True,在Python3中是False\n \"\"\"", "if", "type", "(", "s", ")", "==", "bytes", ":", "return", "s", ".", "decode", "(", "'utf-8'", ")", "return", "s" ]
将字节数组转成成字符串 :param s: 字节数组 :return: 字符串
[ "将字节数组转成成字符串", ":", "param", "s", ":", "字节数组", ":", "return", ":", "字符串" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/stringlib.py#L65-L77
salimm/msgpack-pystream
msgpackstream/backend/pyc/stream.py
StreamUnpacker.process
def process(self, buff): ''' Process the input buffer. The buffer can contains all or a segment of the bytes from the complete message. The function will buffer what will require extra bytes to be processed. :param buff: ''' (self._stack, self._memory, scstateid...
python
def process(self, buff): ''' Process the input buffer. The buffer can contains all or a segment of the bytes from the complete message. The function will buffer what will require extra bytes to be processed. :param buff: ''' (self._stack, self._memory, scstateid...
[ "def", "process", "(", "self", ",", "buff", ")", ":", "(", "self", ".", "_stack", ",", "self", ".", "_memory", ",", "scstateidx", ",", "self", ".", "_state", ",", "tmpevents", ",", "self", ".", "_waitingforprop", ",", "self", ".", "_parentismap", ")", ...
Process the input buffer. The buffer can contains all or a segment of the bytes from the complete message. The function will buffer what will require extra bytes to be processed. :param buff:
[ "Process", "the", "input", "buffer", ".", "The", "buffer", "can", "contains", "all", "or", "a", "segment", "of", "the", "bytes", "from", "the", "complete", "message", ".", "The", "function", "will", "buffer", "what", "will", "require", "extra", "bytes", "t...
train
https://github.com/salimm/msgpack-pystream/blob/676158a5a8dd8ff56dca080d597943f67fc4325e/msgpackstream/backend/pyc/stream.py#L35-L45
donovan-duplessis/pwnurl
manage.py
profile
def profile(length=25): """ Start the application under the code profiler """ from werkzeug.contrib.profiler import ProfilerMiddleware app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[length]) app.run()
python
def profile(length=25): """ Start the application under the code profiler """ from werkzeug.contrib.profiler import ProfilerMiddleware app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[length]) app.run()
[ "def", "profile", "(", "length", "=", "25", ")", ":", "from", "werkzeug", ".", "contrib", ".", "profiler", "import", "ProfilerMiddleware", "app", ".", "wsgi_app", "=", "ProfilerMiddleware", "(", "app", ".", "wsgi_app", ",", "restrictions", "=", "[", "length"...
Start the application under the code profiler
[ "Start", "the", "application", "under", "the", "code", "profiler" ]
train
https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/manage.py#L63-L68
donovan-duplessis/pwnurl
manage.py
_help
def _help(): """ Display both SQLAlchemy and Python help statements """ statement = '%s%s' % (shelp, phelp % ', '.join(cntx_.keys())) print statement.strip()
python
def _help(): """ Display both SQLAlchemy and Python help statements """ statement = '%s%s' % (shelp, phelp % ', '.join(cntx_.keys())) print statement.strip()
[ "def", "_help", "(", ")", ":", "statement", "=", "'%s%s'", "%", "(", "shelp", ",", "phelp", "%", "', '", ".", "join", "(", "cntx_", ".", "keys", "(", ")", ")", ")", "print", "statement", ".", "strip", "(", ")" ]
Display both SQLAlchemy and Python help statements
[ "Display", "both", "SQLAlchemy", "and", "Python", "help", "statements" ]
train
https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/manage.py#L71-L75
beylsp/unisquid
unisquid/liveserver.py
LiveServerThread.run
def run(self): """ Sets up live server, and then loops over handling http requests. """ try: # Go through the list of possible ports, hoping we can find # one that is free to use for the WSGI server. for index, port in enumerate(self.possible_ports): ...
python
def run(self): """ Sets up live server, and then loops over handling http requests. """ try: # Go through the list of possible ports, hoping we can find # one that is free to use for the WSGI server. for index, port in enumerate(self.possible_ports): ...
[ "def", "run", "(", "self", ")", ":", "try", ":", "# Go through the list of possible ports, hoping we can find", "# one that is free to use for the WSGI server.", "for", "index", ",", "port", "in", "enumerate", "(", "self", ".", "possible_ports", ")", ":", "try", ":", ...
Sets up live server, and then loops over handling http requests.
[ "Sets", "up", "live", "server", "and", "then", "loops", "over", "handling", "http", "requests", "." ]
train
https://github.com/beylsp/unisquid/blob/880787a2b6c9051b7f82a7f721434819984003e2/unisquid/liveserver.py#L29-L59
OpenGov/carpenter
carpenter/carpenter.py
append_column
def append_column(table, col_name, default_value=None): ''' Appends a column to the raw data without any integrity checks. Args: default_value: The value which will assigned, not copied into each row ''' table[0].append(col_name.strip()) for row in table[1:]: row.append...
python
def append_column(table, col_name, default_value=None): ''' Appends a column to the raw data without any integrity checks. Args: default_value: The value which will assigned, not copied into each row ''' table[0].append(col_name.strip()) for row in table[1:]: row.append...
[ "def", "append_column", "(", "table", ",", "col_name", ",", "default_value", "=", "None", ")", ":", "table", "[", "0", "]", ".", "append", "(", "col_name", ".", "strip", "(", ")", ")", "for", "row", "in", "table", "[", "1", ":", "]", ":", "row", ...
Appends a column to the raw data without any integrity checks. Args: default_value: The value which will assigned, not copied into each row
[ "Appends", "a", "column", "to", "the", "raw", "data", "without", "any", "integrity", "checks", ".", "Args", ":", "default_value", ":", "The", "value", "which", "will", "assigned", "not", "copied", "into", "each", "row" ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/carpenter.py#L5-L14
OpenGov/carpenter
carpenter/carpenter.py
remove_column
def remove_column(table, remove_index): ''' Removes the specified column from the table. ''' for row_index in range(len(table)): old_row = table[row_index] new_row = [] for column_index in range(len(old_row)): if column_index !=...
python
def remove_column(table, remove_index): ''' Removes the specified column from the table. ''' for row_index in range(len(table)): old_row = table[row_index] new_row = [] for column_index in range(len(old_row)): if column_index !=...
[ "def", "remove_column", "(", "table", ",", "remove_index", ")", ":", "for", "row_index", "in", "range", "(", "len", "(", "table", ")", ")", ":", "old_row", "=", "table", "[", "row_index", "]", "new_row", "=", "[", "]", "for", "column_index", "in", "ran...
Removes the specified column from the table.
[ "Removes", "the", "specified", "column", "from", "the", "table", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/carpenter.py#L16-L27
OpenGov/carpenter
carpenter/carpenter.py
insert_column
def insert_column(table, insert_column, col_name=None, default_value=None): ''' Inserts a new column before another specified column (by name or index). Args: insert_column: The column index or first row name where the insertion should occur col_name: The name to insert into the first...
python
def insert_column(table, insert_column, col_name=None, default_value=None): ''' Inserts a new column before another specified column (by name or index). Args: insert_column: The column index or first row name where the insertion should occur col_name: The name to insert into the first...
[ "def", "insert_column", "(", "table", ",", "insert_column", ",", "col_name", "=", "None", ",", "default_value", "=", "None", ")", ":", "column_labels", "=", "table", "[", "0", "]", "following_index", "=", "0", "def", "set_cell", "(", "row", ",", "column_in...
Inserts a new column before another specified column (by name or index). Args: insert_column: The column index or first row name where the insertion should occur col_name: The name to insert into the first row of the column. Leaving this argument to the default of None will apply t...
[ "Inserts", "a", "new", "column", "before", "another", "specified", "column", "(", "by", "name", "or", "index", ")", ".", "Args", ":", "insert_column", ":", "The", "column", "index", "or", "first", "row", "name", "where", "the", "insertion", "should", "occu...
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/carpenter.py#L29-L66
OpenGov/carpenter
carpenter/carpenter.py
stitch_block
def stitch_block(block_list): ''' Stitches blocks together into a single block columnwise. These blocks are 2D tables usually generated from tableproc. The final block will be of dimensions (max(num_rows), sum(num_cols)). ''' block_out = [[]] for block in block_list: num_row = len...
python
def stitch_block(block_list): ''' Stitches blocks together into a single block columnwise. These blocks are 2D tables usually generated from tableproc. The final block will be of dimensions (max(num_rows), sum(num_cols)). ''' block_out = [[]] for block in block_list: num_row = len...
[ "def", "stitch_block", "(", "block_list", ")", ":", "block_out", "=", "[", "[", "]", "]", "for", "block", "in", "block_list", ":", "num_row", "=", "len", "(", "block", ")", "row_len", "=", "len", "(", "block", "[", "0", "]", ")", "if", "len", "(", ...
Stitches blocks together into a single block columnwise. These blocks are 2D tables usually generated from tableproc. The final block will be of dimensions (max(num_rows), sum(num_cols)).
[ "Stitches", "blocks", "together", "into", "a", "single", "block", "columnwise", ".", "These", "blocks", "are", "2D", "tables", "usually", "generated", "from", "tableproc", ".", "The", "final", "block", "will", "be", "of", "dimensions", "(", "max", "(", "num_...
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/carpenter.py#L68-L85
OpenGov/carpenter
carpenter/carpenter.py
stitch_block_rows
def stitch_block_rows(block_list): ''' Stitches blocks together into a single block rowwise. These blocks are 2D tables usually generated from tableproc. The final block will be of dimensions (sum(num_rows), max(num_cols)). ''' stitched = list(itertools.chain(*block_list)) max_length = max...
python
def stitch_block_rows(block_list): ''' Stitches blocks together into a single block rowwise. These blocks are 2D tables usually generated from tableproc. The final block will be of dimensions (sum(num_rows), max(num_cols)). ''' stitched = list(itertools.chain(*block_list)) max_length = max...
[ "def", "stitch_block_rows", "(", "block_list", ")", ":", "stitched", "=", "list", "(", "itertools", ".", "chain", "(", "*", "block_list", ")", ")", "max_length", "=", "max", "(", "len", "(", "row", ")", "for", "row", "in", "stitched", ")", "for", "row"...
Stitches blocks together into a single block rowwise. These blocks are 2D tables usually generated from tableproc. The final block will be of dimensions (sum(num_rows), max(num_cols)).
[ "Stitches", "blocks", "together", "into", "a", "single", "block", "rowwise", ".", "These", "blocks", "are", "2D", "tables", "usually", "generated", "from", "tableproc", ".", "The", "final", "block", "will", "be", "of", "dimensions", "(", "sum", "(", "num_row...
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/carpenter.py#L87-L97
OpenGov/carpenter
carpenter/carpenter.py
row_content_length
def row_content_length(row): ''' Returns the length of non-empty content in a given row. ''' if not row: return 0 try: return (index + 1 for index, cell in reversed(list(enumerate(row))) if not is_empty_cell(cell)).next() except StopIteration: return len(row)
python
def row_content_length(row): ''' Returns the length of non-empty content in a given row. ''' if not row: return 0 try: return (index + 1 for index, cell in reversed(list(enumerate(row))) if not is_empty_cell(cell)).next() except StopIteration: return len(row)
[ "def", "row_content_length", "(", "row", ")", ":", "if", "not", "row", ":", "return", "0", "try", ":", "return", "(", "index", "+", "1", "for", "index", ",", "cell", "in", "reversed", "(", "list", "(", "enumerate", "(", "row", ")", ")", ")", "if", ...
Returns the length of non-empty content in a given row.
[ "Returns", "the", "length", "of", "non", "-", "empty", "content", "in", "a", "given", "row", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/carpenter.py#L99-L108
OpenGov/carpenter
carpenter/carpenter.py
split_block_by_row_length
def split_block_by_row_length(block, split_row_length): ''' Splits the block by finding all rows with less consequetive, non-empty rows than the min_row_length input. ''' split_blocks = [] current_block = [] for row in block: if row_content_length(row) <= split_row_length: ...
python
def split_block_by_row_length(block, split_row_length): ''' Splits the block by finding all rows with less consequetive, non-empty rows than the min_row_length input. ''' split_blocks = [] current_block = [] for row in block: if row_content_length(row) <= split_row_length: ...
[ "def", "split_block_by_row_length", "(", "block", ",", "split_row_length", ")", ":", "split_blocks", "=", "[", "]", "current_block", "=", "[", "]", "for", "row", "in", "block", ":", "if", "row_content_length", "(", "row", ")", "<=", "split_row_length", ":", ...
Splits the block by finding all rows with less consequetive, non-empty rows than the min_row_length input.
[ "Splits", "the", "block", "by", "finding", "all", "rows", "with", "less", "consequetive", "non", "-", "empty", "rows", "than", "the", "min_row_length", "input", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/carpenter.py#L110-L128
MacHu-GWU/angora-project
angora/zzz_manual_install.py
check_need_install
def check_need_install(): """Check if installed package are exactly the same to this one. """ md5_root, md5_dst = list(), list() need_install_flag = False for root, _, basename_list in os.walk(_ROOT): if os.path.basename(root) != "__pycache__": for basename in basename_list: ...
python
def check_need_install(): """Check if installed package are exactly the same to this one. """ md5_root, md5_dst = list(), list() need_install_flag = False for root, _, basename_list in os.walk(_ROOT): if os.path.basename(root) != "__pycache__": for basename in basename_list: ...
[ "def", "check_need_install", "(", ")", ":", "md5_root", ",", "md5_dst", "=", "list", "(", ")", ",", "list", "(", ")", "need_install_flag", "=", "False", "for", "root", ",", "_", ",", "basename_list", "in", "os", ".", "walk", "(", "_ROOT", ")", ":", "...
Check if installed package are exactly the same to this one.
[ "Check", "if", "installed", "package", "are", "exactly", "the", "same", "to", "this", "one", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/zzz_manual_install.py#L145-L160
MacHu-GWU/angora-project
angora/zzz_manual_install.py
install
def install(): """Manual install main script. """ # check installed package print("Compare to '%s' ..." % _DST) need_install_flag = check_need_install() if not need_install_flag: print("\tpackage is up-to-date, no need to install.") return print("Difference been found, start ...
python
def install(): """Manual install main script. """ # check installed package print("Compare to '%s' ..." % _DST) need_install_flag = check_need_install() if not need_install_flag: print("\tpackage is up-to-date, no need to install.") return print("Difference been found, start ...
[ "def", "install", "(", ")", ":", "# check installed package", "print", "(", "\"Compare to '%s' ...\"", "%", "_DST", ")", "need_install_flag", "=", "check_need_install", "(", ")", "if", "not", "need_install_flag", ":", "print", "(", "\"\\tpackage is up-to-date, no need t...
Manual install main script.
[ "Manual", "install", "main", "script", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/zzz_manual_install.py#L163-L195
ebrelsford/feincms-pagepermissions
pagepermissions/extension.py
has_permission_to_view
def has_permission_to_view(page, user): """ Check whether the user has permission to view the page. If the user has any of the page's permissions, they have permission. If the page has no set permissions, they have permission. """ if page.permissions.count() == 0: return True for pe...
python
def has_permission_to_view(page, user): """ Check whether the user has permission to view the page. If the user has any of the page's permissions, they have permission. If the page has no set permissions, they have permission. """ if page.permissions.count() == 0: return True for pe...
[ "def", "has_permission_to_view", "(", "page", ",", "user", ")", ":", "if", "page", ".", "permissions", ".", "count", "(", ")", "==", "0", ":", "return", "True", "for", "perm", "in", "page", ".", "permissions", ".", "all", "(", ")", ":", "perm_label", ...
Check whether the user has permission to view the page. If the user has any of the page's permissions, they have permission. If the page has no set permissions, they have permission.
[ "Check", "whether", "the", "user", "has", "permission", "to", "view", "the", "page", ".", "If", "the", "user", "has", "any", "of", "the", "page", "s", "permissions", "they", "have", "permission", ".", "If", "the", "page", "has", "no", "set", "permissions...
train
https://github.com/ebrelsford/feincms-pagepermissions/blob/097ebf810e794feb4219defc1dc0cd9dd394a734/pagepermissions/extension.py#L41-L54
mariocesar/pengbot
src/pengbot/adapters/shell.py
Shell.do_directives
def do_directives(self, line): """List all directives supported by the bot""" for name, cmd in self.adapter.directives.items(): with colorize('blue'): print('bot %s:' % name) if cmd.__doc__: for line in cmd.__doc__.split('\n'): ...
python
def do_directives(self, line): """List all directives supported by the bot""" for name, cmd in self.adapter.directives.items(): with colorize('blue'): print('bot %s:' % name) if cmd.__doc__: for line in cmd.__doc__.split('\n'): ...
[ "def", "do_directives", "(", "self", ",", "line", ")", ":", "for", "name", ",", "cmd", "in", "self", ".", "adapter", ".", "directives", ".", "items", "(", ")", ":", "with", "colorize", "(", "'blue'", ")", ":", "print", "(", "'bot %s:'", "%", "name", ...
List all directives supported by the bot
[ "List", "all", "directives", "supported", "by", "the", "bot" ]
train
https://github.com/mariocesar/pengbot/blob/070854f92ac1314ee56f7f6cb9d27430b8f0fda8/src/pengbot/adapters/shell.py#L30-L39
mariocesar/pengbot
src/pengbot/adapters/shell.py
Shell.do_bot
def do_bot(self, line): """Call the bot""" with colorize('blue'): if not line: self.say('what?') try: res = self.adapter.receive(message=line) except UnknownCommand: self.say("I do not known what the '%s' directive is" ...
python
def do_bot(self, line): """Call the bot""" with colorize('blue'): if not line: self.say('what?') try: res = self.adapter.receive(message=line) except UnknownCommand: self.say("I do not known what the '%s' directive is" ...
[ "def", "do_bot", "(", "self", ",", "line", ")", ":", "with", "colorize", "(", "'blue'", ")", ":", "if", "not", "line", ":", "self", ".", "say", "(", "'what?'", ")", "try", ":", "res", "=", "self", ".", "adapter", ".", "receive", "(", "message", "...
Call the bot
[ "Call", "the", "bot" ]
train
https://github.com/mariocesar/pengbot/blob/070854f92ac1314ee56f7f6cb9d27430b8f0fda8/src/pengbot/adapters/shell.py#L45-L56
Vito2015/pyextend
pyextend/core/wrappers/timeout.py
timeout
def timeout(seconds, error_message=None): """Timeout checking just for Linux-like platform, not working in Windows platform.""" def decorated(func): result = "" def _handle_timeout(signum, frame): errmsg = error_message or 'Timeout: The action <%s> is timeout!' % func.__name__ ...
python
def timeout(seconds, error_message=None): """Timeout checking just for Linux-like platform, not working in Windows platform.""" def decorated(func): result = "" def _handle_timeout(signum, frame): errmsg = error_message or 'Timeout: The action <%s> is timeout!' % func.__name__ ...
[ "def", "timeout", "(", "seconds", ",", "error_message", "=", "None", ")", ":", "def", "decorated", "(", "func", ")", ":", "result", "=", "\"\"", "def", "_handle_timeout", "(", "signum", ",", "frame", ")", ":", "errmsg", "=", "error_message", "or", "'Time...
Timeout checking just for Linux-like platform, not working in Windows platform.
[ "Timeout", "checking", "just", "for", "Linux", "-", "like", "platform", "not", "working", "in", "Windows", "platform", "." ]
train
https://github.com/Vito2015/pyextend/blob/36861dfe1087e437ffe9b5a1da9345c85b4fa4a1/pyextend/core/wrappers/timeout.py#L25-L60
PonteIneptique/collatinus-python
pycollatinus/util.py
lignesFichier
def lignesFichier(nf): """ L'ensemble de lignes du fichier qui ne sont ni vides ni commentées. * Les fichiers de Collatinus ont adopté le point d'exclamation * en début de ligne pour introduire un commentaire. * Ces lignes doivent être ignorées par le programme. :param nf: Nom du fichi...
python
def lignesFichier(nf): """ L'ensemble de lignes du fichier qui ne sont ni vides ni commentées. * Les fichiers de Collatinus ont adopté le point d'exclamation * en début de ligne pour introduire un commentaire. * Ces lignes doivent être ignorées par le programme. :param nf: Nom du fichi...
[ "def", "lignesFichier", "(", "nf", ")", ":", "with", "open", "(", "nf", ")", "as", "file", ":", "for", "line", "in", "file", ".", "readlines", "(", ")", ":", "line", "=", "line", ".", "strip", "(", ")", "if", "line", "and", "not", "line", ".", ...
L'ensemble de lignes du fichier qui ne sont ni vides ni commentées. * Les fichiers de Collatinus ont adopté le point d'exclamation * en début de ligne pour introduire un commentaire. * Ces lignes doivent être ignorées par le programme. :param nf: Nom du fichier :type nf: str :yield...
[ "L", "ensemble", "de", "lignes", "du", "fichier", "qui", "ne", "sont", "ni", "vides", "ni", "commentées", "." ]
train
https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/util.py#L48-L66
luismasuelli/python-cantrips
cantrips/patterns/broadcast.py
IBroadcast.BROADCAST_FILTER_OTHERS
def BROADCAST_FILTER_OTHERS(user): """ HIGH-ORDER (pass it as IBroadcast.BROADCAST_FILTER_OTHERS(user-or-sequence)) Criteria to broadcast to every user but the current(s). """ if not isinstance(user, (set,frozenset,list,tuple)): user = (user,) return lambda u,...
python
def BROADCAST_FILTER_OTHERS(user): """ HIGH-ORDER (pass it as IBroadcast.BROADCAST_FILTER_OTHERS(user-or-sequence)) Criteria to broadcast to every user but the current(s). """ if not isinstance(user, (set,frozenset,list,tuple)): user = (user,) return lambda u,...
[ "def", "BROADCAST_FILTER_OTHERS", "(", "user", ")", ":", "if", "not", "isinstance", "(", "user", ",", "(", "set", ",", "frozenset", ",", "list", ",", "tuple", ")", ")", ":", "user", "=", "(", "user", ",", ")", "return", "lambda", "u", ",", "command",...
HIGH-ORDER (pass it as IBroadcast.BROADCAST_FILTER_OTHERS(user-or-sequence)) Criteria to broadcast to every user but the current(s).
[ "HIGH", "-", "ORDER", "(", "pass", "it", "as", "IBroadcast", ".", "BROADCAST_FILTER_OTHERS", "(", "user", "-", "or", "-", "sequence", "))", "Criteria", "to", "broadcast", "to", "every", "user", "but", "the", "current", "(", "s", ")", "." ]
train
https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/patterns/broadcast.py#L58-L65
luismasuelli/python-cantrips
cantrips/patterns/broadcast.py
IBroadcast.BROADCAST_FILTER_AND
def BROADCAST_FILTER_AND(*funcs): """ Composes the passed filters into an and-joined filter. """ return lambda u, command, *args, **kwargs: all(f(u, command, *args, **kwargs) for f in funcs)
python
def BROADCAST_FILTER_AND(*funcs): """ Composes the passed filters into an and-joined filter. """ return lambda u, command, *args, **kwargs: all(f(u, command, *args, **kwargs) for f in funcs)
[ "def", "BROADCAST_FILTER_AND", "(", "*", "funcs", ")", ":", "return", "lambda", "u", ",", "command", ",", "*", "args", ",", "*", "*", "kwargs", ":", "all", "(", "f", "(", "u", ",", "command", ",", "*", "args", ",", "*", "*", "kwargs", ")", "for",...
Composes the passed filters into an and-joined filter.
[ "Composes", "the", "passed", "filters", "into", "an", "and", "-", "joined", "filter", "." ]
train
https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/patterns/broadcast.py#L68-L72
luismasuelli/python-cantrips
cantrips/patterns/broadcast.py
IBroadcast.BROADCAST_FILTER_OR
def BROADCAST_FILTER_OR(*funcs): """ Composes the passed filters into an and-joined filter. """ return lambda u, command, *args, **kwargs: any(f(u, command, *args, **kwargs) for f in funcs)
python
def BROADCAST_FILTER_OR(*funcs): """ Composes the passed filters into an and-joined filter. """ return lambda u, command, *args, **kwargs: any(f(u, command, *args, **kwargs) for f in funcs)
[ "def", "BROADCAST_FILTER_OR", "(", "*", "funcs", ")", ":", "return", "lambda", "u", ",", "command", ",", "*", "args", ",", "*", "*", "kwargs", ":", "any", "(", "f", "(", "u", ",", "command", ",", "*", "args", ",", "*", "*", "kwargs", ")", "for", ...
Composes the passed filters into an and-joined filter.
[ "Composes", "the", "passed", "filters", "into", "an", "and", "-", "joined", "filter", "." ]
train
https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/patterns/broadcast.py#L75-L79
luismasuelli/python-cantrips
cantrips/patterns/broadcast.py
IBroadcast.BROADCAST_FILTER_NOT
def BROADCAST_FILTER_NOT(func): """ Composes the passed filters into an and-joined filter. """ return lambda u, command, *args, **kwargs: not func(u, command, *args, **kwargs)
python
def BROADCAST_FILTER_NOT(func): """ Composes the passed filters into an and-joined filter. """ return lambda u, command, *args, **kwargs: not func(u, command, *args, **kwargs)
[ "def", "BROADCAST_FILTER_NOT", "(", "func", ")", ":", "return", "lambda", "u", ",", "command", ",", "*", "args", ",", "*", "*", "kwargs", ":", "not", "func", "(", "u", ",", "command", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Composes the passed filters into an and-joined filter.
[ "Composes", "the", "passed", "filters", "into", "an", "and", "-", "joined", "filter", "." ]
train
https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/patterns/broadcast.py#L82-L86
luismasuelli/python-cantrips
cantrips/patterns/broadcast.py
IBroadcast.broadcast
def broadcast(self, command, *args, **kwargs): """ Notifies each user with a specified command. """ criterion = kwargs.pop('criterion', self.BROADCAST_FILTER_ALL) for index, user in items(self.users()): if criterion(user, command, *args, **kwargs): sel...
python
def broadcast(self, command, *args, **kwargs): """ Notifies each user with a specified command. """ criterion = kwargs.pop('criterion', self.BROADCAST_FILTER_ALL) for index, user in items(self.users()): if criterion(user, command, *args, **kwargs): sel...
[ "def", "broadcast", "(", "self", ",", "command", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "criterion", "=", "kwargs", ".", "pop", "(", "'criterion'", ",", "self", ".", "BROADCAST_FILTER_ALL", ")", "for", "index", ",", "user", "in", "items",...
Notifies each user with a specified command.
[ "Notifies", "each", "user", "with", "a", "specified", "command", "." ]
train
https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/patterns/broadcast.py#L88-L95
KitB/compose-deploy
compose_deploy/_main.py
get_config
def get_config(basedir, files): """ Returns the config object for the selected docker-compose.yml This is an instance of `compose.config.config.Config`. """ config_details = config.find( basedir, files, environment.Environment.from_env_file(basedir)) return config.load(config_detai...
python
def get_config(basedir, files): """ Returns the config object for the selected docker-compose.yml This is an instance of `compose.config.config.Config`. """ config_details = config.find( basedir, files, environment.Environment.from_env_file(basedir)) return config.load(config_detai...
[ "def", "get_config", "(", "basedir", ",", "files", ")", ":", "config_details", "=", "config", ".", "find", "(", "basedir", ",", "files", ",", "environment", ".", "Environment", ".", "from_env_file", "(", "basedir", ")", ")", "return", "config", ".", "load"...
Returns the config object for the selected docker-compose.yml This is an instance of `compose.config.config.Config`.
[ "Returns", "the", "config", "object", "for", "the", "selected", "docker", "-", "compose", ".", "yml" ]
train
https://github.com/KitB/compose-deploy/blob/45e351ff4a3e8001e544655e7068d9cacdbb48e5/compose_deploy/_main.py#L31-L40
KitB/compose-deploy
compose_deploy/_main.py
build
def build(config, services): """ Builds images and tags them appropriately. Where "appropriately" means with the output of: git describe --tags HEAD and 'latest' as well (so the "latest" image for each will always be the most recently built) """ filtered_services = {name: service for ...
python
def build(config, services): """ Builds images and tags them appropriately. Where "appropriately" means with the output of: git describe --tags HEAD and 'latest' as well (so the "latest" image for each will always be the most recently built) """ filtered_services = {name: service for ...
[ "def", "build", "(", "config", ",", "services", ")", ":", "filtered_services", "=", "{", "name", ":", "service", "for", "name", ",", "service", "in", "services", ".", "iteritems", "(", ")", "if", "'build'", "in", "service", "}", "_call_output", "(", "'do...
Builds images and tags them appropriately. Where "appropriately" means with the output of: git describe --tags HEAD and 'latest' as well (so the "latest" image for each will always be the most recently built)
[ "Builds", "images", "and", "tags", "them", "appropriately", "." ]
train
https://github.com/KitB/compose-deploy/blob/45e351ff4a3e8001e544655e7068d9cacdbb48e5/compose_deploy/_main.py#L99-L122
KitB/compose-deploy
compose_deploy/_main.py
push
def push(config, services): """ Upload the defined services to their respective repositories. So's we can then tell the remote docker host to then pull and run them. """ version = _get_version() for service_name, service_dict in services.iteritems(): image = service_dict['image'] th...
python
def push(config, services): """ Upload the defined services to their respective repositories. So's we can then tell the remote docker host to then pull and run them. """ version = _get_version() for service_name, service_dict in services.iteritems(): image = service_dict['image'] th...
[ "def", "push", "(", "config", ",", "services", ")", ":", "version", "=", "_get_version", "(", ")", "for", "service_name", ",", "service_dict", "in", "services", ".", "iteritems", "(", ")", ":", "image", "=", "service_dict", "[", "'image'", "]", "things", ...
Upload the defined services to their respective repositories. So's we can then tell the remote docker host to then pull and run them.
[ "Upload", "the", "defined", "services", "to", "their", "respective", "repositories", "." ]
train
https://github.com/KitB/compose-deploy/blob/45e351ff4a3e8001e544655e7068d9cacdbb48e5/compose_deploy/_main.py#L125-L135
hobson/pug-invest
pug/invest/plot.py
animate_panel
def animate_panel(panel, keys=None, columns=None, interval=1000, blit=False, titles='', path='animate_panel', xlabel='Time', ylabel='Value', ext='gif', replot=False, linewidth=3, close=False, fontsize=24, background_color='white', alpha=1, figsize=(12,8), xlabel_rotation=-25, plot_kwargs=(('rotation'...
python
def animate_panel(panel, keys=None, columns=None, interval=1000, blit=False, titles='', path='animate_panel', xlabel='Time', ylabel='Value', ext='gif', replot=False, linewidth=3, close=False, fontsize=24, background_color='white', alpha=1, figsize=(12,8), xlabel_rotation=-25, plot_kwargs=(('rotation'...
[ "def", "animate_panel", "(", "panel", ",", "keys", "=", "None", ",", "columns", "=", "None", ",", "interval", "=", "1000", ",", "blit", "=", "False", ",", "titles", "=", "''", ",", "path", "=", "'animate_panel'", ",", "xlabel", "=", "'Time'", ",", "y...
Animate a pandas.Panel by flipping through plots of the data in each dataframe Arguments: panel (pandas.Panel): Pandas Panel of DataFrames to animate (each DataFrame is an animation video frame) keys (list of str): ordered list of panel keys (pages) to animate columns (list of str): ordered list ...
[ "Animate", "a", "pandas", ".", "Panel", "by", "flipping", "through", "plots", "of", "the", "data", "in", "each", "dataframe" ]
train
https://github.com/hobson/pug-invest/blob/836911258a0e920083a88c91beae88eefdebb20c/pug/invest/plot.py#L30-L188
hobson/pug-invest
pug/invest/plot.py
generate_bins
def generate_bins(bins, values=None): """Compute bin edges for numpy.histogram based on values and a requested bin parameters Unlike `range`, the largest value is included within the range of the last, largest value, so generate_bins(N) with produce a sequence with length N+1 Arguments: bins (...
python
def generate_bins(bins, values=None): """Compute bin edges for numpy.histogram based on values and a requested bin parameters Unlike `range`, the largest value is included within the range of the last, largest value, so generate_bins(N) with produce a sequence with length N+1 Arguments: bins (...
[ "def", "generate_bins", "(", "bins", ",", "values", "=", "None", ")", ":", "if", "isinstance", "(", "bins", ",", "int", ")", ":", "bins", "=", "(", "bins", ",", ")", "if", "isinstance", "(", "bins", ",", "float", ")", ":", "bins", "=", "(", "0", ...
Compute bin edges for numpy.histogram based on values and a requested bin parameters Unlike `range`, the largest value is included within the range of the last, largest value, so generate_bins(N) with produce a sequence with length N+1 Arguments: bins (int or 2-tuple of floats or sequence of float...
[ "Compute", "bin", "edges", "for", "numpy", ".", "histogram", "based", "on", "values", "and", "a", "requested", "bin", "parameters" ]
train
https://github.com/hobson/pug-invest/blob/836911258a0e920083a88c91beae88eefdebb20c/pug/invest/plot.py#L203-L256
hobson/pug-invest
pug/invest/plot.py
thin_string_list
def thin_string_list(list_of_strings, max_nonempty_strings=50, blank=''): """Designed for composing lists of strings suitable for pyplot axis labels Often the xtick spacing doesn't allow room for 100's of text labels, so this eliminates every other one, then every other one of those, until they fit. >...
python
def thin_string_list(list_of_strings, max_nonempty_strings=50, blank=''): """Designed for composing lists of strings suitable for pyplot axis labels Often the xtick spacing doesn't allow room for 100's of text labels, so this eliminates every other one, then every other one of those, until they fit. >...
[ "def", "thin_string_list", "(", "list_of_strings", ",", "max_nonempty_strings", "=", "50", ",", "blank", "=", "''", ")", ":", "# blank some labels to make sure they don't overlap", "list_of_strings", "=", "list", "(", "list_of_strings", ")", "istep", "=", "2", "while"...
Designed for composing lists of strings suitable for pyplot axis labels Often the xtick spacing doesn't allow room for 100's of text labels, so this eliminates every other one, then every other one of those, until they fit. >>> thin_string_list(['x']*20, 5) # doctring: +NORMALIZE_WHITESPACE ['x', '',...
[ "Designed", "for", "composing", "lists", "of", "strings", "suitable", "for", "pyplot", "axis", "labels" ]
train
https://github.com/hobson/pug-invest/blob/836911258a0e920083a88c91beae88eefdebb20c/pug/invest/plot.py#L259-L274
hobson/pug-invest
pug/invest/plot.py
prettify_datetimes
def prettify_datetimes(datetimes, format="%b %Y", max_nonempty_strings=None, blank=''): """Designed for composing lists of strings suitable for pyplot axis labels Often the xtick spacing doesn't allow room for 100's of text labels, so this eliminates every other one, then every other one of those, until th...
python
def prettify_datetimes(datetimes, format="%b %Y", max_nonempty_strings=None, blank=''): """Designed for composing lists of strings suitable for pyplot axis labels Often the xtick spacing doesn't allow room for 100's of text labels, so this eliminates every other one, then every other one of those, until th...
[ "def", "prettify_datetimes", "(", "datetimes", ",", "format", "=", "\"%b %Y\"", ",", "max_nonempty_strings", "=", "None", ",", "blank", "=", "''", ")", ":", "# blank some labels to make sure they don't overlap", "datetimes", "=", "[", "make_datetime", "(", "d", ")",...
Designed for composing lists of strings suitable for pyplot axis labels Often the xtick spacing doesn't allow room for 100's of text labels, so this eliminates every other one, then every other one of those, until they fit. >>> thin_string_list(['x']*20, 5) # doctring: +NORMALIZE_WHITESPACE ['x', '',...
[ "Designed", "for", "composing", "lists", "of", "strings", "suitable", "for", "pyplot", "axis", "labels" ]
train
https://github.com/hobson/pug-invest/blob/836911258a0e920083a88c91beae88eefdebb20c/pug/invest/plot.py#L277-L291
hobson/pug-invest
pug/invest/plot.py
plot_histogram
def plot_histogram(hist, width=0.9, title='', xlabel=None, datetime_format="%b %Y", labels=None, color=None, alpha=None, normalize=True, percent=False, padding=0.03, num_labels=24, formatter=None, ylabel_precision=2, resolution=3, figsize=None,...
python
def plot_histogram(hist, width=0.9, title='', xlabel=None, datetime_format="%b %Y", labels=None, color=None, alpha=None, normalize=True, percent=False, padding=0.03, num_labels=24, formatter=None, ylabel_precision=2, resolution=3, figsize=None,...
[ "def", "plot_histogram", "(", "hist", ",", "width", "=", "0.9", ",", "title", "=", "''", ",", "xlabel", "=", "None", ",", "datetime_format", "=", "\"%b %Y\"", ",", "labels", "=", "None", ",", "color", "=", "None", ",", "alpha", "=", "None", ",", "nor...
Plot a bar chart from np.histogram data >>> plot_histogram(np.histogram([1]*5+[3]*2+list(range(20))+[19.1]), alpha=1) # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS ((array([7, 4, 2, 2, 2, 2, 2, 2, 2, 3]), array([ 0. , 1.91, 3.82, 5.73, 7.64, 9.55, 11.46, 13.37, 15.28, 17.19, 19.1 ]))...
[ "Plot", "a", "bar", "chart", "from", "np", ".", "histogram", "data" ]
train
https://github.com/hobson/pug-invest/blob/836911258a0e920083a88c91beae88eefdebb20c/pug/invest/plot.py#L294-L404
hobson/pug-invest
pug/invest/plot.py
histogram_and_plot
def histogram_and_plot(df, column=0, width=0.9, resolution=2, str_timetags=True, counted=False, title='', xlabel=None, datetime_format='%b %d, %Y', num_labels=24, bins=None, labels=None, color=None, alpha=None, normalize=True, percent=False, padding=0.03, format...
python
def histogram_and_plot(df, column=0, width=0.9, resolution=2, str_timetags=True, counted=False, title='', xlabel=None, datetime_format='%b %d, %Y', num_labels=24, bins=None, labels=None, color=None, alpha=None, normalize=True, percent=False, padding=0.03, format...
[ "def", "histogram_and_plot", "(", "df", ",", "column", "=", "0", ",", "width", "=", "0.9", ",", "resolution", "=", "2", ",", "str_timetags", "=", "True", ",", "counted", "=", "False", ",", "title", "=", "''", ",", "xlabel", "=", "None", ",", "datetim...
Bin a DataFrame of floats or datetime strings and plot the histogram Arguments: df (DataFrame of str or float): table of data containing data to be counted and binned column (str): label of the DataFrame column containing data to be counted and binned width (float): 0 < width <= 1, the graphical ...
[ "Bin", "a", "DataFrame", "of", "floats", "or", "datetime", "strings", "and", "plot", "the", "histogram" ]
train
https://github.com/hobson/pug-invest/blob/836911258a0e920083a88c91beae88eefdebb20c/pug/invest/plot.py#L407-L511
appstore-zencore/dictop
dictop.py
select
def select(target, path, default=None, slient=True): """Select item with path from target. If not find item and slient marked as True, return default value. If not find item and slient marked as False, raise KeyError. """ def _(value, slient): if slient: return value el...
python
def select(target, path, default=None, slient=True): """Select item with path from target. If not find item and slient marked as True, return default value. If not find item and slient marked as False, raise KeyError. """ def _(value, slient): if slient: return value el...
[ "def", "select", "(", "target", ",", "path", ",", "default", "=", "None", ",", "slient", "=", "True", ")", ":", "def", "_", "(", "value", ",", "slient", ")", ":", "if", "slient", ":", "return", "value", "else", ":", "raise", "KeyError", "(", "\"\""...
Select item with path from target. If not find item and slient marked as True, return default value. If not find item and slient marked as False, raise KeyError.
[ "Select", "item", "with", "path", "from", "target", "." ]
train
https://github.com/appstore-zencore/dictop/blob/d730f74f6db9c65b7679db237ccf9b1c4031266b/dictop.py#L5-L34
appstore-zencore/dictop
dictop.py
update
def update(target, path, value): """Update item in path of target with given value. """ names = path.split(".") names_length = len(names) node = target for index in range(names_length): name = names[index] if index == names_length - 1: last = True else: ...
python
def update(target, path, value): """Update item in path of target with given value. """ names = path.split(".") names_length = len(names) node = target for index in range(names_length): name = names[index] if index == names_length - 1: last = True else: ...
[ "def", "update", "(", "target", ",", "path", ",", "value", ")", ":", "names", "=", "path", ".", "split", "(", "\".\"", ")", "names_length", "=", "len", "(", "names", ")", "node", "=", "target", "for", "index", "in", "range", "(", "names_length", ")",...
Update item in path of target with given value.
[ "Update", "item", "in", "path", "of", "target", "with", "given", "value", "." ]
train
https://github.com/appstore-zencore/dictop/blob/d730f74f6db9c65b7679db237ccf9b1c4031266b/dictop.py#L44-L78
cdeboever3/cdpybio
cdpybio/picard.py
parse_bam_index_stats
def parse_bam_index_stats(fn): """ Parse the output from Picard's BamIndexStast and return as pandas Dataframe. Parameters ---------- filename : str of filename or file handle Filename of the Picard output you want to parse. Returns ------- df : pandas.DataFrame Data fr...
python
def parse_bam_index_stats(fn): """ Parse the output from Picard's BamIndexStast and return as pandas Dataframe. Parameters ---------- filename : str of filename or file handle Filename of the Picard output you want to parse. Returns ------- df : pandas.DataFrame Data fr...
[ "def", "parse_bam_index_stats", "(", "fn", ")", ":", "with", "open", "(", "fn", ")", "as", "f", ":", "lines", "=", "[", "x", ".", "strip", "(", ")", ".", "split", "(", ")", "for", "x", "in", "f", ".", "readlines", "(", ")", "]", "no_counts", "=...
Parse the output from Picard's BamIndexStast and return as pandas Dataframe. Parameters ---------- filename : str of filename or file handle Filename of the Picard output you want to parse. Returns ------- df : pandas.DataFrame Data from output file.
[ "Parse", "the", "output", "from", "Picard", "s", "BamIndexStast", "and", "return", "as", "pandas", "Dataframe", "." ]
train
https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/picard.py#L4-L30
cdeboever3/cdpybio
cdpybio/picard.py
parse_alignment_summary_metrics
def parse_alignment_summary_metrics(fn): """ Parse the output from Picard's CollectAlignmentSummaryMetrics and return as pandas Dataframe. Parameters ---------- filename : str of filename or file handle Filename of the Picard output you want to parse. Returns ------- df : p...
python
def parse_alignment_summary_metrics(fn): """ Parse the output from Picard's CollectAlignmentSummaryMetrics and return as pandas Dataframe. Parameters ---------- filename : str of filename or file handle Filename of the Picard output you want to parse. Returns ------- df : p...
[ "def", "parse_alignment_summary_metrics", "(", "fn", ")", ":", "df", "=", "pd", ".", "read_table", "(", "fn", ",", "index_col", "=", "0", ",", "skiprows", "=", "range", "(", "6", ")", "+", "[", "10", ",", "11", "]", ")", ".", "T", "return", "df" ]
Parse the output from Picard's CollectAlignmentSummaryMetrics and return as pandas Dataframe. Parameters ---------- filename : str of filename or file handle Filename of the Picard output you want to parse. Returns ------- df : pandas.DataFrame Data from output file.
[ "Parse", "the", "output", "from", "Picard", "s", "CollectAlignmentSummaryMetrics", "and", "return", "as", "pandas", "Dataframe", "." ]
train
https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/picard.py#L32-L49
cdeboever3/cdpybio
cdpybio/picard.py
parse_mark_duplicate_metrics
def parse_mark_duplicate_metrics(fn): """ Parse the output from Picard's MarkDuplicates and return as pandas Series. Parameters ---------- filename : str of filename or file handle Filename of the Picard output you want to parse. Returns ------- metrics : pandas.Series ...
python
def parse_mark_duplicate_metrics(fn): """ Parse the output from Picard's MarkDuplicates and return as pandas Series. Parameters ---------- filename : str of filename or file handle Filename of the Picard output you want to parse. Returns ------- metrics : pandas.Series ...
[ "def", "parse_mark_duplicate_metrics", "(", "fn", ")", ":", "with", "open", "(", "fn", ")", "as", "f", ":", "lines", "=", "[", "x", ".", "strip", "(", ")", ".", "split", "(", "'\\t'", ")", "for", "x", "in", "f", ".", "readlines", "(", ")", "]", ...
Parse the output from Picard's MarkDuplicates and return as pandas Series. Parameters ---------- filename : str of filename or file handle Filename of the Picard output you want to parse. Returns ------- metrics : pandas.Series Duplicate metrics. hist : pandas.Series ...
[ "Parse", "the", "output", "from", "Picard", "s", "MarkDuplicates", "and", "return", "as", "pandas", "Series", "." ]
train
https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/picard.py#L51-L79
cdeboever3/cdpybio
cdpybio/picard.py
parse_insert_metrics
def parse_insert_metrics(fn): """ Parse the output from Picard's CollectInsertSizeMetrics and return as pandas Series. Parameters ---------- filename : str of filename or file handle Filename of the Picard output you want to parse. Returns ------- metrics : pandas.Series ...
python
def parse_insert_metrics(fn): """ Parse the output from Picard's CollectInsertSizeMetrics and return as pandas Series. Parameters ---------- filename : str of filename or file handle Filename of the Picard output you want to parse. Returns ------- metrics : pandas.Series ...
[ "def", "parse_insert_metrics", "(", "fn", ")", ":", "with", "open", "(", "fn", ")", "as", "f", ":", "lines", "=", "[", "x", ".", "strip", "(", ")", ".", "split", "(", "'\\t'", ")", "for", "x", "in", "f", ".", "readlines", "(", ")", "]", "index"...
Parse the output from Picard's CollectInsertSizeMetrics and return as pandas Series. Parameters ---------- filename : str of filename or file handle Filename of the Picard output you want to parse. Returns ------- metrics : pandas.Series Insert size metrics. hist : pan...
[ "Parse", "the", "output", "from", "Picard", "s", "CollectInsertSizeMetrics", "and", "return", "as", "pandas", "Series", "." ]
train
https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/picard.py#L81-L121