partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | serve | Basic FastCGI support via flup.
This web server has many, many options. Please see the Flup project documentation for details. | web/server/fcgi.py | def serve(application, host='127.0.0.1', port=8080, socket=None, **options):
"""Basic FastCGI support via flup.
This web server has many, many options. Please see the Flup project documentation for details.
"""
# Allow either on-disk socket (recommended) or TCP/IP socket use.
if not socket:
bindAddress = (ho... | def serve(application, host='127.0.0.1', port=8080, socket=None, **options):
"""Basic FastCGI support via flup.
This web server has many, many options. Please see the Flup project documentation for details.
"""
# Allow either on-disk socket (recommended) or TCP/IP socket use.
if not socket:
bindAddress = (ho... | [
"Basic",
"FastCGI",
"support",
"via",
"flup",
".",
"This",
"web",
"server",
"has",
"many",
"many",
"options",
".",
"Please",
"see",
"the",
"Flup",
"project",
"documentation",
"for",
"details",
"."
] | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/fcgi.py#L18-L31 | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
",",
"socket",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"# Allow either on-disk socket (recommended) or TCP/IP socket use.",
"if",
"not",
"socket",
":",
"bindA... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | SubscriptionCreateForm._get_method_kwargs | Helper method. Returns kwargs needed to filter the correct object.
Can also be used to create the correct object. | subscribe/forms.py | def _get_method_kwargs(self):
"""
Helper method. Returns kwargs needed to filter the correct object.
Can also be used to create the correct object.
"""
method_kwargs = {
'user': self.user,
'content_type': self.ctype,
'object_id': self.content... | def _get_method_kwargs(self):
"""
Helper method. Returns kwargs needed to filter the correct object.
Can also be used to create the correct object.
"""
method_kwargs = {
'user': self.user,
'content_type': self.ctype,
'object_id': self.content... | [
"Helper",
"method",
".",
"Returns",
"kwargs",
"needed",
"to",
"filter",
"the",
"correct",
"object",
"."
] | bitlabstudio/django-subscribe | python | https://github.com/bitlabstudio/django-subscribe/blob/313de63fb4acda172e88b65c3327c793f98e8aa9/subscribe/forms.py#L15-L27 | [
"def",
"_get_method_kwargs",
"(",
"self",
")",
":",
"method_kwargs",
"=",
"{",
"'user'",
":",
"self",
".",
"user",
",",
"'content_type'",
":",
"self",
".",
"ctype",
",",
"'object_id'",
":",
"self",
".",
"content_object",
".",
"pk",
",",
"}",
"return",
"m... | 313de63fb4acda172e88b65c3327c793f98e8aa9 |
train | SubscriptionCreateForm.save | Adds a subscription for the given user to the given object. | subscribe/forms.py | def save(self, *args, **kwargs):
"""Adds a subscription for the given user to the given object."""
method_kwargs = self._get_method_kwargs()
try:
subscription = Subscription.objects.get(**method_kwargs)
except Subscription.DoesNotExist:
subscription = Subscription... | def save(self, *args, **kwargs):
"""Adds a subscription for the given user to the given object."""
method_kwargs = self._get_method_kwargs()
try:
subscription = Subscription.objects.get(**method_kwargs)
except Subscription.DoesNotExist:
subscription = Subscription... | [
"Adds",
"a",
"subscription",
"for",
"the",
"given",
"user",
"to",
"the",
"given",
"object",
"."
] | bitlabstudio/django-subscribe | python | https://github.com/bitlabstudio/django-subscribe/blob/313de63fb4acda172e88b65c3327c793f98e8aa9/subscribe/forms.py#L29-L36 | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"method_kwargs",
"=",
"self",
".",
"_get_method_kwargs",
"(",
")",
"try",
":",
"subscription",
"=",
"Subscription",
".",
"objects",
".",
"get",
"(",
"*",
"*",
"method_kwar... | 313de63fb4acda172e88b65c3327c793f98e8aa9 |
train | BaseExtension.prepare | Add the usual suspects to the context.
This adds `request`, `response`, and `path` to the `RequestContext` instance. | web/ext/base.py | def prepare(self, context):
"""Add the usual suspects to the context.
This adds `request`, `response`, and `path` to the `RequestContext` instance.
"""
if __debug__:
log.debug("Preparing request context.", extra=dict(request=id(context)))
# Bridge in WebOb `Request` and `Response` objects.
# Ext... | def prepare(self, context):
"""Add the usual suspects to the context.
This adds `request`, `response`, and `path` to the `RequestContext` instance.
"""
if __debug__:
log.debug("Preparing request context.", extra=dict(request=id(context)))
# Bridge in WebOb `Request` and `Response` objects.
# Ext... | [
"Add",
"the",
"usual",
"suspects",
"to",
"the",
"context",
".",
"This",
"adds",
"request",
"response",
"and",
"path",
"to",
"the",
"RequestContext",
"instance",
"."
] | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L83-L106 | [
"def",
"prepare",
"(",
"self",
",",
"context",
")",
":",
"if",
"__debug__",
":",
"log",
".",
"debug",
"(",
"\"Preparing request context.\"",
",",
"extra",
"=",
"dict",
"(",
"request",
"=",
"id",
"(",
"context",
")",
")",
")",
"# Bridge in WebOb `Request` and... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | BaseExtension.dispatch | Called as dispatch descends into a tier.
The base extension uses this to maintain the "current url". | web/ext/base.py | def dispatch(self, context, consumed, handler, is_endpoint):
"""Called as dispatch descends into a tier.
The base extension uses this to maintain the "current url".
"""
request = context.request
if __debug__:
log.debug("Handling dispatch event.", extra=dict(
request = id(context),
consum... | def dispatch(self, context, consumed, handler, is_endpoint):
"""Called as dispatch descends into a tier.
The base extension uses this to maintain the "current url".
"""
request = context.request
if __debug__:
log.debug("Handling dispatch event.", extra=dict(
request = id(context),
consum... | [
"Called",
"as",
"dispatch",
"descends",
"into",
"a",
"tier",
".",
"The",
"base",
"extension",
"uses",
"this",
"to",
"maintain",
"the",
"current",
"url",
"."
] | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L108-L145 | [
"def",
"dispatch",
"(",
"self",
",",
"context",
",",
"consumed",
",",
"handler",
",",
"is_endpoint",
")",
":",
"request",
"=",
"context",
".",
"request",
"if",
"__debug__",
":",
"log",
".",
"debug",
"(",
"\"Handling dispatch event.\"",
",",
"extra",
"=",
"... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | BaseExtension.render_none | Render empty responses. | web/ext/base.py | def render_none(self, context, result):
"""Render empty responses."""
context.response.body = b''
del context.response.content_length
return True | def render_none(self, context, result):
"""Render empty responses."""
context.response.body = b''
del context.response.content_length
return True | [
"Render",
"empty",
"responses",
"."
] | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L149-L153 | [
"def",
"render_none",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"context",
".",
"response",
".",
"body",
"=",
"b''",
"del",
"context",
".",
"response",
".",
"content_length",
"return",
"True"
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | BaseExtension.render_binary | Return binary responses unmodified. | web/ext/base.py | def render_binary(self, context, result):
"""Return binary responses unmodified."""
context.response.app_iter = iter((result, )) # This wraps the binary string in a WSGI body iterable.
return True | def render_binary(self, context, result):
"""Return binary responses unmodified."""
context.response.app_iter = iter((result, )) # This wraps the binary string in a WSGI body iterable.
return True | [
"Return",
"binary",
"responses",
"unmodified",
"."
] | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L160-L163 | [
"def",
"render_binary",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"context",
".",
"response",
".",
"app_iter",
"=",
"iter",
"(",
"(",
"result",
",",
")",
")",
"# This wraps the binary string in a WSGI body iterable.",
"return",
"True"
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | BaseExtension.render_file | Perform appropriate metadata wrangling for returned open file handles. | web/ext/base.py | def render_file(self, context, result):
"""Perform appropriate metadata wrangling for returned open file handles."""
if __debug__:
log.debug("Processing file-like object.", extra=dict(request=id(context), result=repr(result)))
response = context.response
response.conditional_response = True
modified ... | def render_file(self, context, result):
"""Perform appropriate metadata wrangling for returned open file handles."""
if __debug__:
log.debug("Processing file-like object.", extra=dict(request=id(context), result=repr(result)))
response = context.response
response.conditional_response = True
modified ... | [
"Perform",
"appropriate",
"metadata",
"wrangling",
"for",
"returned",
"open",
"file",
"handles",
"."
] | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L170-L192 | [
"def",
"render_file",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"if",
"__debug__",
":",
"log",
".",
"debug",
"(",
"\"Processing file-like object.\"",
",",
"extra",
"=",
"dict",
"(",
"request",
"=",
"id",
"(",
"context",
")",
",",
"result",
"=... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | BaseExtension.render_generator | Attempt to serve generator responses through stream encoding.
This allows for direct use of cinje template functions, which are generators, as returned views. | web/ext/base.py | def render_generator(self, context, result):
"""Attempt to serve generator responses through stream encoding.
This allows for direct use of cinje template functions, which are generators, as returned views.
"""
context.response.encoding = 'utf8'
context.response.app_iter = (
(i.encode('utf8') if isinst... | def render_generator(self, context, result):
"""Attempt to serve generator responses through stream encoding.
This allows for direct use of cinje template functions, which are generators, as returned views.
"""
context.response.encoding = 'utf8'
context.response.app_iter = (
(i.encode('utf8') if isinst... | [
"Attempt",
"to",
"serve",
"generator",
"responses",
"through",
"stream",
"encoding",
".",
"This",
"allows",
"for",
"direct",
"use",
"of",
"cinje",
"template",
"functions",
"which",
"are",
"generators",
"as",
"returned",
"views",
"."
] | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L194-L204 | [
"def",
"render_generator",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"context",
".",
"response",
".",
"encoding",
"=",
"'utf8'",
"context",
".",
"response",
".",
"app_iter",
"=",
"(",
"(",
"i",
".",
"encode",
"(",
"'utf8'",
")",
"if",
"isin... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | serve | CherryPy-based WSGI-HTTP server. | web/server/cherrypy_.py | def serve(application, host='127.0.0.1', port=8080):
"""CherryPy-based WSGI-HTTP server."""
# Instantiate the server with our configuration and application.
server = CherryPyWSGIServer((host, int(port)), application, server_name=host)
# Try to be handy as many terminals allow clicking links.
print("serving on ... | def serve(application, host='127.0.0.1', port=8080):
"""CherryPy-based WSGI-HTTP server."""
# Instantiate the server with our configuration and application.
server = CherryPyWSGIServer((host, int(port)), application, server_name=host)
# Try to be handy as many terminals allow clicking links.
print("serving on ... | [
"CherryPy",
"-",
"based",
"WSGI",
"-",
"HTTP",
"server",
"."
] | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/cherrypy_.py#L14-L27 | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
")",
":",
"# Instantiate the server with our configuration and application.",
"server",
"=",
"CherryPyWSGIServer",
"(",
"(",
"host",
",",
"int",
"(",
"port",
")",
")",
... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | TerminalColorMap.colorize | Returns the colored string | xtermcolor/ColorMap.py | def colorize(self, string, rgb=None, ansi=None, bg=None, ansi_bg=None):
'''Returns the colored string'''
if not isinstance(string, str):
string = str(string)
if rgb is None and ansi is None:
raise TerminalColorMapException(
'colorize: must specify one name... | def colorize(self, string, rgb=None, ansi=None, bg=None, ansi_bg=None):
'''Returns the colored string'''
if not isinstance(string, str):
string = str(string)
if rgb is None and ansi is None:
raise TerminalColorMapException(
'colorize: must specify one name... | [
"Returns",
"the",
"colored",
"string"
] | broadinstitute/xtermcolor | python | https://github.com/broadinstitute/xtermcolor/blob/2615100979eb59744597c9d01e6fd1b711b311e1/xtermcolor/ColorMap.py#L27-L54 | [
"def",
"colorize",
"(",
"self",
",",
"string",
",",
"rgb",
"=",
"None",
",",
"ansi",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"ansi_bg",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"string",
",",
"str",
")",
":",
"string",
"=",
"str",... | 2615100979eb59744597c9d01e6fd1b711b311e1 |
train | SerializationExtension.render_serialization | Render serialized responses. | web/ext/serialize.py | def render_serialization(self, context, result):
"""Render serialized responses."""
resp = context.response
serial = context.serialize
match = context.request.accept.best_match(serial.types, default_match=self.default)
result = serial[match](result)
if isinstance(result, str):
result = result.decod... | def render_serialization(self, context, result):
"""Render serialized responses."""
resp = context.response
serial = context.serialize
match = context.request.accept.best_match(serial.types, default_match=self.default)
result = serial[match](result)
if isinstance(result, str):
result = result.decod... | [
"Render",
"serialized",
"responses",
"."
] | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/serialize.py#L91-L106 | [
"def",
"render_serialization",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"resp",
"=",
"context",
".",
"response",
"serial",
"=",
"context",
".",
"serialize",
"match",
"=",
"context",
".",
"request",
".",
"accept",
".",
"best_match",
"(",
"seria... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | serve | Eventlet-based WSGI-HTTP server.
For a more fully-featured Eventlet-capable interface, see also [Spawning](http://pypi.python.org/pypi/Spawning/). | web/server/eventlet_.py | def serve(application, host='127.0.0.1', port=8080):
"""Eventlet-based WSGI-HTTP server.
For a more fully-featured Eventlet-capable interface, see also [Spawning](http://pypi.python.org/pypi/Spawning/).
"""
# Instantiate the server with a bound port and with our application.
server(listen(host, int(port)), app... | def serve(application, host='127.0.0.1', port=8080):
"""Eventlet-based WSGI-HTTP server.
For a more fully-featured Eventlet-capable interface, see also [Spawning](http://pypi.python.org/pypi/Spawning/).
"""
# Instantiate the server with a bound port and with our application.
server(listen(host, int(port)), app... | [
"Eventlet",
"-",
"based",
"WSGI",
"-",
"HTTP",
"server",
".",
"For",
"a",
"more",
"fully",
"-",
"featured",
"Eventlet",
"-",
"capable",
"interface",
"see",
"also",
"[",
"Spawning",
"]",
"(",
"http",
":",
"//",
"pypi",
".",
"python",
".",
"org",
"/",
... | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/eventlet_.py#L15-L22 | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
")",
":",
"# Instantiate the server with a bound port and with our application.",
"server",
"(",
"listen",
"(",
"host",
",",
"int",
"(",
"port",
")",
")",
",",
"applic... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | main | Main | examples/component_evaluation.py | def main(args=None):
"""Main"""
vs = [(v-100)*0.001 for v in range(200)]
for f in ['IM.channel.nml','Kd.channel.nml']:
nml_doc = pynml.read_neuroml2_file(f)
for ct in nml_doc.ComponentType:
ys = []
for v in vs:
req_variables = {'v':'%sV'%v,... | def main(args=None):
"""Main"""
vs = [(v-100)*0.001 for v in range(200)]
for f in ['IM.channel.nml','Kd.channel.nml']:
nml_doc = pynml.read_neuroml2_file(f)
for ct in nml_doc.ComponentType:
ys = []
for v in vs:
req_variables = {'v':'%sV'%v,... | [
"Main"
] | NeuroML/pyNeuroML | python | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/examples/component_evaluation.py#L5-L33 | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"vs",
"=",
"[",
"(",
"v",
"-",
"100",
")",
"*",
"0.001",
"for",
"v",
"in",
"range",
"(",
"200",
")",
"]",
"for",
"f",
"in",
"[",
"'IM.channel.nml'",
",",
"'Kd.channel.nml'",
"]",
":",
"nml_doc",
... | aeba2e3040b360bb26556f643cccbfb3dac3b8fb |
train | process_args | Parse command-line arguments. | pyneuroml/analysis/NML2ChannelAnalysis.py | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(
description=("A script which can be run to generate a LEMS "
"file to analyse the behaviour of channels in "
"NeuroML 2"))
parser.ad... | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(
description=("A script which can be run to generate a LEMS "
"file to analyse the behaviour of channels in "
"NeuroML 2"))
parser.ad... | [
"Parse",
"command",
"-",
"line",
"arguments",
"."
] | NeuroML/pyNeuroML | python | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/analysis/NML2ChannelAnalysis.py#L58-L185 | [
"def",
"process_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"(",
"\"A script which can be run to generate a LEMS \"",
"\"file to analyse the behaviour of channels in \"",
"\"NeuroML 2\"",
")",
")",
"parser",
".",
"add_arg... | aeba2e3040b360bb26556f643cccbfb3dac3b8fb |
train | plot_iv_curve | A single IV curve | pyneuroml/analysis/NML2ChannelAnalysis.py | def plot_iv_curve(a, hold_v, i, *plt_args, **plt_kwargs):
"""A single IV curve"""
grid = plt_kwargs.pop('grid',True)
same_fig = plt_kwargs.pop('same_fig',False)
if not len(plt_args):
plt_args = ('ko-',)
if 'label' not in plt_kwargs:
plt_kwargs['label'] = 'Current'
if not sa... | def plot_iv_curve(a, hold_v, i, *plt_args, **plt_kwargs):
"""A single IV curve"""
grid = plt_kwargs.pop('grid',True)
same_fig = plt_kwargs.pop('same_fig',False)
if not len(plt_args):
plt_args = ('ko-',)
if 'label' not in plt_kwargs:
plt_kwargs['label'] = 'Current'
if not sa... | [
"A",
"single",
"IV",
"curve"
] | NeuroML/pyNeuroML | python | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/analysis/NML2ChannelAnalysis.py#L581-L594 | [
"def",
"plot_iv_curve",
"(",
"a",
",",
"hold_v",
",",
"i",
",",
"*",
"plt_args",
",",
"*",
"*",
"plt_kwargs",
")",
":",
"grid",
"=",
"plt_kwargs",
".",
"pop",
"(",
"'grid'",
",",
"True",
")",
"same_fig",
"=",
"plt_kwargs",
".",
"pop",
"(",
"'same_fig... | aeba2e3040b360bb26556f643cccbfb3dac3b8fb |
train | root | Multipart AJAX request example.
See: http://test.getify.com/mpAjax/description.html | example/stream.py | def root(context):
"""Multipart AJAX request example.
See: http://test.getify.com/mpAjax/description.html
"""
response = context.response
parts = []
for i in range(12):
for j in range(12):
parts.append(executor.submit(mul, i, j))
def stream(parts, timeout=None):
try:
for future in as_complete... | def root(context):
"""Multipart AJAX request example.
See: http://test.getify.com/mpAjax/description.html
"""
response = context.response
parts = []
for i in range(12):
for j in range(12):
parts.append(executor.submit(mul, i, j))
def stream(parts, timeout=None):
try:
for future in as_complete... | [
"Multipart",
"AJAX",
"request",
"example",
".",
"See",
":",
"http",
":",
"//",
"test",
".",
"getify",
".",
"com",
"/",
"mpAjax",
"/",
"description",
".",
"html"
] | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/example/stream.py#L16-L49 | [
"def",
"root",
"(",
"context",
")",
":",
"response",
"=",
"context",
".",
"response",
"parts",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"12",
")",
":",
"for",
"j",
"in",
"range",
"(",
"12",
")",
":",
"parts",
".",
"append",
"(",
"executor",... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | render_template_with_args_in_file | Get a file and render the content of the template_file_name with kwargs in a file
:param file: A File Stream to write
:param template_file_name: path to route with template name
:param **kwargs: Args to be rendered in template | django_crud_generator/django_crud_generator.py | def render_template_with_args_in_file(file, template_file_name, **kwargs):
"""
Get a file and render the content of the template_file_name with kwargs in a file
:param file: A File Stream to write
:param template_file_name: path to route with template name
:param **kwargs: Args to be rendered in tem... | def render_template_with_args_in_file(file, template_file_name, **kwargs):
"""
Get a file and render the content of the template_file_name with kwargs in a file
:param file: A File Stream to write
:param template_file_name: path to route with template name
:param **kwargs: Args to be rendered in tem... | [
"Get",
"a",
"file",
"and",
"render",
"the",
"content",
"of",
"the",
"template_file_name",
"with",
"kwargs",
"in",
"a",
"file",
":",
"param",
"file",
":",
"A",
"File",
"Stream",
"to",
"write",
":",
"param",
"template_file_name",
":",
"path",
"to",
"route",
... | contraslash/django-crud-generator | python | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L20-L34 | [
"def",
"render_template_with_args_in_file",
"(",
"file",
",",
"template_file_name",
",",
"*",
"*",
"kwargs",
")",
":",
"template_file_content",
"=",
"\"\"",
".",
"join",
"(",
"codecs",
".",
"open",
"(",
"template_file_name",
",",
"encoding",
"=",
"'UTF-8'",
")",... | 9080a227291a36cf0d93b49d20601e55a616da1e |
train | create_or_open | Creates a file or open the file with file_name name
:param file_name: String with a filename
:param initial_template_file_name: String with path to initial template
:param args: from console to determine path to save the files | django_crud_generator/django_crud_generator.py | def create_or_open(file_name, initial_template_file_name, args):
"""
Creates a file or open the file with file_name name
:param file_name: String with a filename
:param initial_template_file_name: String with path to initial template
:param args: from console to determine path to save the files
... | def create_or_open(file_name, initial_template_file_name, args):
"""
Creates a file or open the file with file_name name
:param file_name: String with a filename
:param initial_template_file_name: String with path to initial template
:param args: from console to determine path to save the files
... | [
"Creates",
"a",
"file",
"or",
"open",
"the",
"file",
"with",
"file_name",
"name",
":",
"param",
"file_name",
":",
"String",
"with",
"a",
"filename",
":",
"param",
"initial_template_file_name",
":",
"String",
"with",
"path",
"to",
"initial",
"template",
":",
... | contraslash/django-crud-generator | python | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L37-L74 | [
"def",
"create_or_open",
"(",
"file_name",
",",
"initial_template_file_name",
",",
"args",
")",
":",
"file",
"=",
"None",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"args",
"[",
"'django_application_folder'",
"... | 9080a227291a36cf0d93b49d20601e55a616da1e |
train | generic_insert_module | In general we have a initial template and then insert new data, so we dont repeat the schema for each module
:param module_name: String with module name
:paran **kwargs: Args to be rendered in template | django_crud_generator/django_crud_generator.py | def generic_insert_module(module_name, args, **kwargs):
"""
In general we have a initial template and then insert new data, so we dont repeat the schema for each module
:param module_name: String with module name
:paran **kwargs: Args to be rendered in template
"""
file = create_or_open(
... | def generic_insert_module(module_name, args, **kwargs):
"""
In general we have a initial template and then insert new data, so we dont repeat the schema for each module
:param module_name: String with module name
:paran **kwargs: Args to be rendered in template
"""
file = create_or_open(
... | [
"In",
"general",
"we",
"have",
"a",
"initial",
"template",
"and",
"then",
"insert",
"new",
"data",
"so",
"we",
"dont",
"repeat",
"the",
"schema",
"for",
"each",
"module",
":",
"param",
"module_name",
":",
"String",
"with",
"module",
"name",
":",
"paran",
... | contraslash/django-crud-generator | python | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L77-L100 | [
"def",
"generic_insert_module",
"(",
"module_name",
",",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"file",
"=",
"create_or_open",
"(",
"'{}.py'",
".",
"format",
"(",
"module_name",
")",
",",
"os",
".",
"path",
".",
"join",
"(",
"BASE_TEMPLATES_DIR",
",",
... | 9080a227291a36cf0d93b49d20601e55a616da1e |
train | sanity_check | Verify if the work folder is a django app.
A valid django app always must have a models.py file
:return: None | django_crud_generator/django_crud_generator.py | def sanity_check(args):
"""
Verify if the work folder is a django app.
A valid django app always must have a models.py file
:return: None
"""
if not os.path.isfile(
os.path.join(
args['django_application_folder'],
'models.py'
)
):
print("django... | def sanity_check(args):
"""
Verify if the work folder is a django app.
A valid django app always must have a models.py file
:return: None
"""
if not os.path.isfile(
os.path.join(
args['django_application_folder'],
'models.py'
)
):
print("django... | [
"Verify",
"if",
"the",
"work",
"folder",
"is",
"a",
"django",
"app",
".",
"A",
"valid",
"django",
"app",
"always",
"must",
"have",
"a",
"models",
".",
"py",
"file",
":",
"return",
":",
"None"
] | contraslash/django-crud-generator | python | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L103-L116 | [
"def",
"sanity_check",
"(",
"args",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"args",
"[",
"'django_application_folder'",
"]",
",",
"'models.py'",
")",
")",
":",
"print",
"(",
"\"django_application... | 9080a227291a36cf0d93b49d20601e55a616da1e |
train | generic_insert_with_folder | In general if we need to put a file on a folder, we use this method | django_crud_generator/django_crud_generator.py | def generic_insert_with_folder(folder_name, file_name, template_name, args):
"""
In general if we need to put a file on a folder, we use this method
"""
# First we make sure views are a package instead a file
if not os.path.isdir(
os.path.join(
args['django_application_folder'],
... | def generic_insert_with_folder(folder_name, file_name, template_name, args):
"""
In general if we need to put a file on a folder, we use this method
"""
# First we make sure views are a package instead a file
if not os.path.isdir(
os.path.join(
args['django_application_folder'],
... | [
"In",
"general",
"if",
"we",
"need",
"to",
"put",
"a",
"file",
"on",
"a",
"folder",
"we",
"use",
"this",
"method"
] | contraslash/django-crud-generator | python | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L119-L160 | [
"def",
"generic_insert_with_folder",
"(",
"folder_name",
",",
"file_name",
",",
"template_name",
",",
"args",
")",
":",
"# First we make sure views are a package instead a file",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",
"join",
"(... | 9080a227291a36cf0d93b49d20601e55a616da1e |
train | serve | The recommended development HTTP server.
Note that this server performs additional buffering and will not honour chunked encoding breaks. | web/server/waitress_.py | def serve(application, host='127.0.0.1', port=8080, threads=4, **kw):
"""The recommended development HTTP server.
Note that this server performs additional buffering and will not honour chunked encoding breaks.
"""
# Bind and start the server; this is a blocking process.
serve_(application, host=host, port=int... | def serve(application, host='127.0.0.1', port=8080, threads=4, **kw):
"""The recommended development HTTP server.
Note that this server performs additional buffering and will not honour chunked encoding breaks.
"""
# Bind and start the server; this is a blocking process.
serve_(application, host=host, port=int... | [
"The",
"recommended",
"development",
"HTTP",
"server",
".",
"Note",
"that",
"this",
"server",
"performs",
"additional",
"buffering",
"and",
"will",
"not",
"honour",
"chunked",
"encoding",
"breaks",
"."
] | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/waitress_.py#L18-L25 | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
",",
"threads",
"=",
"4",
",",
"*",
"*",
"kw",
")",
":",
"# Bind and start the server; this is a blocking process.",
"serve_",
"(",
"application",
",",
"host",
"=",
... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | NeuroMLSimulation.show | Plot the result of the simulation once it's been intialized | pyneuroml/tune/NeuroMLSimulation.py | def show(self):
"""
Plot the result of the simulation once it's been intialized
"""
from matplotlib import pyplot as plt
if self.already_run:
for ref in self.volts.keys():
plt.plot(self.t, self.volts[ref], label=ref)
plt... | def show(self):
"""
Plot the result of the simulation once it's been intialized
"""
from matplotlib import pyplot as plt
if self.already_run:
for ref in self.volts.keys():
plt.plot(self.t, self.volts[ref], label=ref)
plt... | [
"Plot",
"the",
"result",
"of",
"the",
"simulation",
"once",
"it",
"s",
"been",
"intialized"
] | NeuroML/pyNeuroML | python | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/tune/NeuroMLSimulation.py#L58-L77 | [
"def",
"show",
"(",
"self",
")",
":",
"from",
"matplotlib",
"import",
"pyplot",
"as",
"plt",
"if",
"self",
".",
"already_run",
":",
"for",
"ref",
"in",
"self",
".",
"volts",
".",
"keys",
"(",
")",
":",
"plt",
".",
"plot",
"(",
"self",
".",
"t",
"... | aeba2e3040b360bb26556f643cccbfb3dac3b8fb |
train | Root.mul | Multiply two values together and return the result via JSON.
Python 3 function annotations are used to ensure that the arguments are integers. This requires the
functionality of `web.ext.annotation:AnnotationExtension`.
There are several ways to execute this method:
* POST http://localhost:8080/mul
*... | example/annotation.py | def mul(self, a: int = None, b: int = None) -> 'json':
"""Multiply two values together and return the result via JSON.
Python 3 function annotations are used to ensure that the arguments are integers. This requires the
functionality of `web.ext.annotation:AnnotationExtension`.
There are several ways to ex... | def mul(self, a: int = None, b: int = None) -> 'json':
"""Multiply two values together and return the result via JSON.
Python 3 function annotations are used to ensure that the arguments are integers. This requires the
functionality of `web.ext.annotation:AnnotationExtension`.
There are several ways to ex... | [
"Multiply",
"two",
"values",
"together",
"and",
"return",
"the",
"result",
"via",
"JSON",
".",
"Python",
"3",
"function",
"annotations",
"are",
"used",
"to",
"ensure",
"that",
"the",
"arguments",
"are",
"integers",
".",
"This",
"requires",
"the",
"functionalit... | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/example/annotation.py#L15-L42 | [
"def",
"mul",
"(",
"self",
",",
"a",
":",
"int",
"=",
"None",
",",
"b",
":",
"int",
"=",
"None",
")",
"->",
"'json'",
":",
"if",
"not",
"a",
"or",
"not",
"b",
":",
"return",
"dict",
"(",
"message",
"=",
"\"Pass arguments a and b to multiply them togeth... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | colorize | Returns the colored string to print on the terminal.
This function detects the terminal type and if it is supported and the
output is not going to a pipe or a file, then it will return the colored
string, otherwise it will return the string without modifications.
string = the string to print. Only acc... | xtermcolor/__init__.py | def colorize(string, rgb=None, ansi=None, bg=None, ansi_bg=None, fd=1):
'''Returns the colored string to print on the terminal.
This function detects the terminal type and if it is supported and the
output is not going to a pipe or a file, then it will return the colored
string, otherwise it will retur... | def colorize(string, rgb=None, ansi=None, bg=None, ansi_bg=None, fd=1):
'''Returns the colored string to print on the terminal.
This function detects the terminal type and if it is supported and the
output is not going to a pipe or a file, then it will return the colored
string, otherwise it will retur... | [
"Returns",
"the",
"colored",
"string",
"to",
"print",
"on",
"the",
"terminal",
"."
] | broadinstitute/xtermcolor | python | https://github.com/broadinstitute/xtermcolor/blob/2615100979eb59744597c9d01e6fd1b711b311e1/xtermcolor/__init__.py#L6-L45 | [
"def",
"colorize",
"(",
"string",
",",
"rgb",
"=",
"None",
",",
"ansi",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"ansi_bg",
"=",
"None",
",",
"fd",
"=",
"1",
")",
":",
"#Reinitializes if fd used is different",
"if",
"colorize",
".",
"fd",
"!=",
"fd",
... | 2615100979eb59744597c9d01e6fd1b711b311e1 |
train | AnnotationExtension.mutate | Inspect and potentially mutate the given handler's arguments.
The args list and kw dictionary may be freely modified, though invalid arguments to the handler will fail. | web/ext/annotation.py | def mutate(self, context, handler, args, kw):
"""Inspect and potentially mutate the given handler's arguments.
The args list and kw dictionary may be freely modified, though invalid arguments to the handler will fail.
"""
def cast(arg, val):
if arg not in annotations:
return
cast = annotations[... | def mutate(self, context, handler, args, kw):
"""Inspect and potentially mutate the given handler's arguments.
The args list and kw dictionary may be freely modified, though invalid arguments to the handler will fail.
"""
def cast(arg, val):
if arg not in annotations:
return
cast = annotations[... | [
"Inspect",
"and",
"potentially",
"mutate",
"the",
"given",
"handler",
"s",
"arguments",
".",
"The",
"args",
"list",
"and",
"kw",
"dictionary",
"may",
"be",
"freely",
"modified",
"though",
"invalid",
"arguments",
"to",
"the",
"handler",
"will",
"fail",
"."
] | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/annotation.py#L48-L87 | [
"def",
"mutate",
"(",
"self",
",",
"context",
",",
"handler",
",",
"args",
",",
"kw",
")",
":",
"def",
"cast",
"(",
"arg",
",",
"val",
")",
":",
"if",
"arg",
"not",
"in",
"annotations",
":",
"return",
"cast",
"=",
"annotations",
"[",
"key",
"]",
... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | AnnotationExtension.transform | Transform the value returned by the controller endpoint.
This extension transforms returned values if the endpoint has a return type annotation. | web/ext/annotation.py | def transform(self, context, handler, result):
"""Transform the value returned by the controller endpoint.
This extension transforms returned values if the endpoint has a return type annotation.
"""
handler = handler.__func__ if hasattr(handler, '__func__') else handler
annotation = getattr(handler, '__ann... | def transform(self, context, handler, result):
"""Transform the value returned by the controller endpoint.
This extension transforms returned values if the endpoint has a return type annotation.
"""
handler = handler.__func__ if hasattr(handler, '__func__') else handler
annotation = getattr(handler, '__ann... | [
"Transform",
"the",
"value",
"returned",
"by",
"the",
"controller",
"endpoint",
".",
"This",
"extension",
"transforms",
"returned",
"values",
"if",
"the",
"endpoint",
"has",
"a",
"return",
"type",
"annotation",
"."
] | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/annotation.py#L89-L100 | [
"def",
"transform",
"(",
"self",
",",
"context",
",",
"handler",
",",
"result",
")",
":",
"handler",
"=",
"handler",
".",
"__func__",
"if",
"hasattr",
"(",
"handler",
",",
"'__func__'",
")",
"else",
"handler",
"annotation",
"=",
"getattr",
"(",
"handler",
... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | process_args | Parse command-line arguments. | pyneuroml/tune/NeuroMLTuner.py | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(
description=("A script which can be run to tune a NeuroML 2 model against a number of target properties. Work in progress!"))
parser.add_argument('prefix',
... | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(
description=("A script which can be run to tune a NeuroML 2 model against a number of target properties. Work in progress!"))
parser.add_argument('prefix',
... | [
"Parse",
"command",
"-",
"line",
"arguments",
"."
] | NeuroML/pyNeuroML | python | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/tune/NeuroMLTuner.py#L52-L209 | [
"def",
"process_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"(",
"\"A script which can be run to tune a NeuroML 2 model against a number of target properties. Work in progress!\"",
")",
")",
"parser",
".",
"add_argument",
"... | aeba2e3040b360bb26556f643cccbfb3dac3b8fb |
train | process_args | Parse command-line arguments. | pyneuroml/povray/MakeMovie.py | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A file for overlaying POVRay files generated from NeuroML by NeuroML1ToPOVRay.py with cell activity (e.g. as generated from a neuroConstruct simulation)")
parser.add_argument('prefix',
... | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A file for overlaying POVRay files generated from NeuroML by NeuroML1ToPOVRay.py with cell activity (e.g. as generated from a neuroConstruct simulation)")
parser.add_argument('prefix',
... | [
"Parse",
"command",
"-",
"line",
"arguments",
"."
] | NeuroML/pyNeuroML | python | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/povray/MakeMovie.py#L27-L92 | [
"def",
"process_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"A file for overlaying POVRay files generated from NeuroML by NeuroML1ToPOVRay.py with cell activity (e.g. as generated from a neuroConstruct simulation)\"",
")",
"parser"... | aeba2e3040b360bb26556f643cccbfb3dac3b8fb |
train | serve | Tornado's HTTPServer.
This is a high quality asynchronous server with many options. For details, please visit:
http://www.tornadoweb.org/en/stable/httpserver.html#http-server | web/server/tornado_.py | def serve(application, host='127.0.0.1', port=8080, **options):
"""Tornado's HTTPServer.
This is a high quality asynchronous server with many options. For details, please visit:
http://www.tornadoweb.org/en/stable/httpserver.html#http-server
"""
# Wrap our our WSGI application (potentially stack) in a Torn... | def serve(application, host='127.0.0.1', port=8080, **options):
"""Tornado's HTTPServer.
This is a high quality asynchronous server with many options. For details, please visit:
http://www.tornadoweb.org/en/stable/httpserver.html#http-server
"""
# Wrap our our WSGI application (potentially stack) in a Torn... | [
"Tornado",
"s",
"HTTPServer",
".",
"This",
"is",
"a",
"high",
"quality",
"asynchronous",
"server",
"with",
"many",
"options",
".",
"For",
"details",
"please",
"visit",
":",
"http",
":",
"//",
"www",
".",
"tornadoweb",
".",
"org",
"/",
"en",
"/",
"stable"... | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/tornado_.py#L18-L34 | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
",",
"*",
"*",
"options",
")",
":",
"# Wrap our our WSGI application (potentially stack) in a Tornado adapter.",
"container",
"=",
"tornado",
".",
"wsgi",
".",
"WSGIContai... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | parse_arguments | Parse command line arguments | pyneuroml/pynml.py | def parse_arguments():
"""Parse command line arguments"""
import argparse
parser = argparse.ArgumentParser(
description=('pyNeuroML v%s: Python utilities for NeuroML2' % __version__
+ "\n libNeuroML v%s"%(neuroml.__version__)
+ "\n jNe... | def parse_arguments():
"""Parse command line arguments"""
import argparse
parser = argparse.ArgumentParser(
description=('pyNeuroML v%s: Python utilities for NeuroML2' % __version__
+ "\n libNeuroML v%s"%(neuroml.__version__)
+ "\n jNe... | [
"Parse",
"command",
"line",
"arguments"
] | NeuroML/pyNeuroML | python | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/pynml.py#L43-L245 | [
"def",
"parse_arguments",
"(",
")",
":",
"import",
"argparse",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"(",
"'pyNeuroML v%s: Python utilities for NeuroML2'",
"%",
"__version__",
"+",
"\"\\n libNeuroML v%s\"",
"%",
"(",
"neuroml",
... | aeba2e3040b360bb26556f643cccbfb3dac3b8fb |
train | quick_summary | Or better just use nml2_doc.summary(show_includes=False) | pyneuroml/pynml.py | def quick_summary(nml2_doc):
'''
Or better just use nml2_doc.summary(show_includes=False)
'''
info = 'Contents of NeuroML 2 document: %s\n'%nml2_doc.id
membs = inspect.getmembers(nml2_doc)
for memb in membs:
if isinstance(memb[1], list) and len(memb[1])>0 \
and not... | def quick_summary(nml2_doc):
'''
Or better just use nml2_doc.summary(show_includes=False)
'''
info = 'Contents of NeuroML 2 document: %s\n'%nml2_doc.id
membs = inspect.getmembers(nml2_doc)
for memb in membs:
if isinstance(memb[1], list) and len(memb[1])>0 \
and not... | [
"Or",
"better",
"just",
"use",
"nml2_doc",
".",
"summary",
"(",
"show_includes",
"=",
"False",
")"
] | NeuroML/pyNeuroML | python | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/pynml.py#L419-L441 | [
"def",
"quick_summary",
"(",
"nml2_doc",
")",
":",
"info",
"=",
"'Contents of NeuroML 2 document: %s\\n'",
"%",
"nml2_doc",
".",
"id",
"membs",
"=",
"inspect",
".",
"getmembers",
"(",
"nml2_doc",
")",
"for",
"memb",
"in",
"membs",
":",
"if",
"isinstance",
"(",... | aeba2e3040b360bb26556f643cccbfb3dac3b8fb |
train | execute_command_in_dir | Execute a command in specific working directory | pyneuroml/pynml.py | def execute_command_in_dir(command, directory, verbose=DEFAULTS['v'],
prefix="Output: ", env=None):
"""Execute a command in specific working directory"""
if os.name == 'nt':
directory = os.path.normpath(directory)
print_comment("Executing: (%s) in direc... | def execute_command_in_dir(command, directory, verbose=DEFAULTS['v'],
prefix="Output: ", env=None):
"""Execute a command in specific working directory"""
if os.name == 'nt':
directory = os.path.normpath(directory)
print_comment("Executing: (%s) in direc... | [
"Execute",
"a",
"command",
"in",
"specific",
"working",
"directory"
] | NeuroML/pyNeuroML | python | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/pynml.py#L1181-L1239 | [
"def",
"execute_command_in_dir",
"(",
"command",
",",
"directory",
",",
"verbose",
"=",
"DEFAULTS",
"[",
"'v'",
"]",
",",
"prefix",
"=",
"\"Output: \"",
",",
"env",
"=",
"None",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"directory",
"=",
"o... | aeba2e3040b360bb26556f643cccbfb3dac3b8fb |
train | evaluate_component | print_comment_v(exec_str) | pyneuroml/pynml.py | def evaluate_component(comp_type, req_variables={}, parameter_values={}):
print_comment('Evaluating %s with req:%s; params:%s'%(comp_type.name,req_variables,parameter_values))
exec_str = ''
return_vals = {}
from math import exp
for p in parameter_values:
exec_str+='%s = %s\n'%(p, get_va... | def evaluate_component(comp_type, req_variables={}, parameter_values={}):
print_comment('Evaluating %s with req:%s; params:%s'%(comp_type.name,req_variables,parameter_values))
exec_str = ''
return_vals = {}
from math import exp
for p in parameter_values:
exec_str+='%s = %s\n'%(p, get_va... | [
"print_comment_v",
"(",
"exec_str",
")"
] | NeuroML/pyNeuroML | python | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/pynml.py#L1431-L1462 | [
"def",
"evaluate_component",
"(",
"comp_type",
",",
"req_variables",
"=",
"{",
"}",
",",
"parameter_values",
"=",
"{",
"}",
")",
":",
"print_comment",
"(",
"'Evaluating %s with req:%s; params:%s'",
"%",
"(",
"comp_type",
".",
"name",
",",
"req_variables",
",",
"... | aeba2e3040b360bb26556f643cccbfb3dac3b8fb |
train | AnalyticsExtension.after | Executed after dispatch has returned and the response populated, prior to anything being sent to the client. | web/ext/analytics.py | def after(self, context, exc=None):
"""Executed after dispatch has returned and the response populated, prior to anything being sent to the client."""
duration = context._duration = round((time.time() - context._start_time) * 1000) # Convert to ms.
delta = unicode(duration)
# Default response augmentatio... | def after(self, context, exc=None):
"""Executed after dispatch has returned and the response populated, prior to anything being sent to the client."""
duration = context._duration = round((time.time() - context._start_time) * 1000) # Convert to ms.
delta = unicode(duration)
# Default response augmentatio... | [
"Executed",
"after",
"dispatch",
"has",
"returned",
"and",
"the",
"response",
"populated",
"prior",
"to",
"anything",
"being",
"sent",
"to",
"the",
"client",
"."
] | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/analytics.py#L55-L69 | [
"def",
"after",
"(",
"self",
",",
"context",
",",
"exc",
"=",
"None",
")",
":",
"duration",
"=",
"context",
".",
"_duration",
"=",
"round",
"(",
"(",
"time",
".",
"time",
"(",
")",
"-",
"context",
".",
"_start_time",
")",
"*",
"1000",
")",
"# Conve... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | ArgumentExtension._process_flat_kwargs | Apply a flat namespace transformation to recreate (in some respects) a rich structure.
This applies several transformations, which may be nested:
`foo` (singular): define a simple value named `foo`
`foo` (repeated): define a simple value for placement in an array named `foo`
`foo[]`: define a simple value... | web/ext/args.py | def _process_flat_kwargs(source, kwargs):
"""Apply a flat namespace transformation to recreate (in some respects) a rich structure.
This applies several transformations, which may be nested:
`foo` (singular): define a simple value named `foo`
`foo` (repeated): define a simple value for placement in an arr... | def _process_flat_kwargs(source, kwargs):
"""Apply a flat namespace transformation to recreate (in some respects) a rich structure.
This applies several transformations, which may be nested:
`foo` (singular): define a simple value named `foo`
`foo` (repeated): define a simple value for placement in an arr... | [
"Apply",
"a",
"flat",
"namespace",
"transformation",
"to",
"recreate",
"(",
"in",
"some",
"respects",
")",
"a",
"rich",
"structure",
".",
"This",
"applies",
"several",
"transformations",
"which",
"may",
"be",
"nested",
":",
"foo",
"(",
"singular",
")",
":",
... | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/args.py#L22-L87 | [
"def",
"_process_flat_kwargs",
"(",
"source",
",",
"kwargs",
")",
":",
"ordered_arrays",
"=",
"[",
"]",
"# Process arguments one at a time and apply them to the kwargs passed in.",
"for",
"name",
",",
"value",
"in",
"source",
".",
"items",
"(",
")",
":",
"container",
... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | process_args | Parse command-line arguments. | pyneuroml/povray/NeuroML2ToPOVRay.py | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A file for converting NeuroML v2 files into POVRay files for 3D rendering")
parser.add_argument('neuroml_file', type=str, metavar='<NeuroML file>',
help='NeuroML ... | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A file for converting NeuroML v2 files into POVRay files for 3D rendering")
parser.add_argument('neuroml_file', type=str, metavar='<NeuroML file>',
help='NeuroML ... | [
"Parse",
"command",
"-",
"line",
"arguments",
"."
] | NeuroML/pyNeuroML | python | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/povray/NeuroML2ToPOVRay.py#L27-L143 | [
"def",
"process_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"A file for converting NeuroML v2 files into POVRay files for 3D rendering\"",
")",
"parser",
".",
"add_argument",
"(",
"'neuroml_file'",
",",
"type",
"=",
... | aeba2e3040b360bb26556f643cccbfb3dac3b8fb |
train | Application._configure | Prepare the incoming configuration and ensure certain expected values are present.
For example, this ensures BaseExtension is included in the extension list, and populates the logging config. | web/core/application.py | def _configure(self, config):
"""Prepare the incoming configuration and ensure certain expected values are present.
For example, this ensures BaseExtension is included in the extension list, and populates the logging config.
"""
config = config or dict()
# We really need this to be there.
if 'extensio... | def _configure(self, config):
"""Prepare the incoming configuration and ensure certain expected values are present.
For example, this ensures BaseExtension is included in the extension list, and populates the logging config.
"""
config = config or dict()
# We really need this to be there.
if 'extensio... | [
"Prepare",
"the",
"incoming",
"configuration",
"and",
"ensure",
"certain",
"expected",
"values",
"are",
"present",
".",
"For",
"example",
"this",
"ensures",
"BaseExtension",
"is",
"included",
"in",
"the",
"extension",
"list",
"and",
"populates",
"the",
"logging",
... | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/core/application.py#L108-L147 | [
"def",
"_configure",
"(",
"self",
",",
"config",
")",
":",
"config",
"=",
"config",
"or",
"dict",
"(",
")",
"# We really need this to be there.",
"if",
"'extensions'",
"not",
"in",
"config",
":",
"config",
"[",
"'extensions'",
"]",
"=",
"list",
"(",
")",
"... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | Application.serve | Initiate a web server service to serve this application.
You can always use the Application instance as a bare WSGI application, of course. This method is provided as
a convienence.
Pass in the name of the service you wish to use, and any additional configuration options appropriate for that
service. Al... | web/core/application.py | def serve(self, service='auto', **options): # pragma: no cover
"""Initiate a web server service to serve this application.
You can always use the Application instance as a bare WSGI application, of course. This method is provided as
a convienence.
Pass in the name of the service you wish to use, and any... | def serve(self, service='auto', **options): # pragma: no cover
"""Initiate a web server service to serve this application.
You can always use the Application instance as a bare WSGI application, of course. This method is provided as
a convienence.
Pass in the name of the service you wish to use, and any... | [
"Initiate",
"a",
"web",
"server",
"service",
"to",
"serve",
"this",
"application",
".",
"You",
"can",
"always",
"use",
"the",
"Application",
"instance",
"as",
"a",
"bare",
"WSGI",
"application",
"of",
"course",
".",
"This",
"method",
"is",
"provided",
"as",
... | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/core/application.py#L151-L170 | [
"def",
"serve",
"(",
"self",
",",
"service",
"=",
"'auto'",
",",
"*",
"*",
"options",
")",
":",
"# pragma: no cover",
"service",
"=",
"load",
"(",
"service",
",",
"'web.server'",
")",
"# We don't bother with a full registry for these one-time lookups.",
"try",
":",
... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | Application.application | Process a single WSGI request/response cycle.
This is the WSGI handler for WebCore. Depending on the presence of extensions providing WSGI middleware,
the `__call__` attribute of the Application instance will either become this, or become the outermost
middleware callable.
Most apps won't utilize middlew... | web/core/application.py | def application(self, environ, start_response):
"""Process a single WSGI request/response cycle.
This is the WSGI handler for WebCore. Depending on the presence of extensions providing WSGI middleware,
the `__call__` attribute of the Application instance will either become this, or become the outermost
midd... | def application(self, environ, start_response):
"""Process a single WSGI request/response cycle.
This is the WSGI handler for WebCore. Depending on the presence of extensions providing WSGI middleware,
the `__call__` attribute of the Application instance will either become this, or become the outermost
midd... | [
"Process",
"a",
"single",
"WSGI",
"request",
"/",
"response",
"cycle",
".",
"This",
"is",
"the",
"WSGI",
"handler",
"for",
"WebCore",
".",
"Depending",
"on",
"the",
"presence",
"of",
"extensions",
"providing",
"WSGI",
"middleware",
"the",
"__call__",
"attribut... | marrow/WebCore | python | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/core/application.py#L217-L280 | [
"def",
"application",
"(",
"self",
",",
"environ",
",",
"start_response",
")",
":",
"context",
"=",
"environ",
"[",
"'wc.context'",
"]",
"=",
"self",
".",
"RequestContext",
"(",
"environ",
"=",
"environ",
")",
"signals",
"=",
"context",
".",
"extension",
"... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 |
train | Alignment._swap | Swaps the alignment so that the reference becomes the query and vice-versa. Swaps their names, coordinates etc. The frame is not changed | pymummer/alignment.py | def _swap(self):
'''Swaps the alignment so that the reference becomes the query and vice-versa. Swaps their names, coordinates etc. The frame is not changed'''
self.ref_start, self.qry_start = self.qry_start, self.ref_start
self.ref_end, self.qry_end = self.qry_end, self.ref_end
self.hit... | def _swap(self):
'''Swaps the alignment so that the reference becomes the query and vice-versa. Swaps their names, coordinates etc. The frame is not changed'''
self.ref_start, self.qry_start = self.qry_start, self.ref_start
self.ref_end, self.qry_end = self.qry_end, self.ref_end
self.hit... | [
"Swaps",
"the",
"alignment",
"so",
"that",
"the",
"reference",
"becomes",
"the",
"query",
"and",
"vice",
"-",
"versa",
".",
"Swaps",
"their",
"names",
"coordinates",
"etc",
".",
"The",
"frame",
"is",
"not",
"changed"
] | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L52-L58 | [
"def",
"_swap",
"(",
"self",
")",
":",
"self",
".",
"ref_start",
",",
"self",
".",
"qry_start",
"=",
"self",
".",
"qry_start",
",",
"self",
".",
"ref_start",
"self",
".",
"ref_end",
",",
"self",
".",
"qry_end",
"=",
"self",
".",
"qry_end",
",",
"self... | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | Alignment.qry_coords | Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the query sequence | pymummer/alignment.py | def qry_coords(self):
'''Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the query sequence'''
return pyfastaq.intervals.Interval(min(self.qry_start, self.qry_end), max(self.qry_start, self.qry_end)) | def qry_coords(self):
'''Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the query sequence'''
return pyfastaq.intervals.Interval(min(self.qry_start, self.qry_end), max(self.qry_start, self.qry_end)) | [
"Returns",
"a",
"pyfastaq",
".",
"intervals",
".",
"Interval",
"object",
"of",
"the",
"start",
"and",
"end",
"coordinates",
"in",
"the",
"query",
"sequence"
] | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L61-L63 | [
"def",
"qry_coords",
"(",
"self",
")",
":",
"return",
"pyfastaq",
".",
"intervals",
".",
"Interval",
"(",
"min",
"(",
"self",
".",
"qry_start",
",",
"self",
".",
"qry_end",
")",
",",
"max",
"(",
"self",
".",
"qry_start",
",",
"self",
".",
"qry_end",
... | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | Alignment.ref_coords | Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the reference sequence | pymummer/alignment.py | def ref_coords(self):
'''Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the reference sequence'''
return pyfastaq.intervals.Interval(min(self.ref_start, self.ref_end), max(self.ref_start, self.ref_end)) | def ref_coords(self):
'''Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the reference sequence'''
return pyfastaq.intervals.Interval(min(self.ref_start, self.ref_end), max(self.ref_start, self.ref_end)) | [
"Returns",
"a",
"pyfastaq",
".",
"intervals",
".",
"Interval",
"object",
"of",
"the",
"start",
"and",
"end",
"coordinates",
"in",
"the",
"reference",
"sequence"
] | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L66-L68 | [
"def",
"ref_coords",
"(",
"self",
")",
":",
"return",
"pyfastaq",
".",
"intervals",
".",
"Interval",
"(",
"min",
"(",
"self",
".",
"ref_start",
",",
"self",
".",
"ref_end",
")",
",",
"max",
"(",
"self",
".",
"ref_start",
",",
"self",
".",
"ref_end",
... | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | Alignment.on_same_strand | Returns true iff the direction of the alignment is the same in the reference and the query | pymummer/alignment.py | def on_same_strand(self):
'''Returns true iff the direction of the alignment is the same in the reference and the query'''
return (self.ref_start < self.ref_end) == (self.qry_start < self.qry_end) | def on_same_strand(self):
'''Returns true iff the direction of the alignment is the same in the reference and the query'''
return (self.ref_start < self.ref_end) == (self.qry_start < self.qry_end) | [
"Returns",
"true",
"iff",
"the",
"direction",
"of",
"the",
"alignment",
"is",
"the",
"same",
"in",
"the",
"reference",
"and",
"the",
"query"
] | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L71-L73 | [
"def",
"on_same_strand",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"ref_start",
"<",
"self",
".",
"ref_end",
")",
"==",
"(",
"self",
".",
"qry_start",
"<",
"self",
".",
"qry_end",
")"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | Alignment.is_self_hit | Returns true iff the alignment is of a sequence to itself: names and all coordinates are the same and 100 percent identity | pymummer/alignment.py | def is_self_hit(self):
'''Returns true iff the alignment is of a sequence to itself: names and all coordinates are the same and 100 percent identity'''
return self.ref_name == self.qry_name \
and self.ref_start == self.qry_start \
and self.ref_end == self.qry_end \
... | def is_self_hit(self):
'''Returns true iff the alignment is of a sequence to itself: names and all coordinates are the same and 100 percent identity'''
return self.ref_name == self.qry_name \
and self.ref_start == self.qry_start \
and self.ref_end == self.qry_end \
... | [
"Returns",
"true",
"iff",
"the",
"alignment",
"is",
"of",
"a",
"sequence",
"to",
"itself",
":",
"names",
"and",
"all",
"coordinates",
"are",
"the",
"same",
"and",
"100",
"percent",
"identity"
] | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L76-L81 | [
"def",
"is_self_hit",
"(",
"self",
")",
":",
"return",
"self",
".",
"ref_name",
"==",
"self",
".",
"qry_name",
"and",
"self",
".",
"ref_start",
"==",
"self",
".",
"qry_start",
"and",
"self",
".",
"ref_end",
"==",
"self",
".",
"qry_end",
"and",
"self",
... | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | Alignment.reverse_query | Changes the coordinates as if the query sequence has been reverse complemented | pymummer/alignment.py | def reverse_query(self):
'''Changes the coordinates as if the query sequence has been reverse complemented'''
self.qry_start = self.qry_length - self.qry_start - 1
self.qry_end = self.qry_length - self.qry_end - 1 | def reverse_query(self):
'''Changes the coordinates as if the query sequence has been reverse complemented'''
self.qry_start = self.qry_length - self.qry_start - 1
self.qry_end = self.qry_length - self.qry_end - 1 | [
"Changes",
"the",
"coordinates",
"as",
"if",
"the",
"query",
"sequence",
"has",
"been",
"reverse",
"complemented"
] | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L84-L87 | [
"def",
"reverse_query",
"(",
"self",
")",
":",
"self",
".",
"qry_start",
"=",
"self",
".",
"qry_length",
"-",
"self",
".",
"qry_start",
"-",
"1",
"self",
".",
"qry_end",
"=",
"self",
".",
"qry_length",
"-",
"self",
".",
"qry_end",
"-",
"1"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | Alignment.reverse_reference | Changes the coordinates as if the reference sequence has been reverse complemented | pymummer/alignment.py | def reverse_reference(self):
'''Changes the coordinates as if the reference sequence has been reverse complemented'''
self.ref_start = self.ref_length - self.ref_start - 1
self.ref_end = self.ref_length - self.ref_end - 1 | def reverse_reference(self):
'''Changes the coordinates as if the reference sequence has been reverse complemented'''
self.ref_start = self.ref_length - self.ref_start - 1
self.ref_end = self.ref_length - self.ref_end - 1 | [
"Changes",
"the",
"coordinates",
"as",
"if",
"the",
"reference",
"sequence",
"has",
"been",
"reverse",
"complemented"
] | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L90-L93 | [
"def",
"reverse_reference",
"(",
"self",
")",
":",
"self",
".",
"ref_start",
"=",
"self",
".",
"ref_length",
"-",
"self",
".",
"ref_start",
"-",
"1",
"self",
".",
"ref_end",
"=",
"self",
".",
"ref_length",
"-",
"self",
".",
"ref_end",
"-",
"1"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | Alignment.to_msp_crunch | Returns the alignment as a line in MSPcrunch format. The columns are space-separated and are:
1. score
2. percent identity
3. match start in the query sequence
4. match end in the query sequence
5. query sequence name
6. subject sequence start
... | pymummer/alignment.py | def to_msp_crunch(self):
'''Returns the alignment as a line in MSPcrunch format. The columns are space-separated and are:
1. score
2. percent identity
3. match start in the query sequence
4. match end in the query sequence
5. query sequence name
... | def to_msp_crunch(self):
'''Returns the alignment as a line in MSPcrunch format. The columns are space-separated and are:
1. score
2. percent identity
3. match start in the query sequence
4. match end in the query sequence
5. query sequence name
... | [
"Returns",
"the",
"alignment",
"as",
"a",
"line",
"in",
"MSPcrunch",
"format",
".",
"The",
"columns",
"are",
"space",
"-",
"separated",
"and",
"are",
":",
"1",
".",
"score",
"2",
".",
"percent",
"identity",
"3",
".",
"match",
"start",
"in",
"the",
"que... | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L113-L136 | [
"def",
"to_msp_crunch",
"(",
"self",
")",
":",
"# we don't know the alignment score. Estimate it. This approximates 1 for a match.",
"aln_score",
"=",
"int",
"(",
"self",
".",
"percent_identity",
"*",
"0.005",
"*",
"(",
"self",
".",
"hit_length_ref",
"+",
"self",
".",
... | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | Alignment.qry_coords_from_ref_coord | Given a reference position and a list of variants ([variant.Variant]),
works out the position in the query sequence, accounting for indels.
Returns a tuple: (position, True|False), where second element is whether
or not the ref_coord lies in an indel. If it is, then
returns t... | pymummer/alignment.py | def qry_coords_from_ref_coord(self, ref_coord, variant_list):
'''Given a reference position and a list of variants ([variant.Variant]),
works out the position in the query sequence, accounting for indels.
Returns a tuple: (position, True|False), where second element is whether
o... | def qry_coords_from_ref_coord(self, ref_coord, variant_list):
'''Given a reference position and a list of variants ([variant.Variant]),
works out the position in the query sequence, accounting for indels.
Returns a tuple: (position, True|False), where second element is whether
o... | [
"Given",
"a",
"reference",
"position",
"and",
"a",
"list",
"of",
"variants",
"(",
"[",
"variant",
".",
"Variant",
"]",
")",
"works",
"out",
"the",
"position",
"in",
"the",
"query",
"sequence",
"accounting",
"for",
"indels",
".",
"Returns",
"a",
"tuple",
... | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L147-L181 | [
"def",
"qry_coords_from_ref_coord",
"(",
"self",
",",
"ref_coord",
",",
"variant_list",
")",
":",
"if",
"self",
".",
"ref_coords",
"(",
")",
".",
"distance_to_point",
"(",
"ref_coord",
")",
">",
"0",
":",
"raise",
"Error",
"(",
"'Cannot get query coord in qry_co... | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | Runner._nucmer_command | Construct the nucmer command | pymummer/nucmer.py | def _nucmer_command(self, ref, qry, outprefix):
'''Construct the nucmer command'''
if self.use_promer:
command = 'promer'
else:
command = 'nucmer'
command += ' -p ' + outprefix
if self.breaklen is not None:
command += ' -b ' + str(self.breakl... | def _nucmer_command(self, ref, qry, outprefix):
'''Construct the nucmer command'''
if self.use_promer:
command = 'promer'
else:
command = 'nucmer'
command += ' -p ' + outprefix
if self.breaklen is not None:
command += ' -b ' + str(self.breakl... | [
"Construct",
"the",
"nucmer",
"command"
] | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/nucmer.py#L53-L83 | [
"def",
"_nucmer_command",
"(",
"self",
",",
"ref",
",",
"qry",
",",
"outprefix",
")",
":",
"if",
"self",
".",
"use_promer",
":",
"command",
"=",
"'promer'",
"else",
":",
"command",
"=",
"'nucmer'",
"command",
"+=",
"' -p '",
"+",
"outprefix",
"if",
"self... | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | Runner._delta_filter_command | Construct delta-filter command | pymummer/nucmer.py | def _delta_filter_command(self, infile, outfile):
'''Construct delta-filter command'''
command = 'delta-filter'
if self.min_id is not None:
command += ' -i ' + str(self.min_id)
if self.min_length is not None:
command += ' -l ' + str(self.min_length)
ret... | def _delta_filter_command(self, infile, outfile):
'''Construct delta-filter command'''
command = 'delta-filter'
if self.min_id is not None:
command += ' -i ' + str(self.min_id)
if self.min_length is not None:
command += ' -l ' + str(self.min_length)
ret... | [
"Construct",
"delta",
"-",
"filter",
"command"
] | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/nucmer.py#L86-L96 | [
"def",
"_delta_filter_command",
"(",
"self",
",",
"infile",
",",
"outfile",
")",
":",
"command",
"=",
"'delta-filter'",
"if",
"self",
".",
"min_id",
"is",
"not",
"None",
":",
"command",
"+=",
"' -i '",
"+",
"str",
"(",
"self",
".",
"min_id",
")",
"if",
... | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | Runner._show_coords_command | Construct show-coords command | pymummer/nucmer.py | def _show_coords_command(self, infile, outfile):
'''Construct show-coords command'''
command = 'show-coords -dTlro'
if not self.coords_header:
command += ' -H'
return command + ' ' + infile + ' > ' + outfile | def _show_coords_command(self, infile, outfile):
'''Construct show-coords command'''
command = 'show-coords -dTlro'
if not self.coords_header:
command += ' -H'
return command + ' ' + infile + ' > ' + outfile | [
"Construct",
"show",
"-",
"coords",
"command"
] | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/nucmer.py#L99-L106 | [
"def",
"_show_coords_command",
"(",
"self",
",",
"infile",
",",
"outfile",
")",
":",
"command",
"=",
"'show-coords -dTlro'",
"if",
"not",
"self",
".",
"coords_header",
":",
"command",
"+=",
"' -H'",
"return",
"command",
"+",
"' '",
"+",
"infile",
"+",
"' > '... | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | Runner._write_script | Write commands into a bash script | pymummer/nucmer.py | def _write_script(self, script_name, ref, qry, outfile):
'''Write commands into a bash script'''
f = pyfastaq.utils.open_file_write(script_name)
print(self._nucmer_command(ref, qry, 'p'), file=f)
print(self._delta_filter_command('p.delta', 'p.delta.filter'), file=f)
print(self._s... | def _write_script(self, script_name, ref, qry, outfile):
'''Write commands into a bash script'''
f = pyfastaq.utils.open_file_write(script_name)
print(self._nucmer_command(ref, qry, 'p'), file=f)
print(self._delta_filter_command('p.delta', 'p.delta.filter'), file=f)
print(self._s... | [
"Write",
"commands",
"into",
"a",
"bash",
"script"
] | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/nucmer.py#L118-L126 | [
"def",
"_write_script",
"(",
"self",
",",
"script_name",
",",
"ref",
",",
"qry",
",",
"outfile",
")",
":",
"f",
"=",
"pyfastaq",
".",
"utils",
".",
"open_file_write",
"(",
"script_name",
")",
"print",
"(",
"self",
".",
"_nucmer_command",
"(",
"ref",
",",... | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | Runner.run | Change to a temp directory
Run bash script containing commands
Place results in specified output file
Clean up temp directory | pymummer/nucmer.py | def run(self):
'''
Change to a temp directory
Run bash script containing commands
Place results in specified output file
Clean up temp directory
'''
qry = os.path.abspath(self.qry)
ref = os.path.abspath(self.ref)
outfile = os.path.abspath(self.outf... | def run(self):
'''
Change to a temp directory
Run bash script containing commands
Place results in specified output file
Clean up temp directory
'''
qry = os.path.abspath(self.qry)
ref = os.path.abspath(self.ref)
outfile = os.path.abspath(self.outf... | [
"Change",
"to",
"a",
"temp",
"directory",
"Run",
"bash",
"script",
"containing",
"commands",
"Place",
"results",
"in",
"specified",
"output",
"file",
"Clean",
"up",
"temp",
"directory"
] | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/nucmer.py#L129-L146 | [
"def",
"run",
"(",
"self",
")",
":",
"qry",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"self",
".",
"qry",
")",
"ref",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"self",
".",
"ref",
")",
"outfile",
"=",
"os",
".",
"path",
".",
"abspath",
... | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | Variant.update_indel | Indels are reported over multiple lines, 1 base insertion or deletion per line. This method extends the current variant by 1 base if it's an indel and adjacent to the new SNP and returns True. If the current variant is a SNP, does nothing and returns False | pymummer/variant.py | def update_indel(self, nucmer_snp):
'''Indels are reported over multiple lines, 1 base insertion or deletion per line. This method extends the current variant by 1 base if it's an indel and adjacent to the new SNP and returns True. If the current variant is a SNP, does nothing and returns False'''
new_v... | def update_indel(self, nucmer_snp):
'''Indels are reported over multiple lines, 1 base insertion or deletion per line. This method extends the current variant by 1 base if it's an indel and adjacent to the new SNP and returns True. If the current variant is a SNP, does nothing and returns False'''
new_v... | [
"Indels",
"are",
"reported",
"over",
"multiple",
"lines",
"1",
"base",
"insertion",
"or",
"deletion",
"per",
"line",
".",
"This",
"method",
"extends",
"the",
"current",
"variant",
"by",
"1",
"base",
"if",
"it",
"s",
"an",
"indel",
"and",
"adjacent",
"to",
... | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/variant.py#L62-L84 | [
"def",
"update_indel",
"(",
"self",
",",
"nucmer_snp",
")",
":",
"new_variant",
"=",
"Variant",
"(",
"nucmer_snp",
")",
"if",
"self",
".",
"var_type",
"not",
"in",
"[",
"INS",
",",
"DEL",
"]",
"or",
"self",
".",
"var_type",
"!=",
"new_variant",
".",
"v... | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | reader | Helper function to open the results file (coords file) and create alignment objects with the values in it | pymummer/coords_file.py | def reader(fname):
'''Helper function to open the results file (coords file) and create alignment objects with the values in it'''
f = pyfastaq.utils.open_file_read(fname)
for line in f:
if line.startswith('[') or (not '\t' in line):
continue
yield alignment.Alignment(line)
... | def reader(fname):
'''Helper function to open the results file (coords file) and create alignment objects with the values in it'''
f = pyfastaq.utils.open_file_read(fname)
for line in f:
if line.startswith('[') or (not '\t' in line):
continue
yield alignment.Alignment(line)
... | [
"Helper",
"function",
"to",
"open",
"the",
"results",
"file",
"(",
"coords",
"file",
")",
"and",
"create",
"alignment",
"objects",
"with",
"the",
"values",
"in",
"it"
] | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/coords_file.py#L6-L16 | [
"def",
"reader",
"(",
"fname",
")",
":",
"f",
"=",
"pyfastaq",
".",
"utils",
".",
"open_file_read",
"(",
"fname",
")",
"for",
"line",
"in",
"f",
":",
"if",
"line",
".",
"startswith",
"(",
"'['",
")",
"or",
"(",
"not",
"'\\t'",
"in",
"line",
")",
... | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | convert_to_msp_crunch | Converts a coords file to a file in MSPcrunch format (for use with ACT, most likely).
ACT ignores sequence names in the crunch file, and just looks at the numbers.
To make a compatible file, the coords all must be shifted appropriately, which
can be done by providing both the ref_fai and qry_fai op... | pymummer/coords_file.py | def convert_to_msp_crunch(infile, outfile, ref_fai=None, qry_fai=None):
'''Converts a coords file to a file in MSPcrunch format (for use with ACT, most likely).
ACT ignores sequence names in the crunch file, and just looks at the numbers.
To make a compatible file, the coords all must be shifted appro... | def convert_to_msp_crunch(infile, outfile, ref_fai=None, qry_fai=None):
'''Converts a coords file to a file in MSPcrunch format (for use with ACT, most likely).
ACT ignores sequence names in the crunch file, and just looks at the numbers.
To make a compatible file, the coords all must be shifted appro... | [
"Converts",
"a",
"coords",
"file",
"to",
"a",
"file",
"in",
"MSPcrunch",
"format",
"(",
"for",
"use",
"with",
"ACT",
"most",
"likely",
")",
".",
"ACT",
"ignores",
"sequence",
"names",
"in",
"the",
"crunch",
"file",
"and",
"just",
"looks",
"at",
"the",
... | sanger-pathogens/pymummer | python | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/coords_file.py#L19-L47 | [
"def",
"convert_to_msp_crunch",
"(",
"infile",
",",
"outfile",
",",
"ref_fai",
"=",
"None",
",",
"qry_fai",
"=",
"None",
")",
":",
"fai_files",
"=",
"{",
"ref_fai",
",",
"qry_fai",
"}",
"if",
"None",
"in",
"fai_files",
"and",
"len",
"(",
"fai_files",
")"... | fd97bccfbae62719a7247473d73dd6733d4fa903 |
train | BurpApi._request | Common handler for all the HTTP requests. | PyBurprestapi/burpscanner.py | def _request(self, method, url, params=None, headers=None, data=None):
"""Common handler for all the HTTP requests."""
if not params:
params = {}
# set default headers
if not headers:
headers = {
'accept': '*/*'
}
if method... | def _request(self, method, url, params=None, headers=None, data=None):
"""Common handler for all the HTTP requests."""
if not params:
params = {}
# set default headers
if not headers:
headers = {
'accept': '*/*'
}
if method... | [
"Common",
"handler",
"for",
"all",
"the",
"HTTP",
"requests",
"."
] | anandtiwarics/python-burp-rest-api | python | https://github.com/anandtiwarics/python-burp-rest-api/blob/1b3fb263ef1d006e181b838ea017ac2abbd68a30/PyBurprestapi/burpscanner.py#L55-L98 | [
"def",
"_request",
"(",
"self",
",",
"method",
",",
"url",
",",
"params",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"if",
"not",
"params",
":",
"params",
"=",
"{",
"}",
"# set default headers",
"if",
"not",
"header... | 1b3fb263ef1d006e181b838ea017ac2abbd68a30 |
train | user_role | Sphinx role for linking to a user profile. Defaults to linking to
Github profiles, but the profile URIS can be configured via the
``issues_user_uri`` config value.
Examples: ::
:user:`sloria`
Anchor text also works: ::
:user:`Steven Loria <sloria>` | sphinx_issues.py | def user_role(name, rawtext, text, lineno, inliner, options=None, content=None):
"""Sphinx role for linking to a user profile. Defaults to linking to
Github profiles, but the profile URIS can be configured via the
``issues_user_uri`` config value.
Examples: ::
:user:`sloria`
Anchor text a... | def user_role(name, rawtext, text, lineno, inliner, options=None, content=None):
"""Sphinx role for linking to a user profile. Defaults to linking to
Github profiles, but the profile URIS can be configured via the
``issues_user_uri`` config value.
Examples: ::
:user:`sloria`
Anchor text a... | [
"Sphinx",
"role",
"for",
"linking",
"to",
"a",
"user",
"profile",
".",
"Defaults",
"to",
"linking",
"to",
"Github",
"profiles",
"but",
"the",
"profile",
"URIS",
"can",
"be",
"configured",
"via",
"the",
"issues_user_uri",
"config",
"value",
"."
] | sloria/sphinx-issues | python | https://github.com/sloria/sphinx-issues/blob/0a9597472645dc728c2aef12e0653aabfdb68ab2/sphinx_issues.py#L13-L43 | [
"def",
"user_role",
"(",
"name",
",",
"rawtext",
",",
"text",
",",
"lineno",
",",
"inliner",
",",
"options",
"=",
"None",
",",
"content",
"=",
"None",
")",
":",
"options",
"=",
"options",
"or",
"{",
"}",
"content",
"=",
"content",
"or",
"[",
"]",
"... | 0a9597472645dc728c2aef12e0653aabfdb68ab2 |
train | cve_role | Sphinx role for linking to a CVE on https://cve.mitre.org.
Examples: ::
:cve:`CVE-2018-17175` | sphinx_issues.py | def cve_role(name, rawtext, text, lineno, inliner, options=None, content=None):
"""Sphinx role for linking to a CVE on https://cve.mitre.org.
Examples: ::
:cve:`CVE-2018-17175`
"""
options = options or {}
content = content or []
has_explicit_title, title, target = split_explicit_title... | def cve_role(name, rawtext, text, lineno, inliner, options=None, content=None):
"""Sphinx role for linking to a CVE on https://cve.mitre.org.
Examples: ::
:cve:`CVE-2018-17175`
"""
options = options or {}
content = content or []
has_explicit_title, title, target = split_explicit_title... | [
"Sphinx",
"role",
"for",
"linking",
"to",
"a",
"CVE",
"on",
"https",
":",
"//",
"cve",
".",
"mitre",
".",
"org",
"."
] | sloria/sphinx-issues | python | https://github.com/sloria/sphinx-issues/blob/0a9597472645dc728c2aef12e0653aabfdb68ab2/sphinx_issues.py#L46-L63 | [
"def",
"cve_role",
"(",
"name",
",",
"rawtext",
",",
"text",
",",
"lineno",
",",
"inliner",
",",
"options",
"=",
"None",
",",
"content",
"=",
"None",
")",
":",
"options",
"=",
"options",
"or",
"{",
"}",
"content",
"=",
"content",
"or",
"[",
"]",
"h... | 0a9597472645dc728c2aef12e0653aabfdb68ab2 |
train | TsvWriter.list_line | Write the given iterable of values (line) to the file as items on the
same line. Any argument that stringifies to a string legal as a TSV data
item can be written.
Does not copy the line or build a big string in memory. | tsv.py | def list_line(self, line):
"""
Write the given iterable of values (line) to the file as items on the
same line. Any argument that stringifies to a string legal as a TSV data
item can be written.
Does not copy the line or build a big string in memory.
"""
... | def list_line(self, line):
"""
Write the given iterable of values (line) to the file as items on the
same line. Any argument that stringifies to a string legal as a TSV data
item can be written.
Does not copy the line or build a big string in memory.
"""
... | [
"Write",
"the",
"given",
"iterable",
"of",
"values",
"(",
"line",
")",
"to",
"the",
"file",
"as",
"items",
"on",
"the",
"same",
"line",
".",
"Any",
"argument",
"that",
"stringifies",
"to",
"a",
"string",
"legal",
"as",
"a",
"TSV",
"data",
"item",
"can"... | adamnovak/tsv | python | https://github.com/adamnovak/tsv/blob/379189e9da4c1b65d0587bb32f3b51e6a7c936c8/tsv.py#L42-L60 | [
"def",
"list_line",
"(",
"self",
",",
"line",
")",
":",
"if",
"len",
"(",
"line",
")",
"==",
"0",
":",
"return",
"self",
".",
"stream",
".",
"write",
"(",
"str",
"(",
"line",
"[",
"0",
"]",
")",
")",
"for",
"item",
"in",
"line",
"[",
"1",
":"... | 379189e9da4c1b65d0587bb32f3b51e6a7c936c8 |
train | prepare | Parse metadata to obtain list of mustache templates,
then load those templates. | pandoc_mustache/pandoc_mustache.py | def prepare(doc):
""" Parse metadata to obtain list of mustache templates,
then load those templates.
"""
doc.mustache_files = doc.get_metadata('mustache')
if isinstance(doc.mustache_files, basestring): # process single YAML value stored as string
if not doc.mustache_files:
... | def prepare(doc):
""" Parse metadata to obtain list of mustache templates,
then load those templates.
"""
doc.mustache_files = doc.get_metadata('mustache')
if isinstance(doc.mustache_files, basestring): # process single YAML value stored as string
if not doc.mustache_files:
... | [
"Parse",
"metadata",
"to",
"obtain",
"list",
"of",
"mustache",
"templates",
"then",
"load",
"those",
"templates",
"."
] | michaelstepner/pandoc-mustache | python | https://github.com/michaelstepner/pandoc-mustache/blob/52d71190d134964596e7f8e109564452e916b3fc/pandoc_mustache/pandoc_mustache.py#L8-L26 | [
"def",
"prepare",
"(",
"doc",
")",
":",
"doc",
".",
"mustache_files",
"=",
"doc",
".",
"get_metadata",
"(",
"'mustache'",
")",
"if",
"isinstance",
"(",
"doc",
".",
"mustache_files",
",",
"basestring",
")",
":",
"# process single YAML value stored as string",
"if... | 52d71190d134964596e7f8e109564452e916b3fc |
train | action | Apply combined mustache template to all strings in document. | pandoc_mustache/pandoc_mustache.py | def action(elem, doc):
""" Apply combined mustache template to all strings in document.
"""
if type(elem) == Str and doc.mhash is not None:
elem.text = doc.mrenderer.render(elem.text, doc.mhash)
return elem | def action(elem, doc):
""" Apply combined mustache template to all strings in document.
"""
if type(elem) == Str and doc.mhash is not None:
elem.text = doc.mrenderer.render(elem.text, doc.mhash)
return elem | [
"Apply",
"combined",
"mustache",
"template",
"to",
"all",
"strings",
"in",
"document",
"."
] | michaelstepner/pandoc-mustache | python | https://github.com/michaelstepner/pandoc-mustache/blob/52d71190d134964596e7f8e109564452e916b3fc/pandoc_mustache/pandoc_mustache.py#L28-L33 | [
"def",
"action",
"(",
"elem",
",",
"doc",
")",
":",
"if",
"type",
"(",
"elem",
")",
"==",
"Str",
"and",
"doc",
".",
"mhash",
"is",
"not",
"None",
":",
"elem",
".",
"text",
"=",
"doc",
".",
"mrenderer",
".",
"render",
"(",
"elem",
".",
"text",
"... | 52d71190d134964596e7f8e109564452e916b3fc |
train | JSONPRenderer.get_callback | Determine the name of the callback to wrap around the json output. | rest_framework_jsonp/renderers.py | def get_callback(self, renderer_context):
"""
Determine the name of the callback to wrap around the json output.
"""
request = renderer_context.get('request', None)
params = request and get_query_params(request) or {}
return params.get(self.callback_parameter, self.defaul... | def get_callback(self, renderer_context):
"""
Determine the name of the callback to wrap around the json output.
"""
request = renderer_context.get('request', None)
params = request and get_query_params(request) or {}
return params.get(self.callback_parameter, self.defaul... | [
"Determine",
"the",
"name",
"of",
"the",
"callback",
"to",
"wrap",
"around",
"the",
"json",
"output",
"."
] | jpadilla/django-rest-framework-jsonp | python | https://github.com/jpadilla/django-rest-framework-jsonp/blob/64e91d451206a815b98d4b4a4e27e705104ad06e/rest_framework_jsonp/renderers.py#L23-L29 | [
"def",
"get_callback",
"(",
"self",
",",
"renderer_context",
")",
":",
"request",
"=",
"renderer_context",
".",
"get",
"(",
"'request'",
",",
"None",
")",
"params",
"=",
"request",
"and",
"get_query_params",
"(",
"request",
")",
"or",
"{",
"}",
"return",
"... | 64e91d451206a815b98d4b4a4e27e705104ad06e |
train | JSONPRenderer.render | Renders into jsonp, wrapping the json output in a callback function.
Clients may set the callback function name using a query parameter
on the URL, for example: ?callback=exampleCallbackName | rest_framework_jsonp/renderers.py | def render(self, data, accepted_media_type=None, renderer_context=None):
"""
Renders into jsonp, wrapping the json output in a callback function.
Clients may set the callback function name using a query parameter
on the URL, for example: ?callback=exampleCallbackName
"""
... | def render(self, data, accepted_media_type=None, renderer_context=None):
"""
Renders into jsonp, wrapping the json output in a callback function.
Clients may set the callback function name using a query parameter
on the URL, for example: ?callback=exampleCallbackName
"""
... | [
"Renders",
"into",
"jsonp",
"wrapping",
"the",
"json",
"output",
"in",
"a",
"callback",
"function",
"."
] | jpadilla/django-rest-framework-jsonp | python | https://github.com/jpadilla/django-rest-framework-jsonp/blob/64e91d451206a815b98d4b4a4e27e705104ad06e/rest_framework_jsonp/renderers.py#L31-L42 | [
"def",
"render",
"(",
"self",
",",
"data",
",",
"accepted_media_type",
"=",
"None",
",",
"renderer_context",
"=",
"None",
")",
":",
"renderer_context",
"=",
"renderer_context",
"or",
"{",
"}",
"callback",
"=",
"self",
".",
"get_callback",
"(",
"renderer_contex... | 64e91d451206a815b98d4b4a4e27e705104ad06e |
train | TimeSeries.get | Analyses the measurement with the given parameters
:param measurementId:
:return: | backend/src/analyser/resources/timeseries.py | def get(self, measurementId):
"""
Analyses the measurement with the given parameters
:param measurementId:
:return:
"""
logger.info('Loading raw data for ' + measurementId)
measurement = self._measurementController.getMeasurement(measurementId, MeasurementStatus.C... | def get(self, measurementId):
"""
Analyses the measurement with the given parameters
:param measurementId:
:return:
"""
logger.info('Loading raw data for ' + measurementId)
measurement = self._measurementController.getMeasurement(measurementId, MeasurementStatus.C... | [
"Analyses",
"the",
"measurement",
"with",
"the",
"given",
"parameters",
":",
"param",
"measurementId",
":",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/timeseries.py#L13-L47 | [
"def",
"get",
"(",
"self",
",",
"measurementId",
")",
":",
"logger",
".",
"info",
"(",
"'Loading raw data for '",
"+",
"measurementId",
")",
"measurement",
"=",
"self",
".",
"_measurementController",
".",
"getMeasurement",
"(",
"measurementId",
",",
"MeasurementSt... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | to_jd | Return Julian day count of given ISO year, week, and day | convertdate/iso.py | def to_jd(year, week, day):
'''Return Julian day count of given ISO year, week, and day'''
return day + n_weeks(SUN, gregorian.to_jd(year - 1, 12, 28), week) | def to_jd(year, week, day):
'''Return Julian day count of given ISO year, week, and day'''
return day + n_weeks(SUN, gregorian.to_jd(year - 1, 12, 28), week) | [
"Return",
"Julian",
"day",
"count",
"of",
"given",
"ISO",
"year",
"week",
"and",
"day"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/iso.py#L24-L26 | [
"def",
"to_jd",
"(",
"year",
",",
"week",
",",
"day",
")",
":",
"return",
"day",
"+",
"n_weeks",
"(",
"SUN",
",",
"gregorian",
".",
"to_jd",
"(",
"year",
"-",
"1",
",",
"12",
",",
"28",
")",
",",
"week",
")"
] | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | from_jd | Return tuple of ISO (year, week, day) for Julian day | convertdate/iso.py | def from_jd(jd):
'''Return tuple of ISO (year, week, day) for Julian day'''
year = gregorian.from_jd(jd)[0]
day = jwday(jd) + 1
dayofyear = ordinal.from_jd(jd)[1]
week = trunc((dayofyear - day + 10) / 7)
# Reset year
if week < 1:
week = weeks_per_year(year - 1)
year = year ... | def from_jd(jd):
'''Return tuple of ISO (year, week, day) for Julian day'''
year = gregorian.from_jd(jd)[0]
day = jwday(jd) + 1
dayofyear = ordinal.from_jd(jd)[1]
week = trunc((dayofyear - day + 10) / 7)
# Reset year
if week < 1:
week = weeks_per_year(year - 1)
year = year ... | [
"Return",
"tuple",
"of",
"ISO",
"(",
"year",
"week",
"day",
")",
"for",
"Julian",
"day"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/iso.py#L29-L47 | [
"def",
"from_jd",
"(",
"jd",
")",
":",
"year",
"=",
"gregorian",
".",
"from_jd",
"(",
"jd",
")",
"[",
"0",
"]",
"day",
"=",
"jwday",
"(",
"jd",
")",
"+",
"1",
"dayofyear",
"=",
"ordinal",
".",
"from_jd",
"(",
"jd",
")",
"[",
"1",
"]",
"week",
... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | weeks_per_year | Number of ISO weeks in a year | convertdate/iso.py | def weeks_per_year(year):
'''Number of ISO weeks in a year'''
# 53 weeks: any year starting on Thursday and any leap year starting on Wednesday
jan1 = jwday(gregorian.to_jd(year, 1, 1))
if jan1 == THU or (jan1 == WED and isleap(year)):
return 53
else:
return 52 | def weeks_per_year(year):
'''Number of ISO weeks in a year'''
# 53 weeks: any year starting on Thursday and any leap year starting on Wednesday
jan1 = jwday(gregorian.to_jd(year, 1, 1))
if jan1 == THU or (jan1 == WED and isleap(year)):
return 53
else:
return 52 | [
"Number",
"of",
"ISO",
"weeks",
"in",
"a",
"year"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/iso.py#L50-L58 | [
"def",
"weeks_per_year",
"(",
"year",
")",
":",
"# 53 weeks: any year starting on Thursday and any leap year starting on Wednesday",
"jan1",
"=",
"jwday",
"(",
"gregorian",
".",
"to_jd",
"(",
"year",
",",
"1",
",",
"1",
")",
")",
"if",
"jan1",
"==",
"THU",
"or",
... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | stsci | For STScI GEIS files, need to do extra steps. | lib/stsci/tools/readgeis.py | def stsci(hdulist):
"""For STScI GEIS files, need to do extra steps."""
instrument = hdulist[0].header.get('INSTRUME', '')
# Update extension header keywords
if instrument in ("WFPC2", "FOC"):
rootname = hdulist[0].header.get('ROOTNAME', '')
filetype = hdulist[0].header.get('FILETYPE',... | def stsci(hdulist):
"""For STScI GEIS files, need to do extra steps."""
instrument = hdulist[0].header.get('INSTRUME', '')
# Update extension header keywords
if instrument in ("WFPC2", "FOC"):
rootname = hdulist[0].header.get('ROOTNAME', '')
filetype = hdulist[0].header.get('FILETYPE',... | [
"For",
"STScI",
"GEIS",
"files",
"need",
"to",
"do",
"extra",
"steps",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/readgeis.py#L79-L97 | [
"def",
"stsci",
"(",
"hdulist",
")",
":",
"instrument",
"=",
"hdulist",
"[",
"0",
"]",
".",
"header",
".",
"get",
"(",
"'INSTRUME'",
",",
"''",
")",
"# Update extension header keywords",
"if",
"instrument",
"in",
"(",
"\"WFPC2\"",
",",
"\"FOC\"",
")",
":",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | stsci2 | For STScI GEIS files, need to do extra steps. | lib/stsci/tools/readgeis.py | def stsci2(hdulist, filename):
"""For STScI GEIS files, need to do extra steps."""
# Write output file name to the primary header
instrument = hdulist[0].header.get('INSTRUME', '')
if instrument in ("WFPC2", "FOC"):
hdulist[0].header['FILENAME'] = filename | def stsci2(hdulist, filename):
"""For STScI GEIS files, need to do extra steps."""
# Write output file name to the primary header
instrument = hdulist[0].header.get('INSTRUME', '')
if instrument in ("WFPC2", "FOC"):
hdulist[0].header['FILENAME'] = filename | [
"For",
"STScI",
"GEIS",
"files",
"need",
"to",
"do",
"extra",
"steps",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/readgeis.py#L100-L106 | [
"def",
"stsci2",
"(",
"hdulist",
",",
"filename",
")",
":",
"# Write output file name to the primary header",
"instrument",
"=",
"hdulist",
"[",
"0",
"]",
".",
"header",
".",
"get",
"(",
"'INSTRUME'",
",",
"''",
")",
"if",
"instrument",
"in",
"(",
"\"WFPC2\"",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | readgeis | Input GEIS files "input" will be read and a HDUList object will
be returned.
The user can use the writeto method to write the HDUList object to
a FITS file. | lib/stsci/tools/readgeis.py | def readgeis(input):
"""Input GEIS files "input" will be read and a HDUList object will
be returned.
The user can use the writeto method to write the HDUList object to
a FITS file.
"""
global dat
cardLen = fits.Card.length
# input file(s) must be of the form *.??h and *.??d
... | def readgeis(input):
"""Input GEIS files "input" will be read and a HDUList object will
be returned.
The user can use the writeto method to write the HDUList object to
a FITS file.
"""
global dat
cardLen = fits.Card.length
# input file(s) must be of the form *.??h and *.??d
... | [
"Input",
"GEIS",
"files",
"input",
"will",
"be",
"read",
"and",
"a",
"HDUList",
"object",
"will",
"be",
"returned",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/readgeis.py#L109-L320 | [
"def",
"readgeis",
"(",
"input",
")",
":",
"global",
"dat",
"cardLen",
"=",
"fits",
".",
"Card",
".",
"length",
"# input file(s) must be of the form *.??h and *.??d",
"if",
"input",
"[",
"-",
"1",
"]",
"!=",
"'h'",
"or",
"input",
"[",
"-",
"4",
"]",
"!=",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | parse_path | Parse two input arguments and return two lists of file names | lib/stsci/tools/readgeis.py | def parse_path(f1, f2):
"""Parse two input arguments and return two lists of file names"""
import glob
# if second argument is missing or is a wild card, point it
# to the current directory
f2 = f2.strip()
if f2 == '' or f2 == '*':
f2 = './'
# if the first argument is a directory... | def parse_path(f1, f2):
"""Parse two input arguments and return two lists of file names"""
import glob
# if second argument is missing or is a wild card, point it
# to the current directory
f2 = f2.strip()
if f2 == '' or f2 == '*':
f2 = './'
# if the first argument is a directory... | [
"Parse",
"two",
"input",
"arguments",
"and",
"return",
"two",
"lists",
"of",
"file",
"names"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/readgeis.py#L322-L363 | [
"def",
"parse_path",
"(",
"f1",
",",
"f2",
")",
":",
"import",
"glob",
"# if second argument is missing or is a wild card, point it",
"# to the current directory",
"f2",
"=",
"f2",
".",
"strip",
"(",
")",
"if",
"f2",
"==",
"''",
"or",
"f2",
"==",
"'*'",
":",
"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | parseinput | Recursively parse user input based upon the irafglob
program and construct a list of files that need to be processed.
This program addresses the following deficiencies of the irafglob program::
parseinput can extract filenames from association tables
Returns
-------
This program will return... | lib/stsci/tools/parseinput.py | def parseinput(inputlist,outputname=None, atfile=None):
"""
Recursively parse user input based upon the irafglob
program and construct a list of files that need to be processed.
This program addresses the following deficiencies of the irafglob program::
parseinput can extract filenames from asso... | def parseinput(inputlist,outputname=None, atfile=None):
"""
Recursively parse user input based upon the irafglob
program and construct a list of files that need to be processed.
This program addresses the following deficiencies of the irafglob program::
parseinput can extract filenames from asso... | [
"Recursively",
"parse",
"user",
"input",
"based",
"upon",
"the",
"irafglob",
"program",
"and",
"construct",
"a",
"list",
"of",
"files",
"that",
"need",
"to",
"be",
"processed",
".",
"This",
"program",
"addresses",
"the",
"following",
"deficiencies",
"of",
"the... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/parseinput.py#L31-L134 | [
"def",
"parseinput",
"(",
"inputlist",
",",
"outputname",
"=",
"None",
",",
"atfile",
"=",
"None",
")",
":",
"# Initalize some variables",
"files",
"=",
"[",
"]",
"# list used to store names of input files",
"newoutputname",
"=",
"outputname",
"# Outputname returned to ... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | checkASN | Determine if the filename provided to the function belongs to
an association.
Parameters
----------
filename: string
Returns
-------
validASN : boolean value | lib/stsci/tools/parseinput.py | def checkASN(filename):
"""
Determine if the filename provided to the function belongs to
an association.
Parameters
----------
filename: string
Returns
-------
validASN : boolean value
"""
# Extract the file extn type:
extnType = filename[filename.rfind('_')+1:filena... | def checkASN(filename):
"""
Determine if the filename provided to the function belongs to
an association.
Parameters
----------
filename: string
Returns
-------
validASN : boolean value
"""
# Extract the file extn type:
extnType = filename[filename.rfind('_')+1:filena... | [
"Determine",
"if",
"the",
"filename",
"provided",
"to",
"the",
"function",
"belongs",
"to",
"an",
"association",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/parseinput.py#L137-L158 | [
"def",
"checkASN",
"(",
"filename",
")",
":",
"# Extract the file extn type:",
"extnType",
"=",
"filename",
"[",
"filename",
".",
"rfind",
"(",
"'_'",
")",
"+",
"1",
":",
"filename",
".",
"rfind",
"(",
"'.'",
")",
"]",
"# Determine if this extn name is valid for... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | countinputs | Determine the number of inputfiles provided by the user and the
number of those files that are association tables
Parameters
----------
inputlist : string
the user input
Returns
-------
numInputs: int
number of inputs provided by the user
numASNfiles: int
numb... | lib/stsci/tools/parseinput.py | def countinputs(inputlist):
"""
Determine the number of inputfiles provided by the user and the
number of those files that are association tables
Parameters
----------
inputlist : string
the user input
Returns
-------
numInputs: int
number of inputs provided by th... | def countinputs(inputlist):
"""
Determine the number of inputfiles provided by the user and the
number of those files that are association tables
Parameters
----------
inputlist : string
the user input
Returns
-------
numInputs: int
number of inputs provided by th... | [
"Determine",
"the",
"number",
"of",
"inputfiles",
"provided",
"by",
"the",
"user",
"and",
"the",
"number",
"of",
"those",
"files",
"that",
"are",
"association",
"tables"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/parseinput.py#L185-L218 | [
"def",
"countinputs",
"(",
"inputlist",
")",
":",
"# Initialize return values",
"numInputs",
"=",
"0",
"numASNfiles",
"=",
"0",
"# User irafglob to count the number of inputfiles",
"files",
"=",
"irafglob",
"(",
"inputlist",
",",
"atfile",
"=",
"None",
")",
"# Use the... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | summary | show a summary of all projects | timed/client.py | def summary(logfile, time_format):
"show a summary of all projects"
def output(summary):
width = max([len(p[0]) for p in summary]) + 3
print '\n'.join([
"%s%s%s" % (p[0], ' ' * (width - len(p[0])),
colored(minutes_to_txt(p[1]), 'red')) for p in summary])
output(server.summarize(read(logfil... | def summary(logfile, time_format):
"show a summary of all projects"
def output(summary):
width = max([len(p[0]) for p in summary]) + 3
print '\n'.join([
"%s%s%s" % (p[0], ' ' * (width - len(p[0])),
colored(minutes_to_txt(p[1]), 'red')) for p in summary])
output(server.summarize(read(logfil... | [
"show",
"a",
"summary",
"of",
"all",
"projects"
] | adeel/timed | python | https://github.com/adeel/timed/blob/9f85e004de491cd4863d31b09991a1e2591b1b66/timed/client.py#L21-L30 | [
"def",
"summary",
"(",
"logfile",
",",
"time_format",
")",
":",
"def",
"output",
"(",
"summary",
")",
":",
"width",
"=",
"max",
"(",
"[",
"len",
"(",
"p",
"[",
"0",
"]",
")",
"for",
"p",
"in",
"summary",
"]",
")",
"+",
"3",
"print",
"'\\n'",
".... | 9f85e004de491cd4863d31b09991a1e2591b1b66 |
train | status | show current status | timed/client.py | def status(logfile, time_format):
"show current status"
try:
r = read(logfile, time_format)[-1]
if r[1][1]:
return summary(logfile, time_format)
else:
print "working on %s" % colored(r[0], attrs=['bold'])
print " since %s" % colored(
server.date_to_txt(r[1][0], time_format... | def status(logfile, time_format):
"show current status"
try:
r = read(logfile, time_format)[-1]
if r[1][1]:
return summary(logfile, time_format)
else:
print "working on %s" % colored(r[0], attrs=['bold'])
print " since %s" % colored(
server.date_to_txt(r[1][0], time_format... | [
"show",
"current",
"status"
] | adeel/timed | python | https://github.com/adeel/timed/blob/9f85e004de491cd4863d31b09991a1e2591b1b66/timed/client.py#L34-L49 | [
"def",
"status",
"(",
"logfile",
",",
"time_format",
")",
":",
"try",
":",
"r",
"=",
"read",
"(",
"logfile",
",",
"time_format",
")",
"[",
"-",
"1",
"]",
"if",
"r",
"[",
"1",
"]",
"[",
"1",
"]",
":",
"return",
"summary",
"(",
"logfile",
",",
"t... | 9f85e004de491cd4863d31b09991a1e2591b1b66 |
train | start | start tracking for <project> | timed/client.py | def start(project, logfile, time_format):
"start tracking for <project>"
records = read(logfile, time_format)
if records and not records[-1][1][1]:
print "error: there is a project already active"
return
write(server.start(project, records), logfile, time_format)
print "starting work on %s" % color... | def start(project, logfile, time_format):
"start tracking for <project>"
records = read(logfile, time_format)
if records and not records[-1][1][1]:
print "error: there is a project already active"
return
write(server.start(project, records), logfile, time_format)
print "starting work on %s" % color... | [
"start",
"tracking",
"for",
"<project",
">"
] | adeel/timed | python | https://github.com/adeel/timed/blob/9f85e004de491cd4863d31b09991a1e2591b1b66/timed/client.py#L52-L63 | [
"def",
"start",
"(",
"project",
",",
"logfile",
",",
"time_format",
")",
":",
"records",
"=",
"read",
"(",
"logfile",
",",
"time_format",
")",
"if",
"records",
"and",
"not",
"records",
"[",
"-",
"1",
"]",
"[",
"1",
"]",
"[",
"1",
"]",
":",
"print",... | 9f85e004de491cd4863d31b09991a1e2591b1b66 |
train | stop | stop tracking for the active project | timed/client.py | def stop(logfile, time_format):
"stop tracking for the active project"
def save_and_output(records):
records = server.stop(records)
write(records, logfile, time_format)
def output(r):
print "worked on %s" % colored(r[0], attrs=['bold'])
print " from %s" % colored(
server.date_t... | def stop(logfile, time_format):
"stop tracking for the active project"
def save_and_output(records):
records = server.stop(records)
write(records, logfile, time_format)
def output(r):
print "worked on %s" % colored(r[0], attrs=['bold'])
print " from %s" % colored(
server.date_t... | [
"stop",
"tracking",
"for",
"the",
"active",
"project"
] | adeel/timed | python | https://github.com/adeel/timed/blob/9f85e004de491cd4863d31b09991a1e2591b1b66/timed/client.py#L66-L84 | [
"def",
"stop",
"(",
"logfile",
",",
"time_format",
")",
":",
"def",
"save_and_output",
"(",
"records",
")",
":",
"records",
"=",
"server",
".",
"stop",
"(",
"records",
")",
"write",
"(",
"records",
",",
"logfile",
",",
"time_format",
")",
"def",
"output"... | 9f85e004de491cd4863d31b09991a1e2591b1b66 |
train | parse | parses a stream with text formatted as a Timed logfile and shows a summary | timed/client.py | def parse(logfile, time_format):
"parses a stream with text formatted as a Timed logfile and shows a summary"
records = [server.record_from_txt(line, only_elapsed=True,
time_format=time_format) for line in sys.stdin.readlines()]
# TODO: make this code better.
def output(summary):
width = max([len(p[0]... | def parse(logfile, time_format):
"parses a stream with text formatted as a Timed logfile and shows a summary"
records = [server.record_from_txt(line, only_elapsed=True,
time_format=time_format) for line in sys.stdin.readlines()]
# TODO: make this code better.
def output(summary):
width = max([len(p[0]... | [
"parses",
"a",
"stream",
"with",
"text",
"formatted",
"as",
"a",
"Timed",
"logfile",
"and",
"shows",
"a",
"summary"
] | adeel/timed | python | https://github.com/adeel/timed/blob/9f85e004de491cd4863d31b09991a1e2591b1b66/timed/client.py#L87-L100 | [
"def",
"parse",
"(",
"logfile",
",",
"time_format",
")",
":",
"records",
"=",
"[",
"server",
".",
"record_from_txt",
"(",
"line",
",",
"only_elapsed",
"=",
"True",
",",
"time_format",
"=",
"time_format",
")",
"for",
"line",
"in",
"sys",
".",
"stdin",
"."... | 9f85e004de491cd4863d31b09991a1e2591b1b66 |
train | projects | prints a newline-separated list of all projects | timed/client.py | def projects(logfile, time_format):
"prints a newline-separated list of all projects"
print '\n'.join(server.list_projects(read(logfile, time_format))) | def projects(logfile, time_format):
"prints a newline-separated list of all projects"
print '\n'.join(server.list_projects(read(logfile, time_format))) | [
"prints",
"a",
"newline",
"-",
"separated",
"list",
"of",
"all",
"projects"
] | adeel/timed | python | https://github.com/adeel/timed/blob/9f85e004de491cd4863d31b09991a1e2591b1b66/timed/client.py#L103-L106 | [
"def",
"projects",
"(",
"logfile",
",",
"time_format",
")",
":",
"print",
"'\\n'",
".",
"join",
"(",
"server",
".",
"list_projects",
"(",
"read",
"(",
"logfile",
",",
"time_format",
")",
")",
")"
] | 9f85e004de491cd4863d31b09991a1e2591b1b66 |
train | getLTime | Returns a formatted string with the current local time. | lib/stsci/tools/fileutil.py | def getLTime():
"""Returns a formatted string with the current local time."""
_ltime = _time.localtime(_time.time())
tlm_str = _time.strftime('%H:%M:%S (%d/%m/%Y)', _ltime)
return tlm_str | def getLTime():
"""Returns a formatted string with the current local time."""
_ltime = _time.localtime(_time.time())
tlm_str = _time.strftime('%H:%M:%S (%d/%m/%Y)', _ltime)
return tlm_str | [
"Returns",
"a",
"formatted",
"string",
"with",
"the",
"current",
"local",
"time",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L154-L159 | [
"def",
"getLTime",
"(",
")",
":",
"_ltime",
"=",
"_time",
".",
"localtime",
"(",
"_time",
".",
"time",
"(",
")",
")",
"tlm_str",
"=",
"_time",
".",
"strftime",
"(",
"'%H:%M:%S (%d/%m/%Y)'",
",",
"_ltime",
")",
"return",
"tlm_str"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | getDate | Returns a formatted string with the current date. | lib/stsci/tools/fileutil.py | def getDate():
"""Returns a formatted string with the current date."""
_ltime = _time.localtime(_time.time())
date_str = _time.strftime('%Y-%m-%dT%H:%M:%S',_ltime)
return date_str | def getDate():
"""Returns a formatted string with the current date."""
_ltime = _time.localtime(_time.time())
date_str = _time.strftime('%Y-%m-%dT%H:%M:%S',_ltime)
return date_str | [
"Returns",
"a",
"formatted",
"string",
"with",
"the",
"current",
"date",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L162-L168 | [
"def",
"getDate",
"(",
")",
":",
"_ltime",
"=",
"_time",
".",
"localtime",
"(",
"_time",
".",
"time",
"(",
")",
")",
"date_str",
"=",
"_time",
".",
"strftime",
"(",
"'%Y-%m-%dT%H:%M:%S'",
",",
"_ltime",
")",
"return",
"date_str"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | convertDate | Convert DATE string into a decimal year. | lib/stsci/tools/fileutil.py | def convertDate(date):
"""Convert DATE string into a decimal year."""
d, t = date.split('T')
return decimal_date(d, timeobs=t) | def convertDate(date):
"""Convert DATE string into a decimal year."""
d, t = date.split('T')
return decimal_date(d, timeobs=t) | [
"Convert",
"DATE",
"string",
"into",
"a",
"decimal",
"year",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L171-L175 | [
"def",
"convertDate",
"(",
"date",
")",
":",
"d",
",",
"t",
"=",
"date",
".",
"split",
"(",
"'T'",
")",
"return",
"decimal_date",
"(",
"d",
",",
"timeobs",
"=",
"t",
")"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | decimal_date | Convert DATE-OBS (and optional TIME-OBS) into a decimal year. | lib/stsci/tools/fileutil.py | def decimal_date(dateobs, timeobs=None):
"""Convert DATE-OBS (and optional TIME-OBS) into a decimal year."""
year, month, day = dateobs.split('-')
if timeobs is not None:
hr, min, sec = timeobs.split(':')
else:
hr, min, sec = 0, 0, 0
rdate = datetime.datetime(int(year), int(month),... | def decimal_date(dateobs, timeobs=None):
"""Convert DATE-OBS (and optional TIME-OBS) into a decimal year."""
year, month, day = dateobs.split('-')
if timeobs is not None:
hr, min, sec = timeobs.split(':')
else:
hr, min, sec = 0, 0, 0
rdate = datetime.datetime(int(year), int(month),... | [
"Convert",
"DATE",
"-",
"OBS",
"(",
"and",
"optional",
"TIME",
"-",
"OBS",
")",
"into",
"a",
"decimal",
"year",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L178-L193 | [
"def",
"decimal_date",
"(",
"dateobs",
",",
"timeobs",
"=",
"None",
")",
":",
"year",
",",
"month",
",",
"day",
"=",
"dateobs",
".",
"split",
"(",
"'-'",
")",
"if",
"timeobs",
"is",
"not",
"None",
":",
"hr",
",",
"min",
",",
"sec",
"=",
"timeobs",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | interpretDQvalue | Converts an integer 'input' into its component bit values as a list of
power of 2 integers.
For example, the bit value 1027 would return [1, 2, 1024] | lib/stsci/tools/fileutil.py | def interpretDQvalue(input):
"""
Converts an integer 'input' into its component bit values as a list of
power of 2 integers.
For example, the bit value 1027 would return [1, 2, 1024]
"""
nbits = 16
# We will only support integer values up to 2**128
for iexp in [16, 32, 64, 128]:
... | def interpretDQvalue(input):
"""
Converts an integer 'input' into its component bit values as a list of
power of 2 integers.
For example, the bit value 1027 would return [1, 2, 1024]
"""
nbits = 16
# We will only support integer values up to 2**128
for iexp in [16, 32, 64, 128]:
... | [
"Converts",
"an",
"integer",
"input",
"into",
"its",
"component",
"bit",
"values",
"as",
"a",
"list",
"of",
"power",
"of",
"2",
"integers",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L196-L229 | [
"def",
"interpretDQvalue",
"(",
"input",
")",
":",
"nbits",
"=",
"16",
"# We will only support integer values up to 2**128",
"for",
"iexp",
"in",
"[",
"16",
",",
"32",
",",
"64",
",",
"128",
"]",
":",
"# Find out whether the input value is less than 2**iexp",
"if",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | isFits | Returns
--------
isFits: tuple
An ``(isfits, fitstype)`` tuple. The values of ``isfits`` and
``fitstype`` are specified as:
- ``isfits``: True|False
- ``fitstype``: if True, one of 'waiver', 'mef', 'simple'; if False, None
Notes
-----
Input images which do not ha... | lib/stsci/tools/fileutil.py | def isFits(input):
"""
Returns
--------
isFits: tuple
An ``(isfits, fitstype)`` tuple. The values of ``isfits`` and
``fitstype`` are specified as:
- ``isfits``: True|False
- ``fitstype``: if True, one of 'waiver', 'mef', 'simple'; if False, None
Notes
-----
... | def isFits(input):
"""
Returns
--------
isFits: tuple
An ``(isfits, fitstype)`` tuple. The values of ``isfits`` and
``fitstype`` are specified as:
- ``isfits``: True|False
- ``fitstype``: if True, one of 'waiver', 'mef', 'simple'; if False, None
Notes
-----
... | [
"Returns",
"--------",
"isFits",
":",
"tuple",
"An",
"(",
"isfits",
"fitstype",
")",
"tuple",
".",
"The",
"values",
"of",
"isfits",
"and",
"fitstype",
"are",
"specified",
"as",
":"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L232-L289 | [
"def",
"isFits",
"(",
"input",
")",
":",
"isfits",
"=",
"False",
"fitstype",
"=",
"None",
"names",
"=",
"[",
"'fits'",
",",
"'fit'",
",",
"'FITS'",
",",
"'FIT'",
"]",
"#determine if input is a fits file based on extension",
"# Only check type of FITS file if filename ... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | verifyWriteMode | Checks whether files are writable. It is up to the calling routine to raise
an Exception, if desired.
This function returns True, if all files are writable and False, if any are
not writable. In addition, for all files found to not be writable, it will
print out the list of names of affected files. | lib/stsci/tools/fileutil.py | def verifyWriteMode(files):
"""
Checks whether files are writable. It is up to the calling routine to raise
an Exception, if desired.
This function returns True, if all files are writable and False, if any are
not writable. In addition, for all files found to not be writable, it will
print out... | def verifyWriteMode(files):
"""
Checks whether files are writable. It is up to the calling routine to raise
an Exception, if desired.
This function returns True, if all files are writable and False, if any are
not writable. In addition, for all files found to not be writable, it will
print out... | [
"Checks",
"whether",
"files",
"are",
"writable",
".",
"It",
"is",
"up",
"to",
"the",
"calling",
"routine",
"to",
"raise",
"an",
"Exception",
"if",
"desired",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L308-L343 | [
"def",
"verifyWriteMode",
"(",
"files",
")",
":",
"# Start by insuring that input is a list of filenames,",
"# if only a single filename has been given as input,",
"# convert it to a list with len == 1.",
"if",
"not",
"isinstance",
"(",
"files",
",",
"list",
")",
":",
"files",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | getFilterNames | Returns a comma-separated string of filter names extracted from the input
header (PyFITS header object). This function has been hard-coded to
support the following instruments:
ACS, WFPC2, STIS
This function relies on the 'INSTRUME' keyword to define what instrument
has been used to generate ... | lib/stsci/tools/fileutil.py | def getFilterNames(header, filternames=None):
"""
Returns a comma-separated string of filter names extracted from the input
header (PyFITS header object). This function has been hard-coded to
support the following instruments:
ACS, WFPC2, STIS
This function relies on the 'INSTRUME' keywor... | def getFilterNames(header, filternames=None):
"""
Returns a comma-separated string of filter names extracted from the input
header (PyFITS header object). This function has been hard-coded to
support the following instruments:
ACS, WFPC2, STIS
This function relies on the 'INSTRUME' keywor... | [
"Returns",
"a",
"comma",
"-",
"separated",
"string",
"of",
"filter",
"names",
"extracted",
"from",
"the",
"input",
"header",
"(",
"PyFITS",
"header",
"object",
")",
".",
"This",
"function",
"has",
"been",
"hard",
"-",
"coded",
"to",
"support",
"the",
"foll... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L346-L397 | [
"def",
"getFilterNames",
"(",
"header",
",",
"filternames",
"=",
"None",
")",
":",
"# Define the keyword names for each instrument",
"_keydict",
"=",
"{",
"'ACS'",
":",
"[",
"'FILTER1'",
",",
"'FILTER2'",
"]",
",",
"'WFPC2'",
":",
"[",
"'FILTNAM1'",
",",
"'FILTN... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | buildNewRootname | Build rootname for a new file.
Use 'extn' for new filename if given, does NOT append a suffix/extension at
all.
Does NOT check to see if it exists already. Will ALWAYS return a new
filename. | lib/stsci/tools/fileutil.py | def buildNewRootname(filename, extn=None, extlist=None):
"""
Build rootname for a new file.
Use 'extn' for new filename if given, does NOT append a suffix/extension at
all.
Does NOT check to see if it exists already. Will ALWAYS return a new
filename.
"""
# Search known suffixes to r... | def buildNewRootname(filename, extn=None, extlist=None):
"""
Build rootname for a new file.
Use 'extn' for new filename if given, does NOT append a suffix/extension at
all.
Does NOT check to see if it exists already. Will ALWAYS return a new
filename.
"""
# Search known suffixes to r... | [
"Build",
"rootname",
"for",
"a",
"new",
"file",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L400-L436 | [
"def",
"buildNewRootname",
"(",
"filename",
",",
"extn",
"=",
"None",
",",
"extlist",
"=",
"None",
")",
":",
"# Search known suffixes to replace ('_crj.fits',...)",
"_extlist",
"=",
"copy",
".",
"deepcopy",
"(",
"EXTLIST",
")",
"# Also, add a default where '_dth.fits' r... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | buildRootname | Build a new rootname for an existing file and given extension.
Any user supplied extensions to use for searching for file need to be
provided as a list of extensions.
Examples
--------
::
>>> rootname = buildRootname(filename, ext=['_dth.fits']) # doctest: +SKIP | lib/stsci/tools/fileutil.py | def buildRootname(filename, ext=None):
"""
Build a new rootname for an existing file and given extension.
Any user supplied extensions to use for searching for file need to be
provided as a list of extensions.
Examples
--------
::
>>> rootname = buildRootname(filename, ext=['_dth... | def buildRootname(filename, ext=None):
"""
Build a new rootname for an existing file and given extension.
Any user supplied extensions to use for searching for file need to be
provided as a list of extensions.
Examples
--------
::
>>> rootname = buildRootname(filename, ext=['_dth... | [
"Build",
"a",
"new",
"rootname",
"for",
"an",
"existing",
"file",
"and",
"given",
"extension",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L439-L530 | [
"def",
"buildRootname",
"(",
"filename",
",",
"ext",
"=",
"None",
")",
":",
"if",
"filename",
"in",
"[",
"''",
",",
"' '",
",",
"None",
"]",
":",
"return",
"None",
"fpath",
",",
"fname",
"=",
"os",
".",
"path",
".",
"split",
"(",
"filename",
")",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | getKeyword | General, write-safe method for returning a keyword value from the header of
a IRAF recognized image.
Returns the value as a string. | lib/stsci/tools/fileutil.py | def getKeyword(filename, keyword, default=None, handle=None):
"""
General, write-safe method for returning a keyword value from the header of
a IRAF recognized image.
Returns the value as a string.
"""
# Insure that there is at least 1 extension specified...
if filename.find('[') < 0:
... | def getKeyword(filename, keyword, default=None, handle=None):
"""
General, write-safe method for returning a keyword value from the header of
a IRAF recognized image.
Returns the value as a string.
"""
# Insure that there is at least 1 extension specified...
if filename.find('[') < 0:
... | [
"General",
"write",
"-",
"safe",
"method",
"for",
"returning",
"a",
"keyword",
"value",
"from",
"the",
"header",
"of",
"a",
"IRAF",
"recognized",
"image",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L533-L598 | [
"def",
"getKeyword",
"(",
"filename",
",",
"keyword",
",",
"default",
"=",
"None",
",",
"handle",
"=",
"None",
")",
":",
"# Insure that there is at least 1 extension specified...",
"if",
"filename",
".",
"find",
"(",
"'['",
")",
"<",
"0",
":",
"filename",
"+="... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | getHeader | Return a copy of the PRIMARY header, along with any group/extension header
for this filename specification. | lib/stsci/tools/fileutil.py | def getHeader(filename, handle=None):
"""
Return a copy of the PRIMARY header, along with any group/extension header
for this filename specification.
"""
_fname, _extn = parseFilename(filename)
# Allow the user to provide an already opened PyFITS object
# to derive the header from...
#
... | def getHeader(filename, handle=None):
"""
Return a copy of the PRIMARY header, along with any group/extension header
for this filename specification.
"""
_fname, _extn = parseFilename(filename)
# Allow the user to provide an already opened PyFITS object
# to derive the header from...
#
... | [
"Return",
"a",
"copy",
"of",
"the",
"PRIMARY",
"header",
"along",
"with",
"any",
"group",
"/",
"extension",
"header",
"for",
"this",
"filename",
"specification",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L601-L640 | [
"def",
"getHeader",
"(",
"filename",
",",
"handle",
"=",
"None",
")",
":",
"_fname",
",",
"_extn",
"=",
"parseFilename",
"(",
"filename",
")",
"# Allow the user to provide an already opened PyFITS object",
"# to derive the header from...",
"#",
"if",
"not",
"handle",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | updateKeyword | Add/update keyword to header with given value. | lib/stsci/tools/fileutil.py | def updateKeyword(filename, key, value,show=yes):
"""Add/update keyword to header with given value."""
_fname, _extn = parseFilename(filename)
# Open image whether it is FITS or GEIS
_fimg = openImage(_fname, mode='update')
# Address the correct header
_hdr = getExtn(_fimg, _extn).header
... | def updateKeyword(filename, key, value,show=yes):
"""Add/update keyword to header with given value."""
_fname, _extn = parseFilename(filename)
# Open image whether it is FITS or GEIS
_fimg = openImage(_fname, mode='update')
# Address the correct header
_hdr = getExtn(_fimg, _extn).header
... | [
"Add",
"/",
"update",
"keyword",
"to",
"header",
"with",
"given",
"value",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L643-L664 | [
"def",
"updateKeyword",
"(",
"filename",
",",
"key",
",",
"value",
",",
"show",
"=",
"yes",
")",
":",
"_fname",
",",
"_extn",
"=",
"parseFilename",
"(",
"filename",
")",
"# Open image whether it is FITS or GEIS",
"_fimg",
"=",
"openImage",
"(",
"_fname",
",",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | buildFITSName | Build a new FITS filename for a GEIS input image. | lib/stsci/tools/fileutil.py | def buildFITSName(geisname):
"""Build a new FITS filename for a GEIS input image."""
# User wants to make a FITS copy and update it...
_indx = geisname.rfind('.')
_fitsname = geisname[:_indx] + '_' + geisname[_indx + 1:-1] + 'h.fits'
return _fitsname | def buildFITSName(geisname):
"""Build a new FITS filename for a GEIS input image."""
# User wants to make a FITS copy and update it...
_indx = geisname.rfind('.')
_fitsname = geisname[:_indx] + '_' + geisname[_indx + 1:-1] + 'h.fits'
return _fitsname | [
"Build",
"a",
"new",
"FITS",
"filename",
"for",
"a",
"GEIS",
"input",
"image",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L667-L674 | [
"def",
"buildFITSName",
"(",
"geisname",
")",
":",
"# User wants to make a FITS copy and update it...",
"_indx",
"=",
"geisname",
".",
"rfind",
"(",
"'.'",
")",
"_fitsname",
"=",
"geisname",
"[",
":",
"_indx",
"]",
"+",
"'_'",
"+",
"geisname",
"[",
"_indx",
"+... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | openImage | Opens file and returns PyFITS object. Works on both FITS and GEIS
formatted images.
Notes
-----
If a GEIS or waivered FITS image is used as input, it will convert it to a
MEF object and only if ``writefits = True`` will write it out to a file. If
``fitsname = None``, the name used to write out... | lib/stsci/tools/fileutil.py | def openImage(filename, mode='readonly', memmap=False, writefits=True,
clobber=True, fitsname=None):
"""
Opens file and returns PyFITS object. Works on both FITS and GEIS
formatted images.
Notes
-----
If a GEIS or waivered FITS image is used as input, it will convert it to a
... | def openImage(filename, mode='readonly', memmap=False, writefits=True,
clobber=True, fitsname=None):
"""
Opens file and returns PyFITS object. Works on both FITS and GEIS
formatted images.
Notes
-----
If a GEIS or waivered FITS image is used as input, it will convert it to a
... | [
"Opens",
"file",
"and",
"returns",
"PyFITS",
"object",
".",
"Works",
"on",
"both",
"FITS",
"and",
"GEIS",
"formatted",
"images",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L677-L823 | [
"def",
"openImage",
"(",
"filename",
",",
"mode",
"=",
"'readonly'",
",",
"memmap",
"=",
"False",
",",
"writefits",
"=",
"True",
",",
"clobber",
"=",
"True",
",",
"fitsname",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"filename",
",",
"fits... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | parseFilename | Parse out filename from any specified extensions.
Returns rootname and string version of extension name. | lib/stsci/tools/fileutil.py | def parseFilename(filename):
"""
Parse out filename from any specified extensions.
Returns rootname and string version of extension name.
"""
# Parse out any extension specified in filename
_indx = filename.find('[')
if _indx > 0:
# Read extension name provided
_fname = fil... | def parseFilename(filename):
"""
Parse out filename from any specified extensions.
Returns rootname and string version of extension name.
"""
# Parse out any extension specified in filename
_indx = filename.find('[')
if _indx > 0:
# Read extension name provided
_fname = fil... | [
"Parse",
"out",
"filename",
"from",
"any",
"specified",
"extensions",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L826-L843 | [
"def",
"parseFilename",
"(",
"filename",
")",
":",
"# Parse out any extension specified in filename",
"_indx",
"=",
"filename",
".",
"find",
"(",
"'['",
")",
"if",
"_indx",
">",
"0",
":",
"# Read extension name provided",
"_fname",
"=",
"filename",
"[",
":",
"_ind... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | parseExtn | Parse a string representing a qualified fits extension name as in the
output of `parseFilename` and return a tuple ``(str(extname),
int(extver))``, which can be passed to `astropy.io.fits` functions using
the 'ext' kw.
Default return is the first extension in a fits file.
Examples
--------
... | lib/stsci/tools/fileutil.py | def parseExtn(extn=None):
"""
Parse a string representing a qualified fits extension name as in the
output of `parseFilename` and return a tuple ``(str(extname),
int(extver))``, which can be passed to `astropy.io.fits` functions using
the 'ext' kw.
Default return is the first extension in a fit... | def parseExtn(extn=None):
"""
Parse a string representing a qualified fits extension name as in the
output of `parseFilename` and return a tuple ``(str(extname),
int(extver))``, which can be passed to `astropy.io.fits` functions using
the 'ext' kw.
Default return is the first extension in a fit... | [
"Parse",
"a",
"string",
"representing",
"a",
"qualified",
"fits",
"extension",
"name",
"as",
"in",
"the",
"output",
"of",
"parseFilename",
"and",
"return",
"a",
"tuple",
"(",
"str",
"(",
"extname",
")",
"int",
"(",
"extver",
"))",
"which",
"can",
"be",
"... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L846-L882 | [
"def",
"parseExtn",
"(",
"extn",
"=",
"None",
")",
":",
"if",
"not",
"extn",
":",
"return",
"(",
"''",
",",
"0",
")",
"try",
":",
"lext",
"=",
"extn",
".",
"split",
"(",
"','",
")",
"except",
":",
"return",
"(",
"''",
",",
"1",
")",
"if",
"le... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.