repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
contains-io/containment | containment/builder.py | CommandLineInterface.pave_community | def pave_community(self):
"""
Usage:
containment pave_community
"""
settings.project_config.path.mkdir()
settings.project_config.base.write_text(self.context.base_text)
settings.project_config.os_packages.write_text("[]")
settings.project_config.lang_pac... | python | def pave_community(self):
"""
Usage:
containment pave_community
"""
settings.project_config.path.mkdir()
settings.project_config.base.write_text(self.context.base_text)
settings.project_config.os_packages.write_text("[]")
settings.project_config.lang_pac... | [
"def",
"pave_community",
"(",
"self",
")",
":",
"settings",
".",
"project_config",
".",
"path",
".",
"mkdir",
"(",
")",
"settings",
".",
"project_config",
".",
"base",
".",
"write_text",
"(",
"self",
".",
"context",
".",
"base_text",
")",
"settings",
".",
... | Usage:
containment pave_community | [
"Usage",
":",
"containment",
"pave_community"
] | train | https://github.com/contains-io/containment/blob/4f7e2c2338e0ca7c107a7b3a9913bb5e6e07245f/containment/builder.py#L126-L134 |
contains-io/containment | containment/builder.py | CommandLineInterface.build | def build(self):
"""
Usage:
containment build
"""
docker_build = docker.from_env().api.build
build_actions = []
for a in docker_build(
str(settings.project_customization.path), tag=settings.tag
):
build_actions.append(a) | python | def build(self):
"""
Usage:
containment build
"""
docker_build = docker.from_env().api.build
build_actions = []
for a in docker_build(
str(settings.project_customization.path), tag=settings.tag
):
build_actions.append(a) | [
"def",
"build",
"(",
"self",
")",
":",
"docker_build",
"=",
"docker",
".",
"from_env",
"(",
")",
".",
"api",
".",
"build",
"build_actions",
"=",
"[",
"]",
"for",
"a",
"in",
"docker_build",
"(",
"str",
"(",
"settings",
".",
"project_customization",
".",
... | Usage:
containment build | [
"Usage",
":",
"containment",
"build"
] | train | https://github.com/contains-io/containment/blob/4f7e2c2338e0ca7c107a7b3a9913bb5e6e07245f/containment/builder.py#L169-L179 |
contains-io/containment | containment/builder.py | CommandLineInterface.run | def run(self):
"""
Usage:
containment run
"""
run_command = (
settings.project_customization.runfile.read_text().split()
)
chmod_string = (
"chmod +x "
+ settings.project_customization.runfile.absolute().as_posix()
)
... | python | def run(self):
"""
Usage:
containment run
"""
run_command = (
settings.project_customization.runfile.read_text().split()
)
chmod_string = (
"chmod +x "
+ settings.project_customization.runfile.absolute().as_posix()
)
... | [
"def",
"run",
"(",
"self",
")",
":",
"run_command",
"=",
"(",
"settings",
".",
"project_customization",
".",
"runfile",
".",
"read_text",
"(",
")",
".",
"split",
"(",
")",
")",
"chmod_string",
"=",
"(",
"\"chmod +x \"",
"+",
"settings",
".",
"project_custo... | Usage:
containment run | [
"Usage",
":",
"containment",
"run"
] | train | https://github.com/contains-io/containment/blob/4f7e2c2338e0ca7c107a7b3a9913bb5e6e07245f/containment/builder.py#L181-L196 |
anti1869/sunhead | src/sunhead/events/transports/amqp.py | AMQPClient.connect | async def connect(self):
"""
Create new asynchronous connection to the RabbitMQ instance.
This will connect, declare exchange and bind itself to the configured queue.
After that, client is ready to publish or consume messages.
:return: Does not return anything.
"""
... | python | async def connect(self):
"""
Create new asynchronous connection to the RabbitMQ instance.
This will connect, declare exchange and bind itself to the configured queue.
After that, client is ready to publish or consume messages.
:return: Does not return anything.
"""
... | [
"async",
"def",
"connect",
"(",
"self",
")",
":",
"if",
"self",
".",
"connected",
"or",
"self",
".",
"is_connecting",
":",
"return",
"self",
".",
"_is_connecting",
"=",
"True",
"try",
":",
"logger",
".",
"info",
"(",
"\"Connecting to RabbitMQ...\"",
")",
"... | Create new asynchronous connection to the RabbitMQ instance.
This will connect, declare exchange and bind itself to the configured queue.
After that, client is ready to publish or consume messages.
:return: Does not return anything. | [
"Create",
"new",
"asynchronous",
"connection",
"to",
"the",
"RabbitMQ",
"instance",
".",
"This",
"will",
"connect",
"declare",
"exchange",
"and",
"bind",
"itself",
"to",
"the",
"configured",
"queue",
"."
] | train | https://github.com/anti1869/sunhead/blob/5117ec797a38eb82d955241d20547d125efe80f3/src/sunhead/events/transports/amqp.py#L87-L119 |
anti1869/sunhead | src/sunhead/events/transports/amqp.py | AMQPClient.consume_queue | async def consume_queue(self, subscriber: AbstractSubscriber) -> None:
"""
Subscribe to the queue consuming.
:param subscriber:
:return:
"""
queue_name = subscriber.name
topics = subscriber.requested_topics
if queue_name in self._known_queues:
... | python | async def consume_queue(self, subscriber: AbstractSubscriber) -> None:
"""
Subscribe to the queue consuming.
:param subscriber:
:return:
"""
queue_name = subscriber.name
topics = subscriber.requested_topics
if queue_name in self._known_queues:
... | [
"async",
"def",
"consume_queue",
"(",
"self",
",",
"subscriber",
":",
"AbstractSubscriber",
")",
"->",
"None",
":",
"queue_name",
"=",
"subscriber",
".",
"name",
"topics",
"=",
"subscriber",
".",
"requested_topics",
"if",
"queue_name",
"in",
"self",
".",
"_kno... | Subscribe to the queue consuming.
:param subscriber:
:return: | [
"Subscribe",
"to",
"the",
"queue",
"consuming",
"."
] | train | https://github.com/anti1869/sunhead/blob/5117ec797a38eb82d955241d20547d125efe80f3/src/sunhead/events/transports/amqp.py#L140-L171 |
anti1869/sunhead | src/sunhead/events/transports/amqp.py | AMQPClient._bind_key_to_queue | async def _bind_key_to_queue(self, routing_key: AnyStr, queue_name: AnyStr) -> None:
"""
Bind to queue with specified routing key.
:param routing_key: Routing key to bind with.
:param queue_name: Name of the queue
:return: Does not return anything
"""
logger.info... | python | async def _bind_key_to_queue(self, routing_key: AnyStr, queue_name: AnyStr) -> None:
"""
Bind to queue with specified routing key.
:param routing_key: Routing key to bind with.
:param queue_name: Name of the queue
:return: Does not return anything
"""
logger.info... | [
"async",
"def",
"_bind_key_to_queue",
"(",
"self",
",",
"routing_key",
":",
"AnyStr",
",",
"queue_name",
":",
"AnyStr",
")",
"->",
"None",
":",
"logger",
".",
"info",
"(",
"\"Binding key='%s'\"",
",",
"routing_key",
")",
"result",
"=",
"await",
"self",
".",
... | Bind to queue with specified routing key.
:param routing_key: Routing key to bind with.
:param queue_name: Name of the queue
:return: Does not return anything | [
"Bind",
"to",
"queue",
"with",
"specified",
"routing",
"key",
"."
] | train | https://github.com/anti1869/sunhead/blob/5117ec797a38eb82d955241d20547d125efe80f3/src/sunhead/events/transports/amqp.py#L179-L194 |
anti1869/sunhead | src/sunhead/events/transports/amqp.py | AMQPClient._on_message | async def _on_message(self, channel, body, envelope, properties) -> None:
"""
Fires up when message is received by this consumer.
:param channel: Channel, through which message is received
:param body: Body of the message (serialized).
:param envelope: Envelope object with messa... | python | async def _on_message(self, channel, body, envelope, properties) -> None:
"""
Fires up when message is received by this consumer.
:param channel: Channel, through which message is received
:param body: Body of the message (serialized).
:param envelope: Envelope object with messa... | [
"async",
"def",
"_on_message",
"(",
"self",
",",
"channel",
",",
"body",
",",
"envelope",
",",
"properties",
")",
"->",
"None",
":",
"subscribers",
"=",
"self",
".",
"_get_subscribers",
"(",
"envelope",
".",
"routing_key",
")",
"if",
"not",
"subscribers",
... | Fires up when message is received by this consumer.
:param channel: Channel, through which message is received
:param body: Body of the message (serialized).
:param envelope: Envelope object with message meta
:type envelope: aioamqp.Envelope
:param properties: Properties of the ... | [
"Fires",
"up",
"when",
"message",
"is",
"received",
"by",
"this",
"consumer",
"."
] | train | https://github.com/anti1869/sunhead/blob/5117ec797a38eb82d955241d20547d125efe80f3/src/sunhead/events/transports/amqp.py#L196-L219 |
bertrandvidal/parse_this | parse_this/__init__.py | parse_this | def parse_this(func, types, args=None, delimiter_chars=":"):
"""Create an ArgParser for the given function converting the command line
arguments according to the list of types.
Args:
func: the function for which the command line arguments to be parsed
types: a list of types - as accepted... | python | def parse_this(func, types, args=None, delimiter_chars=":"):
"""Create an ArgParser for the given function converting the command line
arguments according to the list of types.
Args:
func: the function for which the command line arguments to be parsed
types: a list of types - as accepted... | [
"def",
"parse_this",
"(",
"func",
",",
"types",
",",
"args",
"=",
"None",
",",
"delimiter_chars",
"=",
"\":\"",
")",
":",
"_LOG",
".",
"debug",
"(",
"\"Creating parser for %s\"",
",",
"func",
".",
"__name__",
")",
"(",
"func_args",
",",
"dummy_1",
",",
"... | Create an ArgParser for the given function converting the command line
arguments according to the list of types.
Args:
func: the function for which the command line arguments to be parsed
types: a list of types - as accepted by argparse - that will be used to
convert the command ... | [
"Create",
"an",
"ArgParser",
"for",
"the",
"given",
"function",
"converting",
"the",
"command",
"line",
"arguments",
"according",
"to",
"the",
"list",
"of",
"types",
"."
] | train | https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/__init__.py#L19-L37 |
bertrandvidal/parse_this | parse_this/__init__.py | parse_class._add_sub_parsers | def _add_sub_parsers(self, top_level_parser, methods_to_parse, class_name):
"""Add all the sub-parsers to the top_level_parser.
Args:
top_level_parser: the top level parser
methods_to_parse: dict of method name pointing to their associated
argument parser
... | python | def _add_sub_parsers(self, top_level_parser, methods_to_parse, class_name):
"""Add all the sub-parsers to the top_level_parser.
Args:
top_level_parser: the top level parser
methods_to_parse: dict of method name pointing to their associated
argument parser
... | [
"def",
"_add_sub_parsers",
"(",
"self",
",",
"top_level_parser",
",",
"methods_to_parse",
",",
"class_name",
")",
":",
"description",
"=",
"\"Accessible methods of {}\"",
".",
"format",
"(",
"class_name",
")",
"sub_parsers",
"=",
"top_level_parser",
".",
"add_subparse... | Add all the sub-parsers to the top_level_parser.
Args:
top_level_parser: the top level parser
methods_to_parse: dict of method name pointing to their associated
argument parser
class_name: name of the decorated class
Returns:
a dict of regist... | [
"Add",
"all",
"the",
"sub",
"-",
"parsers",
"to",
"the",
"top_level_parser",
"."
] | train | https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/__init__.py#L119-L157 |
bertrandvidal/parse_this | parse_this/__init__.py | parse_class._set_class_parser | def _set_class_parser(self, init_parser, methods_to_parse, cls):
"""Creates the complete argument parser for the decorated class.
Args:
init_parser: argument parser for the __init__ method or None
methods_to_parse: dict of method name pointing to their associated
arg... | python | def _set_class_parser(self, init_parser, methods_to_parse, cls):
"""Creates the complete argument parser for the decorated class.
Args:
init_parser: argument parser for the __init__ method or None
methods_to_parse: dict of method name pointing to their associated
arg... | [
"def",
"_set_class_parser",
"(",
"self",
",",
"init_parser",
",",
"methods_to_parse",
",",
"cls",
")",
":",
"top_level_parents",
"=",
"[",
"init_parser",
"]",
"if",
"init_parser",
"else",
"[",
"]",
"description",
"=",
"self",
".",
"_description",
"or",
"cls",
... | Creates the complete argument parser for the decorated class.
Args:
init_parser: argument parser for the __init__ method or None
methods_to_parse: dict of method name pointing to their associated
argument parser
cls: the class we are decorating
Returns:
... | [
"Creates",
"the",
"complete",
"argument",
"parser",
"for",
"the",
"decorated",
"class",
"."
] | train | https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/__init__.py#L159-L187 |
bertrandvidal/parse_this | parse_this/__init__.py | parse_class._get_parser_call_method | def _get_parser_call_method(self, parser_to_method):
"""Return the parser special method 'call' that handles sub-command
calling.
Args:
parser_to_method: mapping of the parser registered name
to the method it is linked to
"""
def inner_call(args=None,... | python | def _get_parser_call_method(self, parser_to_method):
"""Return the parser special method 'call' that handles sub-command
calling.
Args:
parser_to_method: mapping of the parser registered name
to the method it is linked to
"""
def inner_call(args=None,... | [
"def",
"_get_parser_call_method",
"(",
"self",
",",
"parser_to_method",
")",
":",
"def",
"inner_call",
"(",
"args",
"=",
"None",
",",
"instance",
"=",
"None",
")",
":",
"\"\"\"Allows to call the method invoked from the command line or\n provided argument.\n\n ... | Return the parser special method 'call' that handles sub-command
calling.
Args:
parser_to_method: mapping of the parser registered name
to the method it is linked to | [
"Return",
"the",
"parser",
"special",
"method",
"call",
"that",
"handles",
"sub",
"-",
"command",
"calling",
"."
] | train | https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/__init__.py#L189-L225 |
tschaume/ccsgp_get_started | ccsgp_get_started/examples/gp_lcltpt.py | gp_lcltpt | def gp_lcltpt():
""" example plot to display linecolors, linetypes and pointtypes
.. image:: pics/gp_lcltpt.png
:width: 450 px
"""
inDir, outDir = getWorkDirs()
nSets = len(default_colors)
make_plot(
data = [
np.array([ [0,i,0,0,0], [1,i,0,0,0] ])
for i in xrange(nSets)
],
prop... | python | def gp_lcltpt():
""" example plot to display linecolors, linetypes and pointtypes
.. image:: pics/gp_lcltpt.png
:width: 450 px
"""
inDir, outDir = getWorkDirs()
nSets = len(default_colors)
make_plot(
data = [
np.array([ [0,i,0,0,0], [1,i,0,0,0] ])
for i in xrange(nSets)
],
prop... | [
"def",
"gp_lcltpt",
"(",
")",
":",
"inDir",
",",
"outDir",
"=",
"getWorkDirs",
"(",
")",
"nSets",
"=",
"len",
"(",
"default_colors",
")",
"make_plot",
"(",
"data",
"=",
"[",
"np",
".",
"array",
"(",
"[",
"[",
"0",
",",
"i",
",",
"0",
",",
"0",
... | example plot to display linecolors, linetypes and pointtypes
.. image:: pics/gp_lcltpt.png
:width: 450 px | [
"example",
"plot",
"to",
"display",
"linecolors",
"linetypes",
"and",
"pointtypes"
] | train | https://github.com/tschaume/ccsgp_get_started/blob/e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2/ccsgp_get_started/examples/gp_lcltpt.py#L7-L28 |
pjanis/funtool | funtool/api.py | run_analyses | def run_analyses(prepared_analyses=None,log_dir=default_log_dir):
"""
If all defaults are ok, this should be the only function needed to run the analyses.
"""
if prepared_analyses == None:
prepared_analyses = prepare_analyses()
state_collection = funtool.state_collection.StateCollection(... | python | def run_analyses(prepared_analyses=None,log_dir=default_log_dir):
"""
If all defaults are ok, this should be the only function needed to run the analyses.
"""
if prepared_analyses == None:
prepared_analyses = prepare_analyses()
state_collection = funtool.state_collection.StateCollection(... | [
"def",
"run_analyses",
"(",
"prepared_analyses",
"=",
"None",
",",
"log_dir",
"=",
"default_log_dir",
")",
":",
"if",
"prepared_analyses",
"==",
"None",
":",
"prepared_analyses",
"=",
"prepare_analyses",
"(",
")",
"state_collection",
"=",
"funtool",
".",
"state_co... | If all defaults are ok, this should be the only function needed to run the analyses. | [
"If",
"all",
"defaults",
"are",
"ok",
"this",
"should",
"be",
"the",
"only",
"function",
"needed",
"to",
"run",
"the",
"analyses",
"."
] | train | https://github.com/pjanis/funtool/blob/231851238f0a62bc3682d8fa937db9053378c53d/funtool/api.py#L98-L107 |
pjanis/funtool | funtool/api.py | run_analysis | def run_analysis( named_analysis, prepared_analyses=None,log_dir=default_log_dir):
"""
Runs just the named analysis. Otherwise just like run_analyses
"""
if prepared_analyses == None:
prepared_analyses = prepare_analyses()
state_collection = funtool.state_collection.StateCollection([],{})
... | python | def run_analysis( named_analysis, prepared_analyses=None,log_dir=default_log_dir):
"""
Runs just the named analysis. Otherwise just like run_analyses
"""
if prepared_analyses == None:
prepared_analyses = prepare_analyses()
state_collection = funtool.state_collection.StateCollection([],{})
... | [
"def",
"run_analysis",
"(",
"named_analysis",
",",
"prepared_analyses",
"=",
"None",
",",
"log_dir",
"=",
"default_log_dir",
")",
":",
"if",
"prepared_analyses",
"==",
"None",
":",
"prepared_analyses",
"=",
"prepare_analyses",
"(",
")",
"state_collection",
"=",
"f... | Runs just the named analysis. Otherwise just like run_analyses | [
"Runs",
"just",
"the",
"named",
"analysis",
".",
"Otherwise",
"just",
"like",
"run_analyses"
] | train | https://github.com/pjanis/funtool/blob/231851238f0a62bc3682d8fa937db9053378c53d/funtool/api.py#L109-L119 |
edeposit/edeposit.amqp.aleph | src/edeposit/amqp/aleph/datastructures/epublication.py | EPublication.from_xml | def from_xml(xml):
"""
Convert :class:`.MARCXMLRecord` object to :class:`.EPublication`
namedtuple.
Args:
xml (str/MARCXMLRecord): MARC XML which will be converted to
EPublication. In case of str, ``<record>`` tag is required.
Returns:
st... | python | def from_xml(xml):
"""
Convert :class:`.MARCXMLRecord` object to :class:`.EPublication`
namedtuple.
Args:
xml (str/MARCXMLRecord): MARC XML which will be converted to
EPublication. In case of str, ``<record>`` tag is required.
Returns:
st... | [
"def",
"from_xml",
"(",
"xml",
")",
":",
"parsed",
"=",
"xml",
"if",
"not",
"isinstance",
"(",
"xml",
",",
"MARCXMLRecord",
")",
":",
"parsed",
"=",
"MARCXMLRecord",
"(",
"str",
"(",
"xml",
")",
")",
"# check whether the document was deleted",
"if",
"\"DEL\"... | Convert :class:`.MARCXMLRecord` object to :class:`.EPublication`
namedtuple.
Args:
xml (str/MARCXMLRecord): MARC XML which will be converted to
EPublication. In case of str, ``<record>`` tag is required.
Returns:
structure: :class:`.EPublication` namedtu... | [
"Convert",
":",
"class",
":",
".",
"MARCXMLRecord",
"object",
"to",
":",
"class",
":",
".",
"EPublication",
"namedtuple",
"."
] | train | https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/datastructures/epublication.py#L90-L145 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/runner/poller.py | AsyncPoller.poll | def poll(self):
""" Poll the job status.
Returns the changes in this iteration."""
self.runner.module_name = 'async_status'
self.runner.module_args = "jid=%s" % self.jid
self.runner.pattern = "*"
self.runner.background = 0
self.runner.inventory.restrict_to(s... | python | def poll(self):
""" Poll the job status.
Returns the changes in this iteration."""
self.runner.module_name = 'async_status'
self.runner.module_args = "jid=%s" % self.jid
self.runner.pattern = "*"
self.runner.background = 0
self.runner.inventory.restrict_to(s... | [
"def",
"poll",
"(",
"self",
")",
":",
"self",
".",
"runner",
".",
"module_name",
"=",
"'async_status'",
"self",
".",
"runner",
".",
"module_args",
"=",
"\"jid=%s\"",
"%",
"self",
".",
"jid",
"self",
".",
"runner",
".",
"pattern",
"=",
"\"*\"",
"self",
... | Poll the job status.
Returns the changes in this iteration. | [
"Poll",
"the",
"job",
"status",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/poller.py#L54-L89 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/runner/poller.py | AsyncPoller.wait | def wait(self, seconds, poll_interval):
""" Wait a certain time for job completion, check status every poll_interval. """
# jid is None when all hosts were skipped
if self.jid is None:
return self.results
clock = seconds - poll_interval
while (clock >= 0 and not self... | python | def wait(self, seconds, poll_interval):
""" Wait a certain time for job completion, check status every poll_interval. """
# jid is None when all hosts were skipped
if self.jid is None:
return self.results
clock = seconds - poll_interval
while (clock >= 0 and not self... | [
"def",
"wait",
"(",
"self",
",",
"seconds",
",",
"poll_interval",
")",
":",
"# jid is None when all hosts were skipped",
"if",
"self",
".",
"jid",
"is",
"None",
":",
"return",
"self",
".",
"results",
"clock",
"=",
"seconds",
"-",
"poll_interval",
"while",
"(",... | Wait a certain time for job completion, check status every poll_interval. | [
"Wait",
"a",
"certain",
"time",
"for",
"job",
"completion",
"check",
"status",
"every",
"poll_interval",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/poller.py#L91-L109 |
minhhoit/yacms | yacms/core/forms.py | get_edit_form | def get_edit_form(obj, field_names, data=None, files=None):
"""
Returns the in-line editing form for editing a single model field.
"""
# Map these form fields to their types defined in the forms app so
# we can make use of their custom widgets.
from yacms.forms import fields
widget_override... | python | def get_edit_form(obj, field_names, data=None, files=None):
"""
Returns the in-line editing form for editing a single model field.
"""
# Map these form fields to their types defined in the forms app so
# we can make use of their custom widgets.
from yacms.forms import fields
widget_override... | [
"def",
"get_edit_form",
"(",
"obj",
",",
"field_names",
",",
"data",
"=",
"None",
",",
"files",
"=",
"None",
")",
":",
"# Map these form fields to their types defined in the forms app so",
"# we can make use of their custom widgets.",
"from",
"yacms",
".",
"forms",
"impor... | Returns the in-line editing form for editing a single model field. | [
"Returns",
"the",
"in",
"-",
"line",
"editing",
"form",
"for",
"editing",
"a",
"single",
"model",
"field",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/forms.py#L107-L155 |
emencia/emencia-django-forum | forum/forms/category.py | CategoryForm.clean_description | def clean_description(self):
"""
Text content validation
"""
description = self.cleaned_data.get("description")
validation_helper = safe_import_module(settings.FORUM_TEXT_VALIDATOR_HELPER_PATH)
if validation_helper is not None:
return validation_helper(self, d... | python | def clean_description(self):
"""
Text content validation
"""
description = self.cleaned_data.get("description")
validation_helper = safe_import_module(settings.FORUM_TEXT_VALIDATOR_HELPER_PATH)
if validation_helper is not None:
return validation_helper(self, d... | [
"def",
"clean_description",
"(",
"self",
")",
":",
"description",
"=",
"self",
".",
"cleaned_data",
".",
"get",
"(",
"\"description\"",
")",
"validation_helper",
"=",
"safe_import_module",
"(",
"settings",
".",
"FORUM_TEXT_VALIDATOR_HELPER_PATH",
")",
"if",
"validat... | Text content validation | [
"Text",
"content",
"validation"
] | train | https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/forms/category.py#L29-L38 |
polysquare/polysquare-generic-file-linter | polysquarelinter/lint_spelling_only.py | _filter_disabled_regions | def _filter_disabled_regions(contents):
"""Filter regions that are contained in back-ticks."""
contents = list(contents)
in_backticks = False
contents_len = len(contents)
index = 0
while index < contents_len:
character = contents[index]
if character == "`":
# Check ... | python | def _filter_disabled_regions(contents):
"""Filter regions that are contained in back-ticks."""
contents = list(contents)
in_backticks = False
contents_len = len(contents)
index = 0
while index < contents_len:
character = contents[index]
if character == "`":
# Check ... | [
"def",
"_filter_disabled_regions",
"(",
"contents",
")",
":",
"contents",
"=",
"list",
"(",
"contents",
")",
"in_backticks",
"=",
"False",
"contents_len",
"=",
"len",
"(",
"contents",
")",
"index",
"=",
"0",
"while",
"index",
"<",
"contents_len",
":",
"chara... | Filter regions that are contained in back-ticks. | [
"Filter",
"regions",
"that",
"are",
"contained",
"in",
"back",
"-",
"ticks",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/lint_spelling_only.py#L28-L52 |
polysquare/polysquare-generic-file-linter | polysquarelinter/lint_spelling_only.py | spellcheck | def spellcheck(contents, technical_terms=None, spellcheck_cache=None):
"""Run spellcheck on the contents of a file.
:technical_terms: is a path to a file containing a list of "technical"
terms. These may be symbols as collected from files by using
the generic linter or other such symbols. If a symbol-l... | python | def spellcheck(contents, technical_terms=None, spellcheck_cache=None):
"""Run spellcheck on the contents of a file.
:technical_terms: is a path to a file containing a list of "technical"
terms. These may be symbols as collected from files by using
the generic linter or other such symbols. If a symbol-l... | [
"def",
"spellcheck",
"(",
"contents",
",",
"technical_terms",
"=",
"None",
",",
"spellcheck_cache",
"=",
"None",
")",
":",
"contents",
"=",
"spelling",
".",
"filter_nonspellcheckable_tokens",
"(",
"contents",
")",
"contents",
"=",
"_filter_disabled_regions",
"(",
... | Run spellcheck on the contents of a file.
:technical_terms: is a path to a file containing a list of "technical"
terms. These may be symbols as collected from files by using
the generic linter or other such symbols. If a symbol-like term is
used within contents and it does not appear in :technical_term... | [
"Run",
"spellcheck",
"on",
"the",
"contents",
"of",
"a",
"file",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/lint_spelling_only.py#L55-L79 |
polysquare/polysquare-generic-file-linter | polysquarelinter/lint_spelling_only.py | _parse_arguments | def _parse_arguments(arguments=None):
"""Return a parser context result."""
dir_hash = hashlib.sha1(os.getcwd().encode("utf-8")).hexdigest()
parser = argparse.ArgumentParser(description="""Find spelling errors""")
parser.add_argument("files",
nargs="*",
m... | python | def _parse_arguments(arguments=None):
"""Return a parser context result."""
dir_hash = hashlib.sha1(os.getcwd().encode("utf-8")).hexdigest()
parser = argparse.ArgumentParser(description="""Find spelling errors""")
parser.add_argument("files",
nargs="*",
m... | [
"def",
"_parse_arguments",
"(",
"arguments",
"=",
"None",
")",
":",
"dir_hash",
"=",
"hashlib",
".",
"sha1",
"(",
"os",
".",
"getcwd",
"(",
")",
".",
"encode",
"(",
"\"utf-8\"",
")",
")",
".",
"hexdigest",
"(",
")",
"parser",
"=",
"argparse",
".",
"A... | Return a parser context result. | [
"Return",
"a",
"parser",
"context",
"result",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/lint_spelling_only.py#L82-L105 |
polysquare/polysquare-generic-file-linter | polysquarelinter/lint_spelling_only.py | _report_spelling_error | def _report_spelling_error(error, file_path):
"""Report a spelling error."""
line = error.line_offset + 1
code = "file/spelling_error"
description = _SPELLCHECK_MESSAGES[error.error_type].format(error.word)
if error.suggestions is not None:
description = (description +
... | python | def _report_spelling_error(error, file_path):
"""Report a spelling error."""
line = error.line_offset + 1
code = "file/spelling_error"
description = _SPELLCHECK_MESSAGES[error.error_type].format(error.word)
if error.suggestions is not None:
description = (description +
... | [
"def",
"_report_spelling_error",
"(",
"error",
",",
"file_path",
")",
":",
"line",
"=",
"error",
".",
"line_offset",
"+",
"1",
"code",
"=",
"\"file/spelling_error\"",
"description",
"=",
"_SPELLCHECK_MESSAGES",
"[",
"error",
".",
"error_type",
"]",
".",
"format"... | Report a spelling error. | [
"Report",
"a",
"spelling",
"error",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/lint_spelling_only.py#L115-L128 |
polysquare/polysquare-generic-file-linter | polysquarelinter/lint_spelling_only.py | main | def main(arguments=None): # suppress(unused-function)
"""Entry point for the spellcheck linter."""
dictionary_path = os.path.abspath("DICTIONARY")
result = _parse_arguments(arguments)
num_errors = 0
for found_filename in result.files:
file_path = os.path.abspath(found_filename)
wit... | python | def main(arguments=None): # suppress(unused-function)
"""Entry point for the spellcheck linter."""
dictionary_path = os.path.abspath("DICTIONARY")
result = _parse_arguments(arguments)
num_errors = 0
for found_filename in result.files:
file_path = os.path.abspath(found_filename)
wit... | [
"def",
"main",
"(",
"arguments",
"=",
"None",
")",
":",
"# suppress(unused-function)",
"dictionary_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"\"DICTIONARY\"",
")",
"result",
"=",
"_parse_arguments",
"(",
"arguments",
")",
"num_errors",
"=",
"0",
"for... | Entry point for the spellcheck linter. | [
"Entry",
"point",
"for",
"the",
"spellcheck",
"linter",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/lint_spelling_only.py#L131-L165 |
sirrice/scorpionsql | scorpionsql/errfunc.py | AggErrFunc.recover | def recover(self, state):
"recompute the actual value, then compare it against the truth"
newval = self.f.recover(state)
return self.errtype(self.value, newval) | python | def recover(self, state):
"recompute the actual value, then compare it against the truth"
newval = self.f.recover(state)
return self.errtype(self.value, newval) | [
"def",
"recover",
"(",
"self",
",",
"state",
")",
":",
"newval",
"=",
"self",
".",
"f",
".",
"recover",
"(",
"state",
")",
"return",
"self",
".",
"errtype",
"(",
"self",
".",
"value",
",",
"newval",
")"
] | recompute the actual value, then compare it against the truth | [
"recompute",
"the",
"actual",
"value",
"then",
"compare",
"it",
"against",
"the",
"truth"
] | train | https://github.com/sirrice/scorpionsql/blob/baa05b745fae5df3171244c3e32160bd36c99e86/scorpionsql/errfunc.py#L182-L185 |
xtrementl/focus | focus/version.py | compare_version | def compare_version(value):
""" Determines if the provided version value compares with program version.
`value`
Version comparison string (e.g. ==1.0, <=1.0, >1.1)
Supported operators:
<, <=, ==, >, >=
"""
# extract parts from value
import re... | python | def compare_version(value):
""" Determines if the provided version value compares with program version.
`value`
Version comparison string (e.g. ==1.0, <=1.0, >1.1)
Supported operators:
<, <=, ==, >, >=
"""
# extract parts from value
import re... | [
"def",
"compare_version",
"(",
"value",
")",
":",
"# extract parts from value",
"import",
"re",
"res",
"=",
"re",
".",
"match",
"(",
"r'(<|<=|==|>|>=)(\\d{1,2}\\.\\d{1,2}(\\.\\d{1,2})?)$'",
",",
"str",
"(",
"value",
")",
".",
"strip",
"(",
")",
")",
"if",
"not",... | Determines if the provided version value compares with program version.
`value`
Version comparison string (e.g. ==1.0, <=1.0, >1.1)
Supported operators:
<, <=, ==, >, >= | [
"Determines",
"if",
"the",
"provided",
"version",
"value",
"compares",
"with",
"program",
"version",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/version.py#L8-L46 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/__init__.py | get_all_publications | def get_all_publications(return_namedtuples=True):
"""
Get list publications from all available source.
Args:
return_namedtuples (bool, default True): Convert :class:`.Publication`
structures to namedtuples (used in AMQP
communication).
Ret... | python | def get_all_publications(return_namedtuples=True):
"""
Get list publications from all available source.
Args:
return_namedtuples (bool, default True): Convert :class:`.Publication`
structures to namedtuples (used in AMQP
communication).
Ret... | [
"def",
"get_all_publications",
"(",
"return_namedtuples",
"=",
"True",
")",
":",
"sources",
"=",
"[",
"ben_cz",
".",
"get_publications",
",",
"grada_cz",
".",
"get_publications",
",",
"cpress_cz",
".",
"get_publications",
",",
"zonerpress_cz",
".",
"get_publications... | Get list publications from all available source.
Args:
return_namedtuples (bool, default True): Convert :class:`.Publication`
structures to namedtuples (used in AMQP
communication).
Returns:
list: List of :class:`.Publication` structures co... | [
"Get",
"list",
"publications",
"from",
"all",
"available",
"source",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/__init__.py#L16-L46 |
zerotk/reraiseit | zerotk/reraiseit/_reraiseit.py | reraise | def reraise(exception, message, separator='\n'):
"""
Raised the same exception given, with an additional message.
:param Exception exception:
Original exception being raised with additional messages
:param unicode message:
Message to be added to the given exception
:para... | python | def reraise(exception, message, separator='\n'):
"""
Raised the same exception given, with an additional message.
:param Exception exception:
Original exception being raised with additional messages
:param unicode message:
Message to be added to the given exception
:para... | [
"def",
"reraise",
"(",
"exception",
",",
"message",
",",
"separator",
"=",
"'\\n'",
")",
":",
"import",
"sys",
"# IMPORTANT: Do NOT use try/except mechanisms in this method or the\r",
"# sys.exc_info()[-1] will be invalid\r",
"if",
"hasattr",
"(",
"exception",
",",
"'rerais... | Raised the same exception given, with an additional message.
:param Exception exception:
Original exception being raised with additional messages
:param unicode message:
Message to be added to the given exception
:param unicode separator:
String separating `message` from ... | [
"Raised",
"the",
"same",
"exception",
"given",
"with",
"an",
"additional",
"message",
".",
":",
"param",
"Exception",
"exception",
":",
"Original",
"exception",
"being",
"raised",
"with",
"additional",
"messages",
":",
"param",
"unicode",
"message",
":",
"Messag... | train | https://github.com/zerotk/reraiseit/blob/3d6c640229e286b539cb06c437151028c51c7003/zerotk/reraiseit/_reraiseit.py#L11-L80 |
zerotk/reraiseit | zerotk/reraiseit/_reraiseit.py | exception_to_unicode | def exception_to_unicode(exception):
"""
Obtains unicode representation of an Exception.
This wrapper is used to circumvent Python 2.7 problems with built-in
exceptions with unicode messages.
Steps used:
* Try to obtain Exception.__unicode__
* Try to obtain Exception.__str... | python | def exception_to_unicode(exception):
"""
Obtains unicode representation of an Exception.
This wrapper is used to circumvent Python 2.7 problems with built-in
exceptions with unicode messages.
Steps used:
* Try to obtain Exception.__unicode__
* Try to obtain Exception.__str... | [
"def",
"exception_to_unicode",
"(",
"exception",
")",
":",
"if",
"six",
".",
"PY2",
":",
"try",
":",
"# First, try to obtain __unicode__ as defined by the Exception\r",
"return",
"six",
".",
"text_type",
"(",
"exception",
")",
"except",
"UnicodeDecodeError",
":",
"try... | Obtains unicode representation of an Exception.
This wrapper is used to circumvent Python 2.7 problems with built-in
exceptions with unicode messages.
Steps used:
* Try to obtain Exception.__unicode__
* Try to obtain Exception.__str__ and decode with utf-8
* Try to obtain E... | [
"Obtains",
"unicode",
"representation",
"of",
"an",
"Exception",
".",
"This",
"wrapper",
"is",
"used",
"to",
"circumvent",
"Python",
"2",
".",
"7",
"problems",
"with",
"built",
"-",
"in",
"exceptions",
"with",
"unicode",
"messages",
".",
"Steps",
"used",
":"... | train | https://github.com/zerotk/reraiseit/blob/3d6c640229e286b539cb06c437151028c51c7003/zerotk/reraiseit/_reraiseit.py#L83-L134 |
treycucco/bidon | bidon/spreadsheet/open_document.py | OpenDocumentWorksheet.parse_cell | def parse_cell(self, cell, coords, cell_mode=CellMode.cooked):
"""Parses a cell according to its cell.value_type."""
# pylint: disable=too-many-return-statements
if cell_mode == CellMode.cooked:
if cell.covered or cell.value_type is None or cell.value is None:
return None
vtype = cell.v... | python | def parse_cell(self, cell, coords, cell_mode=CellMode.cooked):
"""Parses a cell according to its cell.value_type."""
# pylint: disable=too-many-return-statements
if cell_mode == CellMode.cooked:
if cell.covered or cell.value_type is None or cell.value is None:
return None
vtype = cell.v... | [
"def",
"parse_cell",
"(",
"self",
",",
"cell",
",",
"coords",
",",
"cell_mode",
"=",
"CellMode",
".",
"cooked",
")",
":",
"# pylint: disable=too-many-return-statements",
"if",
"cell_mode",
"==",
"CellMode",
".",
"cooked",
":",
"if",
"cell",
".",
"covered",
"or... | Parses a cell according to its cell.value_type. | [
"Parses",
"a",
"cell",
"according",
"to",
"its",
"cell",
".",
"value_type",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/spreadsheet/open_document.py#L28-L59 |
treycucco/bidon | bidon/spreadsheet/open_document.py | OpenDocumentWorksheet.get_row | def get_row(self, row_index):
"""Returns the row at row_index."""
if self._raw_rows is None:
self._raw_rows = list(self.raw_sheet.rows())
return self._raw_rows[row_index] | python | def get_row(self, row_index):
"""Returns the row at row_index."""
if self._raw_rows is None:
self._raw_rows = list(self.raw_sheet.rows())
return self._raw_rows[row_index] | [
"def",
"get_row",
"(",
"self",
",",
"row_index",
")",
":",
"if",
"self",
".",
"_raw_rows",
"is",
"None",
":",
"self",
".",
"_raw_rows",
"=",
"list",
"(",
"self",
".",
"raw_sheet",
".",
"rows",
"(",
")",
")",
"return",
"self",
".",
"_raw_rows",
"[",
... | Returns the row at row_index. | [
"Returns",
"the",
"row",
"at",
"row_index",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/spreadsheet/open_document.py#L61-L65 |
treycucco/bidon | bidon/spreadsheet/open_document.py | OpenDocumentWorksheet.merged_cell_ranges | def merged_cell_ranges(self):
"""Generates the sequence of merged cell ranges in the format:
((col_low, row_low), (col_hi, row_hi))
"""
for row_number, row in enumerate(self.raw_sheet.rows()):
for col_number, cell in enumerate(row):
rspan, cspan = cell.span
if (rspan, cspan) != (1... | python | def merged_cell_ranges(self):
"""Generates the sequence of merged cell ranges in the format:
((col_low, row_low), (col_hi, row_hi))
"""
for row_number, row in enumerate(self.raw_sheet.rows()):
for col_number, cell in enumerate(row):
rspan, cspan = cell.span
if (rspan, cspan) != (1... | [
"def",
"merged_cell_ranges",
"(",
"self",
")",
":",
"for",
"row_number",
",",
"row",
"in",
"enumerate",
"(",
"self",
".",
"raw_sheet",
".",
"rows",
"(",
")",
")",
":",
"for",
"col_number",
",",
"cell",
"in",
"enumerate",
"(",
"row",
")",
":",
"rspan",
... | Generates the sequence of merged cell ranges in the format:
((col_low, row_low), (col_hi, row_hi)) | [
"Generates",
"the",
"sequence",
"of",
"merged",
"cell",
"ranges",
"in",
"the",
"format",
":"
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/spreadsheet/open_document.py#L67-L76 |
ovidner/python-liu | liu/kobra/__init__.py | KOBRAClient.get_student | def get_student(self, **kwargs):
"""
Calls the API and gets a student by **one** (1) of these parameters at a time:
:param liu_id: LiU-ID (e.g. johec890)
:param email: Email address (e.g. johec890@student.liu.se)
:param personal_number: Personal identification number (e.g. 860421... | python | def get_student(self, **kwargs):
"""
Calls the API and gets a student by **one** (1) of these parameters at a time:
:param liu_id: LiU-ID (e.g. johec890)
:param email: Email address (e.g. johec890@student.liu.se)
:param personal_number: Personal identification number (e.g. 860421... | [
"def",
"get_student",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"kwargs",
")",
"!=",
"1",
"or",
"not",
"any",
"(",
"i",
"in",
"self",
".",
"accepted_params",
"for",
"i",
"in",
"kwargs",
".",
"keys",
"(",
")",
")",
":",
"... | Calls the API and gets a student by **one** (1) of these parameters at a time:
:param liu_id: LiU-ID (e.g. johec890)
:param email: Email address (e.g. johec890@student.liu.se)
:param personal_number: Personal identification number (e.g. 860421-0000)
:param rfid_number: LiU card number (N... | [
"Calls",
"the",
"API",
"and",
"gets",
"a",
"student",
"by",
"**",
"one",
"**",
"(",
"1",
")",
"of",
"these",
"parameters",
"at",
"a",
"time",
":",
":",
"param",
"liu_id",
":",
"LiU",
"-",
"ID",
"(",
"e",
".",
"g",
".",
"johec890",
")",
":",
"pa... | train | https://github.com/ovidner/python-liu/blob/f5f4039ef0908c6e871fccb61a8c539116230076/liu/kobra/__init__.py#L31-L55 |
slarse/pdfebc-core | pdfebc_core/config_utils.py | create_config | def create_config(sections, section_contents):
"""Create a config file from the provided sections and key value pairs.
Args:
sections (List[str]): A list of section keys.
key_value_pairs (Dict[str, str]): A list of of dictionaries. Must be as long as
the list of sections. That is to say... | python | def create_config(sections, section_contents):
"""Create a config file from the provided sections and key value pairs.
Args:
sections (List[str]): A list of section keys.
key_value_pairs (Dict[str, str]): A list of of dictionaries. Must be as long as
the list of sections. That is to say... | [
"def",
"create_config",
"(",
"sections",
",",
"section_contents",
")",
":",
"sections_length",
",",
"section_contents_length",
"=",
"len",
"(",
"sections",
")",
",",
"len",
"(",
"section_contents",
")",
"if",
"sections_length",
"!=",
"section_contents_length",
":",
... | Create a config file from the provided sections and key value pairs.
Args:
sections (List[str]): A list of section keys.
key_value_pairs (Dict[str, str]): A list of of dictionaries. Must be as long as
the list of sections. That is to say, if there are two sections, there should be two
... | [
"Create",
"a",
"config",
"file",
"from",
"the",
"provided",
"sections",
"and",
"key",
"value",
"pairs",
"."
] | train | https://github.com/slarse/pdfebc-core/blob/fc40857bc42365b7434714333e37d7a3487603a0/pdfebc_core/config_utils.py#L56-L78 |
slarse/pdfebc-core | pdfebc_core/config_utils.py | write_config | def write_config(config, config_path=CONFIG_PATH):
"""Write the config to the output path.
Creates the necessary directories if they aren't there.
Args:
config (configparser.ConfigParser): A ConfigParser.
"""
if not os.path.exists(config_path):
os.makedirs(os.path.dirname(config_pat... | python | def write_config(config, config_path=CONFIG_PATH):
"""Write the config to the output path.
Creates the necessary directories if they aren't there.
Args:
config (configparser.ConfigParser): A ConfigParser.
"""
if not os.path.exists(config_path):
os.makedirs(os.path.dirname(config_pat... | [
"def",
"write_config",
"(",
"config",
",",
"config_path",
"=",
"CONFIG_PATH",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"config_path",
")",
":",
"os",
".",
"makedirs",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"config_path",
")",... | Write the config to the output path.
Creates the necessary directories if they aren't there.
Args:
config (configparser.ConfigParser): A ConfigParser. | [
"Write",
"the",
"config",
"to",
"the",
"output",
"path",
".",
"Creates",
"the",
"necessary",
"directories",
"if",
"they",
"aren",
"t",
"there",
"."
] | train | https://github.com/slarse/pdfebc-core/blob/fc40857bc42365b7434714333e37d7a3487603a0/pdfebc_core/config_utils.py#L80-L90 |
slarse/pdfebc-core | pdfebc_core/config_utils.py | read_config | def read_config(config_path=CONFIG_PATH):
"""Read the config information from the config file.
Args:
config_path (str): Relative path to the email config file.
Returns:
defaultdict: A defaultdict with the config information.
Raises:
IOError
"""
if not os.path.isfile(conf... | python | def read_config(config_path=CONFIG_PATH):
"""Read the config information from the config file.
Args:
config_path (str): Relative path to the email config file.
Returns:
defaultdict: A defaultdict with the config information.
Raises:
IOError
"""
if not os.path.isfile(conf... | [
"def",
"read_config",
"(",
"config_path",
"=",
"CONFIG_PATH",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"config_path",
")",
":",
"raise",
"IOError",
"(",
"\"No config file found at %s\"",
"%",
"config_path",
")",
"config_parser",
"=",
"conf... | Read the config information from the config file.
Args:
config_path (str): Relative path to the email config file.
Returns:
defaultdict: A defaultdict with the config information.
Raises:
IOError | [
"Read",
"the",
"config",
"information",
"from",
"the",
"config",
"file",
"."
] | train | https://github.com/slarse/pdfebc-core/blob/fc40857bc42365b7434714333e37d7a3487603a0/pdfebc_core/config_utils.py#L92-L107 |
slarse/pdfebc-core | pdfebc_core/config_utils.py | check_config | def check_config(config):
"""Check that all sections of the config contain the keys that they should.
Args:
config (defaultdict): A defaultdict.
Raises:
ConfigurationError
"""
for section, expected_section_keys in SECTION_KEYS.items():
section_content = config.get(section)
... | python | def check_config(config):
"""Check that all sections of the config contain the keys that they should.
Args:
config (defaultdict): A defaultdict.
Raises:
ConfigurationError
"""
for section, expected_section_keys in SECTION_KEYS.items():
section_content = config.get(section)
... | [
"def",
"check_config",
"(",
"config",
")",
":",
"for",
"section",
",",
"expected_section_keys",
"in",
"SECTION_KEYS",
".",
"items",
"(",
")",
":",
"section_content",
"=",
"config",
".",
"get",
"(",
"section",
")",
"if",
"not",
"section_content",
":",
"raise"... | Check that all sections of the config contain the keys that they should.
Args:
config (defaultdict): A defaultdict.
Raises:
ConfigurationError | [
"Check",
"that",
"all",
"sections",
"of",
"the",
"config",
"contain",
"the",
"keys",
"that",
"they",
"should",
"."
] | train | https://github.com/slarse/pdfebc-core/blob/fc40857bc42365b7434714333e37d7a3487603a0/pdfebc_core/config_utils.py#L109-L124 |
slarse/pdfebc-core | pdfebc_core/config_utils.py | run_config_diagnostics | def run_config_diagnostics(config_path=CONFIG_PATH):
"""Run diagnostics on the configuration file.
Args:
config_path (str): Path to the configuration file.
Returns:
str, Set[str], dict(str, Set[str]): The path to the configuration file, a set of missing
sections and a dict that maps... | python | def run_config_diagnostics(config_path=CONFIG_PATH):
"""Run diagnostics on the configuration file.
Args:
config_path (str): Path to the configuration file.
Returns:
str, Set[str], dict(str, Set[str]): The path to the configuration file, a set of missing
sections and a dict that maps... | [
"def",
"run_config_diagnostics",
"(",
"config_path",
"=",
"CONFIG_PATH",
")",
":",
"config",
"=",
"read_config",
"(",
"config_path",
")",
"missing_sections",
"=",
"set",
"(",
")",
"malformed_entries",
"=",
"defaultdict",
"(",
"set",
")",
"for",
"section",
",",
... | Run diagnostics on the configuration file.
Args:
config_path (str): Path to the configuration file.
Returns:
str, Set[str], dict(str, Set[str]): The path to the configuration file, a set of missing
sections and a dict that maps each section to the entries that have either missing or emp... | [
"Run",
"diagnostics",
"on",
"the",
"configuration",
"file",
"."
] | train | https://github.com/slarse/pdfebc-core/blob/fc40857bc42365b7434714333e37d7a3487603a0/pdfebc_core/config_utils.py#L126-L148 |
slarse/pdfebc-core | pdfebc_core/config_utils.py | get_attribute_from_config | def get_attribute_from_config(config, section, attribute):
"""Try to parse an attribute of the config file.
Args:
config (defaultdict): A defaultdict.
section (str): The section of the config file to get information from.
attribute (str): The attribute of the section to fetch.
Retur... | python | def get_attribute_from_config(config, section, attribute):
"""Try to parse an attribute of the config file.
Args:
config (defaultdict): A defaultdict.
section (str): The section of the config file to get information from.
attribute (str): The attribute of the section to fetch.
Retur... | [
"def",
"get_attribute_from_config",
"(",
"config",
",",
"section",
",",
"attribute",
")",
":",
"section",
"=",
"config",
".",
"get",
"(",
"section",
")",
"if",
"section",
":",
"option",
"=",
"section",
".",
"get",
"(",
"attribute",
")",
"if",
"option",
"... | Try to parse an attribute of the config file.
Args:
config (defaultdict): A defaultdict.
section (str): The section of the config file to get information from.
attribute (str): The attribute of the section to fetch.
Returns:
str: The string corresponding to the section and attri... | [
"Try",
"to",
"parse",
"an",
"attribute",
"of",
"the",
"config",
"file",
"."
] | train | https://github.com/slarse/pdfebc-core/blob/fc40857bc42365b7434714333e37d7a3487603a0/pdfebc_core/config_utils.py#L150-L169 |
slarse/pdfebc-core | pdfebc_core/config_utils.py | valid_config_exists | def valid_config_exists(config_path=CONFIG_PATH):
"""Verify that a valid config file exists.
Args:
config_path (str): Path to the config file.
Returns:
boolean: True if there is a valid config file, false if not.
"""
if os.path.isfile(config_path):
try:
config =... | python | def valid_config_exists(config_path=CONFIG_PATH):
"""Verify that a valid config file exists.
Args:
config_path (str): Path to the config file.
Returns:
boolean: True if there is a valid config file, false if not.
"""
if os.path.isfile(config_path):
try:
config =... | [
"def",
"valid_config_exists",
"(",
"config_path",
"=",
"CONFIG_PATH",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"config_path",
")",
":",
"try",
":",
"config",
"=",
"read_config",
"(",
"config_path",
")",
"check_config",
"(",
"config",
")",
"ex... | Verify that a valid config file exists.
Args:
config_path (str): Path to the config file.
Returns:
boolean: True if there is a valid config file, false if not. | [
"Verify",
"that",
"a",
"valid",
"config",
"file",
"exists",
"."
] | train | https://github.com/slarse/pdfebc-core/blob/fc40857bc42365b7434714333e37d7a3487603a0/pdfebc_core/config_utils.py#L171-L188 |
slarse/pdfebc-core | pdfebc_core/config_utils.py | config_to_string | def config_to_string(config):
"""Nice output string for the config, which is a nested defaultdict.
Args:
config (defaultdict(defaultdict)): The configuration information.
Returns:
str: A human-readable output string detailing the contents of the config.
"""
output = []
for secti... | python | def config_to_string(config):
"""Nice output string for the config, which is a nested defaultdict.
Args:
config (defaultdict(defaultdict)): The configuration information.
Returns:
str: A human-readable output string detailing the contents of the config.
"""
output = []
for secti... | [
"def",
"config_to_string",
"(",
"config",
")",
":",
"output",
"=",
"[",
"]",
"for",
"section",
",",
"section_content",
"in",
"config",
".",
"items",
"(",
")",
":",
"output",
".",
"append",
"(",
"\"[{}]\"",
".",
"format",
"(",
"section",
")",
")",
"for"... | Nice output string for the config, which is a nested defaultdict.
Args:
config (defaultdict(defaultdict)): The configuration information.
Returns:
str: A human-readable output string detailing the contents of the config. | [
"Nice",
"output",
"string",
"for",
"the",
"config",
"which",
"is",
"a",
"nested",
"defaultdict",
"."
] | train | https://github.com/slarse/pdfebc-core/blob/fc40857bc42365b7434714333e37d7a3487603a0/pdfebc_core/config_utils.py#L190-L203 |
slarse/pdfebc-core | pdfebc_core/config_utils.py | _config_parser_to_defaultdict | def _config_parser_to_defaultdict(config_parser):
"""Convert a ConfigParser to a defaultdict.
Args:
config_parser (ConfigParser): A ConfigParser.
"""
config = defaultdict(defaultdict)
for section, section_content in config_parser.items():
if section != 'DEFAULT':
for opt... | python | def _config_parser_to_defaultdict(config_parser):
"""Convert a ConfigParser to a defaultdict.
Args:
config_parser (ConfigParser): A ConfigParser.
"""
config = defaultdict(defaultdict)
for section, section_content in config_parser.items():
if section != 'DEFAULT':
for opt... | [
"def",
"_config_parser_to_defaultdict",
"(",
"config_parser",
")",
":",
"config",
"=",
"defaultdict",
"(",
"defaultdict",
")",
"for",
"section",
",",
"section_content",
"in",
"config_parser",
".",
"items",
"(",
")",
":",
"if",
"section",
"!=",
"'DEFAULT'",
":",
... | Convert a ConfigParser to a defaultdict.
Args:
config_parser (ConfigParser): A ConfigParser. | [
"Convert",
"a",
"ConfigParser",
"to",
"a",
"defaultdict",
"."
] | train | https://github.com/slarse/pdfebc-core/blob/fc40857bc42365b7434714333e37d7a3487603a0/pdfebc_core/config_utils.py#L205-L216 |
cfobel/ipython-helpers | ipython_helpers/notebook.py | Session.start | def start(self, *args, **kwargs):
'''
Launch IPython notebook server in background process.
Arguments and keyword arguments are passed on to `Popen` call.
By default, notebook server is launched using current working directory
as the notebook directory.
'''
if '... | python | def start(self, *args, **kwargs):
'''
Launch IPython notebook server in background process.
Arguments and keyword arguments are passed on to `Popen` call.
By default, notebook server is launched using current working directory
as the notebook directory.
'''
if '... | [
"def",
"start",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'stderr'",
"in",
"kwargs",
":",
"raise",
"ValueError",
"(",
"'`stderr` must not be specified, since it must be'",
"' monitored to determine which port the notebook '",
"'server is r... | Launch IPython notebook server in background process.
Arguments and keyword arguments are passed on to `Popen` call.
By default, notebook server is launched using current working directory
as the notebook directory. | [
"Launch",
"IPython",
"notebook",
"server",
"in",
"background",
"process",
"."
] | train | https://github.com/cfobel/ipython-helpers/blob/8bc15ed68df96115b84202b5ca23a6ce048d5daf/ipython_helpers/notebook.py#L46-L86 |
cfobel/ipython-helpers | ipython_helpers/notebook.py | Session.open | def open(self, filename=None):
'''
Open a browser tab with the notebook path specified relative to the
notebook directory.
If no filename is specified, open the root of the notebook server.
'''
if filename is None:
address = self.address + 'tree'
else... | python | def open(self, filename=None):
'''
Open a browser tab with the notebook path specified relative to the
notebook directory.
If no filename is specified, open the root of the notebook server.
'''
if filename is None:
address = self.address + 'tree'
else... | [
"def",
"open",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"address",
"=",
"self",
".",
"address",
"+",
"'tree'",
"else",
":",
"notebook_path",
"=",
"self",
".",
"resource_filename",
"(",
"filename",
")",
"... | Open a browser tab with the notebook path specified relative to the
notebook directory.
If no filename is specified, open the root of the notebook server. | [
"Open",
"a",
"browser",
"tab",
"with",
"the",
"notebook",
"path",
"specified",
"relative",
"to",
"the",
"notebook",
"directory",
"."
] | train | https://github.com/cfobel/ipython-helpers/blob/8bc15ed68df96115b84202b5ca23a6ce048d5daf/ipython_helpers/notebook.py#L115-L130 |
cfobel/ipython-helpers | ipython_helpers/notebook.py | SessionManager.launch_from_template | def launch_from_template(self, template_path, notebook_dir=None,
overwrite=False, output_name=None,
create_dir=False, no_browser=False, **kwargs):
'''
Launch a copy of the specified `.ipynb` (template) file in an IPython
notebook session ... | python | def launch_from_template(self, template_path, notebook_dir=None,
overwrite=False, output_name=None,
create_dir=False, no_browser=False, **kwargs):
'''
Launch a copy of the specified `.ipynb` (template) file in an IPython
notebook session ... | [
"def",
"launch_from_template",
"(",
"self",
",",
"template_path",
",",
"notebook_dir",
"=",
"None",
",",
"overwrite",
"=",
"False",
",",
"output_name",
"=",
"None",
",",
"create_dir",
"=",
"False",
",",
"no_browser",
"=",
"False",
",",
"*",
"*",
"kwargs",
... | Launch a copy of the specified `.ipynb` (template) file in an IPython
notebook session for the specified notebook directory.
If an IPython notebook session has already been launched for the
notebook directory, reuse it.
If no notebook directory is specified, use the current working dir... | [
"Launch",
"a",
"copy",
"of",
"the",
"specified",
".",
"ipynb",
"(",
"template",
")",
"file",
"in",
"an",
"IPython",
"notebook",
"session",
"for",
"the",
"specified",
"notebook",
"directory",
"."
] | train | https://github.com/cfobel/ipython-helpers/blob/8bc15ed68df96115b84202b5ca23a6ce048d5daf/ipython_helpers/notebook.py#L171-L221 |
cfobel/ipython-helpers | ipython_helpers/notebook.py | SessionManager.get_session | def get_session(self, notebook_dir=None, no_browser=True, **kwargs):
'''
Return handle to IPython session for specified notebook directory.
If an IPython notebook session has already been launched for the
notebook directory, reuse it. Otherwise, launch a new IPython notebook
se... | python | def get_session(self, notebook_dir=None, no_browser=True, **kwargs):
'''
Return handle to IPython session for specified notebook directory.
If an IPython notebook session has already been launched for the
notebook directory, reuse it. Otherwise, launch a new IPython notebook
se... | [
"def",
"get_session",
"(",
"self",
",",
"notebook_dir",
"=",
"None",
",",
"no_browser",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"notebook_dir",
"in",
"self",
".",
"sessions",
"and",
"self",
".",
"sessions",
"[",
"notebook_dir",
"]",
".",
... | Return handle to IPython session for specified notebook directory.
If an IPython notebook session has already been launched for the
notebook directory, reuse it. Otherwise, launch a new IPython notebook
session.
By default, notebook session is launched using current working
di... | [
"Return",
"handle",
"to",
"IPython",
"session",
"for",
"specified",
"notebook",
"directory",
"."
] | train | https://github.com/cfobel/ipython-helpers/blob/8bc15ed68df96115b84202b5ca23a6ce048d5daf/ipython_helpers/notebook.py#L223-L261 |
edeposit/edeposit.app.fields | edeposit/app/fields/utils.py | normalizeISBN | def normalizeISBN(isbn):
"""
>>> normalizeISBN('978800105473-4')
'978-80-01-05473-4'
>>> normalizeISBN('80978800105473-4')
'80978800105473-4'
>>> normalizeISBN('988800105473-4')
'988800105473-4'
>>> normalizeISBN('978-80-254-94677')
'978-80-254-9467-7'
"""
try:
ret... | python | def normalizeISBN(isbn):
"""
>>> normalizeISBN('978800105473-4')
'978-80-01-05473-4'
>>> normalizeISBN('80978800105473-4')
'80978800105473-4'
>>> normalizeISBN('988800105473-4')
'988800105473-4'
>>> normalizeISBN('978-80-254-94677')
'978-80-254-9467-7'
"""
try:
ret... | [
"def",
"normalizeISBN",
"(",
"isbn",
")",
":",
"try",
":",
"return",
"isbnlib",
".",
"mask",
"(",
"isbnlib",
".",
"canonical",
"(",
"isbn",
")",
")",
"except",
"isbnlib",
".",
"NotValidISBNError",
":",
"return",
"isbn"
] | >>> normalizeISBN('978800105473-4')
'978-80-01-05473-4'
>>> normalizeISBN('80978800105473-4')
'80978800105473-4'
>>> normalizeISBN('988800105473-4')
'988800105473-4'
>>> normalizeISBN('978-80-254-94677')
'978-80-254-9467-7' | [
">>>",
"normalizeISBN",
"(",
"978800105473",
"-",
"4",
")",
"978",
"-",
"80",
"-",
"01",
"-",
"05473",
"-",
"4"
] | train | https://github.com/edeposit/edeposit.app.fields/blob/dfdf1f0bc435e2eac1b55ca9e69f3b29f8153e14/edeposit/app/fields/utils.py#L11-L28 |
jtpaasch/simplygithub | simplygithub/internals/blobs.py | prepare | def prepare(data):
"""Restructure/prepare data about blobs for output."""
sha = data.get("sha")
content = data.get("content")
encoding = data.get("encoding")
return {"sha": sha, "content": content, "encoding": encoding} | python | def prepare(data):
"""Restructure/prepare data about blobs for output."""
sha = data.get("sha")
content = data.get("content")
encoding = data.get("encoding")
return {"sha": sha, "content": content, "encoding": encoding} | [
"def",
"prepare",
"(",
"data",
")",
":",
"sha",
"=",
"data",
".",
"get",
"(",
"\"sha\"",
")",
"content",
"=",
"data",
".",
"get",
"(",
"\"content\"",
")",
"encoding",
"=",
"data",
".",
"get",
"(",
"\"encoding\"",
")",
"return",
"{",
"\"sha\"",
":",
... | Restructure/prepare data about blobs for output. | [
"Restructure",
"/",
"prepare",
"data",
"about",
"blobs",
"for",
"output",
"."
] | train | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/blobs.py#L8-L13 |
jtpaasch/simplygithub | simplygithub/internals/blobs.py | get_blob | def get_blob(profile, sha):
"""Fetch a blob.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
sha
The SHA of th... | python | def get_blob(profile, sha):
"""Fetch a blob.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
sha
The SHA of th... | [
"def",
"get_blob",
"(",
"profile",
",",
"sha",
")",
":",
"resource",
"=",
"\"/blobs/\"",
"+",
"sha",
"data",
"=",
"api",
".",
"get_request",
"(",
"profile",
",",
"resource",
")",
"return",
"prepare",
"(",
"data",
")"
] | Fetch a blob.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
sha
The SHA of the blob to fetch.
Returns:
... | [
"Fetch",
"a",
"blob",
"."
] | train | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/blobs.py#L16-L35 |
jtpaasch/simplygithub | simplygithub/internals/blobs.py | create_blob | def create_blob(profile, content):
"""Create a blob.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
content
T... | python | def create_blob(profile, content):
"""Create a blob.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
content
T... | [
"def",
"create_blob",
"(",
"profile",
",",
"content",
")",
":",
"resource",
"=",
"\"/blobs\"",
"payload",
"=",
"{",
"\"content\"",
":",
"content",
"}",
"data",
"=",
"api",
".",
"post_request",
"(",
"profile",
",",
"resource",
",",
"payload",
")",
"return",... | Create a blob.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
content
The (UTF-8 encoded) content to create in th... | [
"Create",
"a",
"blob",
"."
] | train | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/blobs.py#L38-L58 |
pjuren/pyokit | src/pyokit/datastruct/sequence.py | Sequence.copy | def copy(self):
"""
Copy constructor for Sequence objects.
"""
return Sequence(self.name, self.sequenceData, self.start, self.end,
self.strand, self.remaining, self.meta_data,
self.mutableString) | python | def copy(self):
"""
Copy constructor for Sequence objects.
"""
return Sequence(self.name, self.sequenceData, self.start, self.end,
self.strand, self.remaining, self.meta_data,
self.mutableString) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"Sequence",
"(",
"self",
".",
"name",
",",
"self",
".",
"sequenceData",
",",
"self",
".",
"start",
",",
"self",
".",
"end",
",",
"self",
".",
"strand",
",",
"self",
".",
"remaining",
",",
"self",
".",... | Copy constructor for Sequence objects. | [
"Copy",
"constructor",
"for",
"Sequence",
"objects",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/sequence.py#L127-L133 |
pjuren/pyokit | src/pyokit/datastruct/sequence.py | Sequence.effective_len | def effective_len(self):
"""
Get the length of the sequence if N's are disregarded.
"""
if self._effective_len is None:
self._effective_len = len([nuc for nuc in self.sequenceData
if nuc != "N" and nuc != "n"])
return self._effective_len | python | def effective_len(self):
"""
Get the length of the sequence if N's are disregarded.
"""
if self._effective_len is None:
self._effective_len = len([nuc for nuc in self.sequenceData
if nuc != "N" and nuc != "n"])
return self._effective_len | [
"def",
"effective_len",
"(",
"self",
")",
":",
"if",
"self",
".",
"_effective_len",
"is",
"None",
":",
"self",
".",
"_effective_len",
"=",
"len",
"(",
"[",
"nuc",
"for",
"nuc",
"in",
"self",
".",
"sequenceData",
"if",
"nuc",
"!=",
"\"N\"",
"and",
"nuc"... | Get the length of the sequence if N's are disregarded. | [
"Get",
"the",
"length",
"of",
"the",
"sequence",
"if",
"N",
"s",
"are",
"disregarded",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/sequence.py#L174-L181 |
pjuren/pyokit | src/pyokit/datastruct/sequence.py | Sequence.subsequence | def subsequence(self, start, end):
"""
Extract a subsequence from this sequence object using absolute coordinates
that exist in the same coordinate space as the sequence itself. For
example:
46 --> A--CTGC-TAGC-GATCGACT <-- 62 subsequence(47,52) == CTGC-T
:param start: the index ... | python | def subsequence(self, start, end):
"""
Extract a subsequence from this sequence object using absolute coordinates
that exist in the same coordinate space as the sequence itself. For
example:
46 --> A--CTGC-TAGC-GATCGACT <-- 62 subsequence(47,52) == CTGC-T
:param start: the index ... | [
"def",
"subsequence",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"if",
"(",
"start",
"<",
"self",
".",
"start",
"or",
"start",
">=",
"self",
".",
"end",
"or",
"end",
"<=",
"self",
".",
"start",
"or",
"end",
">",
"self",
".",
"end",
"or",
... | Extract a subsequence from this sequence object using absolute coordinates
that exist in the same coordinate space as the sequence itself. For
example:
46 --> A--CTGC-TAGC-GATCGACT <-- 62 subsequence(47,52) == CTGC-T
:param start: the index marking the start (inclusive) of the
... | [
"Extract",
"a",
"subsequence",
"from",
"this",
"sequence",
"object",
"using",
"absolute",
"coordinates",
"that",
"exist",
"in",
"the",
"same",
"coordinate",
"space",
"as",
"the",
"sequence",
"itself",
".",
"For",
"example",
":"
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/sequence.py#L193-L224 |
pjuren/pyokit | src/pyokit/datastruct/sequence.py | Sequence.relative_subsequence | def relative_subsequence(self, start, end):
"""
Extract a subsequence from this sequence using coordinates that are
relative to the start (relative position 1) and end coordinates of the
sequence. For example:
46 --> A--CTGC-TAGC-GATCGACT <-- 62 subsequence(2,7) == CTGC-T
:param start... | python | def relative_subsequence(self, start, end):
"""
Extract a subsequence from this sequence using coordinates that are
relative to the start (relative position 1) and end coordinates of the
sequence. For example:
46 --> A--CTGC-TAGC-GATCGACT <-- 62 subsequence(2,7) == CTGC-T
:param start... | [
"def",
"relative_subsequence",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"if",
"start",
"<",
"1",
":",
"raise",
"SequenceError",
"(",
"\"invalid start coordinate for subsequence: \"",
"+",
"str",
"(",
"start",
")",
")",
"if",
"end",
">",
"self",
".",
... | Extract a subsequence from this sequence using coordinates that are
relative to the start (relative position 1) and end coordinates of the
sequence. For example:
46 --> A--CTGC-TAGC-GATCGACT <-- 62 subsequence(2,7) == CTGC-T
:param start: the index marking the start (inclusive) of the
... | [
"Extract",
"a",
"subsequence",
"from",
"this",
"sequence",
"using",
"coordinates",
"that",
"are",
"relative",
"to",
"the",
"start",
"(",
"relative",
"position",
"1",
")",
"and",
"end",
"coordinates",
"of",
"the",
"sequence",
".",
"For",
"example",
":"
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/sequence.py#L226-L258 |
pjuren/pyokit | src/pyokit/datastruct/sequence.py | Sequence.gapped_relative_subsequence | def gapped_relative_subsequence(self, start, end):
"""
Extract a subsequence from this sequence using coordinates that are
relative to the start of the sequence (relative position 1) and the number
of nuceltodies in the sequence, including gaps. For example:
46 --> A--CTGC-TAGC-GATCGACT <-- 62 ... | python | def gapped_relative_subsequence(self, start, end):
"""
Extract a subsequence from this sequence using coordinates that are
relative to the start of the sequence (relative position 1) and the number
of nuceltodies in the sequence, including gaps. For example:
46 --> A--CTGC-TAGC-GATCGACT <-- 62 ... | [
"def",
"gapped_relative_subsequence",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"if",
"start",
"<",
"1",
":",
"msg",
"=",
"\"invalid start coordinate for subsequence: \"",
"+",
"str",
"(",
"start",
")",
"raise",
"InvalidSequenceCoordinatesError",
"(",
"msg"... | Extract a subsequence from this sequence using coordinates that are
relative to the start of the sequence (relative position 1) and the number
of nuceltodies in the sequence, including gaps. For example:
46 --> A--CTGC-TAGC-GATCGACT <-- 62 subsequence(2,7) == --CTG | [
"Extract",
"a",
"subsequence",
"from",
"this",
"sequence",
"using",
"coordinates",
"that",
"are",
"relative",
"to",
"the",
"start",
"of",
"the",
"sequence",
"(",
"relative",
"position",
"1",
")",
"and",
"the",
"number",
"of",
"nuceltodies",
"in",
"the",
"seq... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/sequence.py#L260-L285 |
pjuren/pyokit | src/pyokit/datastruct/sequence.py | Sequence.percentNuc | def percentNuc(self, nuc):
"""
return the percentage of the sequence which is equal to the passed nuc.
:param nuc: the nucleotide to compute percentage composition for. There
is no check to make sure this is a valid nucleotide.
:return: the percentage of the sequence that is <nu... | python | def percentNuc(self, nuc):
"""
return the percentage of the sequence which is equal to the passed nuc.
:param nuc: the nucleotide to compute percentage composition for. There
is no check to make sure this is a valid nucleotide.
:return: the percentage of the sequence that is <nu... | [
"def",
"percentNuc",
"(",
"self",
",",
"nuc",
")",
":",
"count",
"=",
"reduce",
"(",
"lambda",
"x",
",",
"y",
":",
"x",
"+",
"1",
"if",
"y",
"==",
"nuc",
"else",
"x",
",",
"self",
".",
"sequenceData",
",",
"0",
")",
"return",
"count",
"/",
"flo... | return the percentage of the sequence which is equal to the passed nuc.
:param nuc: the nucleotide to compute percentage composition for. There
is no check to make sure this is a valid nucleotide.
:return: the percentage of the sequence that is <nuc> | [
"return",
"the",
"percentage",
"of",
"the",
"sequence",
"which",
"is",
"equal",
"to",
"the",
"passed",
"nuc",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/sequence.py#L292-L301 |
pjuren/pyokit | src/pyokit/datastruct/sequence.py | Sequence.similarity | def similarity(self, self_start, self_end, other_start, other_end, other):
"""
Compute the number of matching bases in the subsequences self[start, end]
and other[o_start, o_end]. Note that the subsequences must be the same
length.
:param self_start: start index for sub-sequence in self
... | python | def similarity(self, self_start, self_end, other_start, other_end, other):
"""
Compute the number of matching bases in the subsequences self[start, end]
and other[o_start, o_end]. Note that the subsequences must be the same
length.
:param self_start: start index for sub-sequence in self
... | [
"def",
"similarity",
"(",
"self",
",",
"self_start",
",",
"self_end",
",",
"other_start",
",",
"other_end",
",",
"other",
")",
":",
"assert",
"(",
"self_end",
"-",
"self_start",
"==",
"other_end",
"-",
"other_start",
")",
"count",
"=",
"0",
"for",
"i",
"... | Compute the number of matching bases in the subsequences self[start, end]
and other[o_start, o_end]. Note that the subsequences must be the same
length.
:param self_start: start index for sub-sequence in self
:param self_end: end index for sub-sequence in self
:param other_start: star... | [
"Compute",
"the",
"number",
"of",
"matching",
"bases",
"in",
"the",
"subsequences",
"self",
"[",
"start",
"end",
"]",
"and",
"other",
"[",
"o_start",
"o_end",
"]",
".",
"Note",
"that",
"the",
"subsequences",
"must",
"be",
"the",
"same",
"length",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/sequence.py#L303-L321 |
pjuren/pyokit | src/pyokit/datastruct/sequence.py | Sequence.reverseComplement | def reverseComplement(self, isRNA=None):
"""
Reverse complement this sequence in-place.
:param isRNA: if True, treat this sequence as RNA. If False, treat it as
DNA. If None (default), inspect the sequence and make a
guess as to whether it is RNA or DNA.
"""
... | python | def reverseComplement(self, isRNA=None):
"""
Reverse complement this sequence in-place.
:param isRNA: if True, treat this sequence as RNA. If False, treat it as
DNA. If None (default), inspect the sequence and make a
guess as to whether it is RNA or DNA.
"""
... | [
"def",
"reverseComplement",
"(",
"self",
",",
"isRNA",
"=",
"None",
")",
":",
"isRNA_l",
"=",
"self",
".",
"isRNA",
"(",
")",
"if",
"isRNA",
"is",
"None",
"else",
"isRNA",
"tmp",
"=",
"\"\"",
"for",
"n",
"in",
"self",
".",
"sequenceData",
":",
"if",
... | Reverse complement this sequence in-place.
:param isRNA: if True, treat this sequence as RNA. If False, treat it as
DNA. If None (default), inspect the sequence and make a
guess as to whether it is RNA or DNA. | [
"Reverse",
"complement",
"this",
"sequence",
"in",
"-",
"place",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/sequence.py#L323-L339 |
pjuren/pyokit | src/pyokit/datastruct/sequence.py | Sequence.maskRegion | def maskRegion(self, region):
"""
Replace nucleotides in this sequence in the regions given by Ns
:param region: any object with .start and .end attributes. Co-ords are
zero based and inclusive of both end points. Any other
attributes (e.g. chrom.) are ignored.... | python | def maskRegion(self, region):
"""
Replace nucleotides in this sequence in the regions given by Ns
:param region: any object with .start and .end attributes. Co-ords are
zero based and inclusive of both end points. Any other
attributes (e.g. chrom.) are ignored.... | [
"def",
"maskRegion",
"(",
"self",
",",
"region",
")",
":",
"if",
"region",
".",
"start",
"<",
"0",
"or",
"region",
".",
"end",
"<",
"0",
"or",
"region",
".",
"start",
">",
"len",
"(",
"self",
")",
"or",
"region",
".",
"end",
">",
"len",
"(",
"s... | Replace nucleotides in this sequence in the regions given by Ns
:param region: any object with .start and .end attributes. Co-ords are
zero based and inclusive of both end points. Any other
attributes (e.g. chrom.) are ignored.
:raise SequenceError: if region speci... | [
"Replace",
"nucleotides",
"in",
"this",
"sequence",
"in",
"the",
"regions",
"given",
"by",
"Ns"
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/sequence.py#L384-L408 |
pjuren/pyokit | src/pyokit/datastruct/sequence.py | Sequence.maskRegions | def maskRegions(self, regions, verbose=False):
"""
Mask the given regions in this sequence with Ns.
:param region: iterable of regions to mask. Each region can be any object
with .start and .end attributes. Co-ords are zero based
and inclusive of both end point... | python | def maskRegions(self, regions, verbose=False):
"""
Mask the given regions in this sequence with Ns.
:param region: iterable of regions to mask. Each region can be any object
with .start and .end attributes. Co-ords are zero based
and inclusive of both end point... | [
"def",
"maskRegions",
"(",
"self",
",",
"regions",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"verbose",
":",
"pind",
"=",
"ProgressIndicator",
"(",
"totalToDo",
"=",
"len",
"(",
"regions",
")",
",",
"messagePrefix",
"=",
"\"completed\"",
",",
"messageS... | Mask the given regions in this sequence with Ns.
:param region: iterable of regions to mask. Each region can be any object
with .start and .end attributes. Co-ords are zero based
and inclusive of both end points. Any other attributes
(e.g. chrom.) ar... | [
"Mask",
"the",
"given",
"regions",
"in",
"this",
"sequence",
"with",
"Ns",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/sequence.py#L410-L429 |
pjuren/pyokit | src/pyokit/datastruct/sequence.py | Sequence.split | def split(self, point=None):
"""
Split this sequence into two halves and return them. The original
sequence remains unmodified.
:param point: defines the split point, if None then the centre is used
:return: two Sequence objects -- one for each side
"""
if point is None:
point... | python | def split(self, point=None):
"""
Split this sequence into two halves and return them. The original
sequence remains unmodified.
:param point: defines the split point, if None then the centre is used
:return: two Sequence objects -- one for each side
"""
if point is None:
point... | [
"def",
"split",
"(",
"self",
",",
"point",
"=",
"None",
")",
":",
"if",
"point",
"is",
"None",
":",
"point",
"=",
"len",
"(",
"self",
")",
"/",
"2",
"r1",
"=",
"Sequence",
"(",
"self",
".",
"name",
"+",
"\".1\"",
",",
"self",
".",
"sequenceData",... | Split this sequence into two halves and return them. The original
sequence remains unmodified.
:param point: defines the split point, if None then the centre is used
:return: two Sequence objects -- one for each side | [
"Split",
"this",
"sequence",
"into",
"two",
"halves",
"and",
"return",
"them",
".",
"The",
"original",
"sequence",
"remains",
"unmodified",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/sequence.py#L468-L482 |
pjuren/pyokit | src/pyokit/datastruct/sequence.py | Sequence.clip_end | def clip_end(self, seq, mm_score):
"""
Clip a sequence from the end of this sequence -- we assume the sequence
to be clipped will always begin somewhere in this sequence, but may not
be fully contained. If found, replaced with Ns.
:param seq: sequence to be clipped
:param mm_score: th... | python | def clip_end(self, seq, mm_score):
"""
Clip a sequence from the end of this sequence -- we assume the sequence
to be clipped will always begin somewhere in this sequence, but may not
be fully contained. If found, replaced with Ns.
:param seq: sequence to be clipped
:param mm_score: th... | [
"def",
"clip_end",
"(",
"self",
",",
"seq",
",",
"mm_score",
")",
":",
"lim",
"=",
"mm_score",
"-",
"1",
"other_end",
"=",
"len",
"(",
"seq",
")",
"-",
"1",
"other_start",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"sequen... | Clip a sequence from the end of this sequence -- we assume the sequence
to be clipped will always begin somewhere in this sequence, but may not
be fully contained. If found, replaced with Ns.
:param seq: sequence to be clipped
:param mm_score: the number of matching bases needed to consider a h... | [
"Clip",
"a",
"sequence",
"from",
"the",
"end",
"of",
"this",
"sequence",
"--",
"we",
"assume",
"the",
"sequence",
"to",
"be",
"clipped",
"will",
"always",
"begin",
"somewhere",
"in",
"this",
"sequence",
"but",
"may",
"not",
"be",
"fully",
"contained",
".",... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/sequence.py#L493-L519 |
pjuren/pyokit | src/pyokit/datastruct/sequence.py | Sequence.maskMatch | def maskMatch(self, mask):
"""
Determine whether this sequence matches the given mask.
:param mask: string to match against. Ns in the mask are considered to
match anything in the sequence -- all other chars must
match exactly.
:return: True if the mask match... | python | def maskMatch(self, mask):
"""
Determine whether this sequence matches the given mask.
:param mask: string to match against. Ns in the mask are considered to
match anything in the sequence -- all other chars must
match exactly.
:return: True if the mask match... | [
"def",
"maskMatch",
"(",
"self",
",",
"mask",
")",
":",
"if",
"len",
"(",
"mask",
")",
">",
"len",
"(",
"self",
".",
"sequenceData",
")",
":",
"return",
"False",
"lim",
"=",
"len",
"(",
"mask",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"li... | Determine whether this sequence matches the given mask.
:param mask: string to match against. Ns in the mask are considered to
match anything in the sequence -- all other chars must
match exactly.
:return: True if the mask matches at all places, otherwise false | [
"Determine",
"whether",
"this",
"sequence",
"matches",
"the",
"given",
"mask",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/sequence.py#L548-L565 |
pjuren/pyokit | src/pyokit/datastruct/sequence.py | Sequence.to_fasta_str | def to_fasta_str(self, line_width=50, include_coords=True):
"""
:return: string representation of this sequence object in fasta format
"""
res = ">" + self.name
if include_coords:
res += ":" + str(self.start) + "-" + str(self.end)
res += " (" + str(self.remaining) + ")"
m_str = self.... | python | def to_fasta_str(self, line_width=50, include_coords=True):
"""
:return: string representation of this sequence object in fasta format
"""
res = ">" + self.name
if include_coords:
res += ":" + str(self.start) + "-" + str(self.end)
res += " (" + str(self.remaining) + ")"
m_str = self.... | [
"def",
"to_fasta_str",
"(",
"self",
",",
"line_width",
"=",
"50",
",",
"include_coords",
"=",
"True",
")",
":",
"res",
"=",
"\">\"",
"+",
"self",
".",
"name",
"if",
"include_coords",
":",
"res",
"+=",
"\":\"",
"+",
"str",
"(",
"self",
".",
"start",
"... | :return: string representation of this sequence object in fasta format | [
":",
"return",
":",
"string",
"representation",
"of",
"this",
"sequence",
"object",
"in",
"fasta",
"format"
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/sequence.py#L590-L606 |
nws-cip/zenconf | zenconf/merged_config.py | walk_recursive | def walk_recursive(f, data):
"""
Recursively apply a function to all dicts in a nested dictionary
:param f: Function to apply
:param data: Dictionary (possibly nested) to recursively apply
function to
:return:
"""
results = {}
if isinstance(data, list):
return [walk_recursiv... | python | def walk_recursive(f, data):
"""
Recursively apply a function to all dicts in a nested dictionary
:param f: Function to apply
:param data: Dictionary (possibly nested) to recursively apply
function to
:return:
"""
results = {}
if isinstance(data, list):
return [walk_recursiv... | [
"def",
"walk_recursive",
"(",
"f",
",",
"data",
")",
":",
"results",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"data",
",",
"list",
")",
":",
"return",
"[",
"walk_recursive",
"(",
"f",
",",
"d",
")",
"for",
"d",
"in",
"data",
"]",
"elif",
"isinstance... | Recursively apply a function to all dicts in a nested dictionary
:param f: Function to apply
:param data: Dictionary (possibly nested) to recursively apply
function to
:return: | [
"Recursively",
"apply",
"a",
"function",
"to",
"all",
"dicts",
"in",
"a",
"nested",
"dictionary"
] | train | https://github.com/nws-cip/zenconf/blob/fc96706468c0741fb1b54b2eeb9f9225737e3e36/zenconf/merged_config.py#L47-L70 |
nws-cip/zenconf | zenconf/merged_config.py | dict_merge | def dict_merge(a, b, dict_boundary):
"""
Recursively merges dicts. not just simple a['key'] = b['key'], if
both a and b have a key who's value is a dict then dict_merge is called
on both values and the result stored in the returned dictionary.
Also, if keys contain `self._dict_boundary`, they will ... | python | def dict_merge(a, b, dict_boundary):
"""
Recursively merges dicts. not just simple a['key'] = b['key'], if
both a and b have a key who's value is a dict then dict_merge is called
on both values and the result stored in the returned dictionary.
Also, if keys contain `self._dict_boundary`, they will ... | [
"def",
"dict_merge",
"(",
"a",
",",
"b",
",",
"dict_boundary",
")",
":",
"if",
"not",
"isinstance",
"(",
"b",
",",
"dict",
")",
":",
"return",
"b",
"result",
"=",
"deepcopy",
"(",
"a",
")",
"for",
"k",
",",
"v",
"in",
"b",
".",
"iteritems",
"(",
... | Recursively merges dicts. not just simple a['key'] = b['key'], if
both a and b have a key who's value is a dict then dict_merge is called
on both values and the result stored in the returned dictionary.
Also, if keys contain `self._dict_boundary`, they will be split into
sub dictionaries.
:param a... | [
"Recursively",
"merges",
"dicts",
".",
"not",
"just",
"simple",
"a",
"[",
"key",
"]",
"=",
"b",
"[",
"key",
"]",
"if",
"both",
"a",
"and",
"b",
"have",
"a",
"key",
"who",
"s",
"value",
"is",
"a",
"dict",
"then",
"dict_merge",
"is",
"called",
"on",
... | train | https://github.com/nws-cip/zenconf/blob/fc96706468c0741fb1b54b2eeb9f9225737e3e36/zenconf/merged_config.py#L73-L113 |
nws-cip/zenconf | zenconf/merged_config.py | MergedConfig.add | def add(self, config, strip_app_name=False, filter_by_app_name=False,
key_normalisation_func=default_key_normalisation_func):
"""
Add a dict of config data. Values from later dicts will take precedence
over those added earlier, so the order data is added matters.
Note: Doubl... | python | def add(self, config, strip_app_name=False, filter_by_app_name=False,
key_normalisation_func=default_key_normalisation_func):
"""
Add a dict of config data. Values from later dicts will take precedence
over those added earlier, so the order data is added matters.
Note: Doubl... | [
"def",
"add",
"(",
"self",
",",
"config",
",",
"strip_app_name",
"=",
"False",
",",
"filter_by_app_name",
"=",
"False",
",",
"key_normalisation_func",
"=",
"default_key_normalisation_func",
")",
":",
"config",
"=",
"walk_recursive",
"(",
"key_normalisation_func",
",... | Add a dict of config data. Values from later dicts will take precedence
over those added earlier, so the order data is added matters.
Note: Double underscores can be used to indicate dict key name
boundaries. i.e. if we have a dict like:
{
'logging': {
'leve... | [
"Add",
"a",
"dict",
"of",
"config",
"data",
".",
"Values",
"from",
"later",
"dicts",
"will",
"take",
"precedence",
"over",
"those",
"added",
"earlier",
"so",
"the",
"order",
"data",
"is",
"added",
"matters",
"."
] | train | https://github.com/nws-cip/zenconf/blob/fc96706468c0741fb1b54b2eeb9f9225737e3e36/zenconf/merged_config.py#L160-L209 |
nws-cip/zenconf | zenconf/merged_config.py | MergedConfig.get_merged_config | def get_merged_config(self):
"""
Return all dicts merged so you can access the data
:return: A dict with values merged so later values override earlier
values
"""
merged_config = OrderedDict()
for source in self._sources:
merged_config = dict_merge(me... | python | def get_merged_config(self):
"""
Return all dicts merged so you can access the data
:return: A dict with values merged so later values override earlier
values
"""
merged_config = OrderedDict()
for source in self._sources:
merged_config = dict_merge(me... | [
"def",
"get_merged_config",
"(",
"self",
")",
":",
"merged_config",
"=",
"OrderedDict",
"(",
")",
"for",
"source",
"in",
"self",
".",
"_sources",
":",
"merged_config",
"=",
"dict_merge",
"(",
"merged_config",
",",
"source",
",",
"self",
".",
"_dict_boundary",
... | Return all dicts merged so you can access the data
:return: A dict with values merged so later values override earlier
values | [
"Return",
"all",
"dicts",
"merged",
"so",
"you",
"can",
"access",
"the",
"data",
":",
"return",
":",
"A",
"dict",
"with",
"values",
"merged",
"so",
"later",
"values",
"override",
"earlier",
"values"
] | train | https://github.com/nws-cip/zenconf/blob/fc96706468c0741fb1b54b2eeb9f9225737e3e36/zenconf/merged_config.py#L211-L223 |
flo-compbio/gopca-server | gpserver/config.py | GSConfig.set_param | def set_param(self, name, value):
"""Set a GO-PCA Server parameter.
Parameters
----------
name: str
The parameter name.
value: ?
The parameter value.
"""
if name not in self.param_names:
raise ValueError('No GO-PCA Server param... | python | def set_param(self, name, value):
"""Set a GO-PCA Server parameter.
Parameters
----------
name: str
The parameter name.
value: ?
The parameter value.
"""
if name not in self.param_names:
raise ValueError('No GO-PCA Server param... | [
"def",
"set_param",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"param_names",
":",
"raise",
"ValueError",
"(",
"'No GO-PCA Server parameter named \"%s\"!'",
"%",
"(",
"param",
")",
")",
"self",
".",
"__params",
... | Set a GO-PCA Server parameter.
Parameters
----------
name: str
The parameter name.
value: ?
The parameter value. | [
"Set",
"a",
"GO",
"-",
"PCA",
"Server",
"parameter",
"."
] | train | https://github.com/flo-compbio/gopca-server/blob/4fe396b12c39c0f156ce3bc4538cade54c9d7ffe/gpserver/config.py#L147-L159 |
flo-compbio/gopca-server | gpserver/config.py | GSConfig.set_params | def set_params(self, params):
"""Sets multiple GO-PCA Server parameters using a dictionary.
Parameters
----------
params: dict
Dictionary containing the parameter values.
Returns
-------
None
"""
for k,v in params.iteritems():
... | python | def set_params(self, params):
"""Sets multiple GO-PCA Server parameters using a dictionary.
Parameters
----------
params: dict
Dictionary containing the parameter values.
Returns
-------
None
"""
for k,v in params.iteritems():
... | [
"def",
"set_params",
"(",
"self",
",",
"params",
")",
":",
"for",
"k",
",",
"v",
"in",
"params",
".",
"iteritems",
"(",
")",
":",
"self",
".",
"set_param",
"(",
"k",
",",
"v",
")"
] | Sets multiple GO-PCA Server parameters using a dictionary.
Parameters
----------
params: dict
Dictionary containing the parameter values.
Returns
-------
None | [
"Sets",
"multiple",
"GO",
"-",
"PCA",
"Server",
"parameters",
"using",
"a",
"dictionary",
"."
] | train | https://github.com/flo-compbio/gopca-server/blob/4fe396b12c39c0f156ce3bc4538cade54c9d7ffe/gpserver/config.py#L161-L174 |
flo-compbio/gopca-server | gpserver/config.py | GSConfig.reset_params | def reset_params(self):
"""Reset all parameters to their default values."""
self.__params = dict([p, None] for p in self.param_names)
self.set_params(self.param_defaults) | python | def reset_params(self):
"""Reset all parameters to their default values."""
self.__params = dict([p, None] for p in self.param_names)
self.set_params(self.param_defaults) | [
"def",
"reset_params",
"(",
"self",
")",
":",
"self",
".",
"__params",
"=",
"dict",
"(",
"[",
"p",
",",
"None",
"]",
"for",
"p",
"in",
"self",
".",
"param_names",
")",
"self",
".",
"set_params",
"(",
"self",
".",
"param_defaults",
")"
] | Reset all parameters to their default values. | [
"Reset",
"all",
"parameters",
"to",
"their",
"default",
"values",
"."
] | train | https://github.com/flo-compbio/gopca-server/blob/4fe396b12c39c0f156ce3bc4538cade54c9d7ffe/gpserver/config.py#L176-L179 |
flo-compbio/gopca-server | gpserver/config.py | GSConfig.check | def check(self):
"""Check if the current configuration is valid.
Parameters:
-----------
None
Returns
-------
bool
True iff no problems were found.
"""
passed = True
def check_type(attr, types):
# checks whether... | python | def check(self):
"""Check if the current configuration is valid.
Parameters:
-----------
None
Returns
-------
bool
True iff no problems were found.
"""
passed = True
def check_type(attr, types):
# checks whether... | [
"def",
"check",
"(",
"self",
")",
":",
"passed",
"=",
"True",
"def",
"check_type",
"(",
"attr",
",",
"types",
")",
":",
"# checks whether the parameter has a certain type",
"val",
"=",
"getattr",
"(",
"self",
",",
"attr",
")",
"if",
"not",
"isinstance",
"(",... | Check if the current configuration is valid.
Parameters:
-----------
None
Returns
-------
bool
True iff no problems were found. | [
"Check",
"if",
"the",
"current",
"configuration",
"is",
"valid",
"."
] | train | https://github.com/flo-compbio/gopca-server/blob/4fe396b12c39c0f156ce3bc4538cade54c9d7ffe/gpserver/config.py#L181-L285 |
rocktavious/waybill | waybill/cli.py | waybill.create | def create(cli, command, docker_id):
"""Creates waybill shims from a given command name and docker image"""
content = waybill_template.format(command=command,
docker_id=docker_id)
waybill_dir = cli.get_waybill_dir()
waybill_filename = os.path.joi... | python | def create(cli, command, docker_id):
"""Creates waybill shims from a given command name and docker image"""
content = waybill_template.format(command=command,
docker_id=docker_id)
waybill_dir = cli.get_waybill_dir()
waybill_filename = os.path.joi... | [
"def",
"create",
"(",
"cli",
",",
"command",
",",
"docker_id",
")",
":",
"content",
"=",
"waybill_template",
".",
"format",
"(",
"command",
"=",
"command",
",",
"docker_id",
"=",
"docker_id",
")",
"waybill_dir",
"=",
"cli",
".",
"get_waybill_dir",
"(",
")"... | Creates waybill shims from a given command name and docker image | [
"Creates",
"waybill",
"shims",
"from",
"a",
"given",
"command",
"name",
"and",
"docker",
"image"
] | train | https://github.com/rocktavious/waybill/blob/62630f3ab67d6f253f09fbcde6fa7386acf9c2e8/waybill/cli.py#L57-L65 |
rocktavious/waybill | waybill/cli.py | waybill.load | def load(cli, yaml_filename):
"""Creates waybill shims from a given yaml file definiations"""
"""Expected Definition:
- name: NAME
docker_id: IMAGE
- name: NAME
docker_id: IMAGE
"""
with open(yaml_filename, 'rb') as filehandle:
for waybill ... | python | def load(cli, yaml_filename):
"""Creates waybill shims from a given yaml file definiations"""
"""Expected Definition:
- name: NAME
docker_id: IMAGE
- name: NAME
docker_id: IMAGE
"""
with open(yaml_filename, 'rb') as filehandle:
for waybill ... | [
"def",
"load",
"(",
"cli",
",",
"yaml_filename",
")",
":",
"\"\"\"Expected Definition:\n - name: NAME\n docker_id: IMAGE\n - name: NAME\n docker_id: IMAGE\n \"\"\"",
"with",
"open",
"(",
"yaml_filename",
",",
"'rb'",
")",
"as",
"filehandle",
... | Creates waybill shims from a given yaml file definiations | [
"Creates",
"waybill",
"shims",
"from",
"a",
"given",
"yaml",
"file",
"definiations"
] | train | https://github.com/rocktavious/waybill/blob/62630f3ab67d6f253f09fbcde6fa7386acf9c2e8/waybill/cli.py#L68-L79 |
rocktavious/waybill | waybill/cli.py | waybill.shellinit | def shellinit(cli):
"""Implements the waybill shims in the active shell"""
output = 'eval echo "Initializing Waybills"'
if which('docker') is None:
raise ValueError("Unable to find program 'docker'. Please make sure it is installed and setup properly")
for waybill in cli.get... | python | def shellinit(cli):
"""Implements the waybill shims in the active shell"""
output = 'eval echo "Initializing Waybills"'
if which('docker') is None:
raise ValueError("Unable to find program 'docker'. Please make sure it is installed and setup properly")
for waybill in cli.get... | [
"def",
"shellinit",
"(",
"cli",
")",
":",
"output",
"=",
"'eval echo \"Initializing Waybills\"'",
"if",
"which",
"(",
"'docker'",
")",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Unable to find program 'docker'. Please make sure it is installed and setup properly\"",
... | Implements the waybill shims in the active shell | [
"Implements",
"the",
"waybill",
"shims",
"in",
"the",
"active",
"shell"
] | train | https://github.com/rocktavious/waybill/blob/62630f3ab67d6f253f09fbcde6fa7386acf9c2e8/waybill/cli.py#L94-L101 |
henrysher/kotocore | kotocore/connection.py | ConnectionDetails.service_data | def service_data(self):
"""
Returns all introspected service data.
If the data has been previously accessed, a memoized version of the
data is returned.
:returns: A dict of introspected service data
:rtype: dict
"""
# Lean on the cache first.
if ... | python | def service_data(self):
"""
Returns all introspected service data.
If the data has been previously accessed, a memoized version of the
data is returned.
:returns: A dict of introspected service data
:rtype: dict
"""
# Lean on the cache first.
if ... | [
"def",
"service_data",
"(",
"self",
")",
":",
"# Lean on the cache first.",
"if",
"self",
".",
"_loaded_service_data",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_loaded_service_data",
"# We don't have a cache. Build it.",
"self",
".",
"_loaded_service_data",
"="... | Returns all introspected service data.
If the data has been previously accessed, a memoized version of the
data is returned.
:returns: A dict of introspected service data
:rtype: dict | [
"Returns",
"all",
"introspected",
"service",
"data",
"."
] | train | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/connection.py#L42-L65 |
henrysher/kotocore | kotocore/connection.py | ConnectionDetails.api_version | def api_version(self):
"""
Returns API version introspected from the service data.
If the data has been previously accessed, a memoized version of the
API version is returned.
:returns: The service's version
:rtype: string
"""
# Lean on the cache first.
... | python | def api_version(self):
"""
Returns API version introspected from the service data.
If the data has been previously accessed, a memoized version of the
API version is returned.
:returns: The service's version
:rtype: string
"""
# Lean on the cache first.
... | [
"def",
"api_version",
"(",
"self",
")",
":",
"# Lean on the cache first.",
"if",
"self",
".",
"_api_version",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_api_version",
"# We don't have a cache. Build it.",
"self",
".",
"_api_version",
"=",
"self",
".",
"_in... | Returns API version introspected from the service data.
If the data has been previously accessed, a memoized version of the
API version is returned.
:returns: The service's version
:rtype: string | [
"Returns",
"API",
"version",
"introspected",
"from",
"the",
"service",
"data",
"."
] | train | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/connection.py#L68-L87 |
henrysher/kotocore | kotocore/connection.py | ConnectionFactory.construct_for | def construct_for(self, service_name):
"""
Builds a new, specialized ``Connection`` subclass for a given service.
This will introspect a service, determine all the API calls it has &
constructs a brand new class with those methods on it.
:param service_name: The name of the ser... | python | def construct_for(self, service_name):
"""
Builds a new, specialized ``Connection`` subclass for a given service.
This will introspect a service, determine all the API calls it has &
constructs a brand new class with those methods on it.
:param service_name: The name of the ser... | [
"def",
"construct_for",
"(",
"self",
",",
"service_name",
")",
":",
"# Construct a new ``ConnectionDetails`` (or similar class) for storing",
"# the relevant details about the service & its operations.",
"details",
"=",
"self",
".",
"details_class",
"(",
"service_name",
",",
"sel... | Builds a new, specialized ``Connection`` subclass for a given service.
This will introspect a service, determine all the API calls it has &
constructs a brand new class with those methods on it.
:param service_name: The name of the service to construct a connection
for. Ex. ``sqs``... | [
"Builds",
"a",
"new",
"specialized",
"Connection",
"subclass",
"for",
"a",
"given",
"service",
"."
] | train | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/connection.py#L258-L291 |
sochotnicky/pytrailer | pytrailer.py | getMoviesFromJSON | def getMoviesFromJSON(jsonURL):
"""Main function for this library
Returns list of Movie classes from apple.com/trailers json URL
such as: http://trailers.apple.com/trailers/home/feeds/just_added.json
The Movie classes use lazy loading mechanisms so that data not
directly available from JSON are lo... | python | def getMoviesFromJSON(jsonURL):
"""Main function for this library
Returns list of Movie classes from apple.com/trailers json URL
such as: http://trailers.apple.com/trailers/home/feeds/just_added.json
The Movie classes use lazy loading mechanisms so that data not
directly available from JSON are lo... | [
"def",
"getMoviesFromJSON",
"(",
"jsonURL",
")",
":",
"response",
"=",
"urllib",
".",
"request",
".",
"urlopen",
"(",
"jsonURL",
")",
"jsonData",
"=",
"response",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"objects",
"=",
"json",
".",
"... | Main function for this library
Returns list of Movie classes from apple.com/trailers json URL
such as: http://trailers.apple.com/trailers/home/feeds/just_added.json
The Movie classes use lazy loading mechanisms so that data not
directly available from JSON are loaded on demand. Currently these
laz... | [
"Main",
"function",
"for",
"this",
"library"
] | train | https://github.com/sochotnicky/pytrailer/blob/f5ebcb14a53c32b7545a334191745e208a3cc319/pytrailer.py#L20-L72 |
sochotnicky/pytrailer | pytrailer.py | Movie.get_trailerLinks | def get_trailerLinks(self):
"""Returns dictionary with trailer names as keys and list of
trailer urls as values. Each trailer can have more links due
to different qualities.
Example:
{'Trailer':['url1','url2'],'Featurette':['url1','url2']}
"""
if self._trailerLin... | python | def get_trailerLinks(self):
"""Returns dictionary with trailer names as keys and list of
trailer urls as values. Each trailer can have more links due
to different qualities.
Example:
{'Trailer':['url1','url2'],'Featurette':['url1','url2']}
"""
if self._trailerLin... | [
"def",
"get_trailerLinks",
"(",
"self",
")",
":",
"if",
"self",
".",
"_trailerLinks",
":",
"return",
"self",
".",
"_trailerLinks",
"wip",
"=",
"WebIncParser",
"(",
"\"http://trailers.apple.com\"",
"+",
"self",
".",
"baseURL",
",",
"\"includes/playlists/web.inc\"",
... | Returns dictionary with trailer names as keys and list of
trailer urls as values. Each trailer can have more links due
to different qualities.
Example:
{'Trailer':['url1','url2'],'Featurette':['url1','url2']} | [
"Returns",
"dictionary",
"with",
"trailer",
"names",
"as",
"keys",
"and",
"list",
"of",
"trailer",
"urls",
"as",
"values",
".",
"Each",
"trailer",
"can",
"have",
"more",
"links",
"due",
"to",
"different",
"qualities",
"."
] | train | https://github.com/sochotnicky/pytrailer/blob/f5ebcb14a53c32b7545a334191745e208a3cc319/pytrailer.py#L94-L109 |
sochotnicky/pytrailer | pytrailer.py | Movie.get_poster | def get_poster(self):
"""Returns poster data itself (as in JPEG/GIF/PNG file)"""
if self._posterData:
return self._posterData
response = urllib.request.urlopen(self.posterURL)
self._posterData = response.read()
return self._posterData | python | def get_poster(self):
"""Returns poster data itself (as in JPEG/GIF/PNG file)"""
if self._posterData:
return self._posterData
response = urllib.request.urlopen(self.posterURL)
self._posterData = response.read()
return self._posterData | [
"def",
"get_poster",
"(",
"self",
")",
":",
"if",
"self",
".",
"_posterData",
":",
"return",
"self",
".",
"_posterData",
"response",
"=",
"urllib",
".",
"request",
".",
"urlopen",
"(",
"self",
".",
"posterURL",
")",
"self",
".",
"_posterData",
"=",
"resp... | Returns poster data itself (as in JPEG/GIF/PNG file) | [
"Returns",
"poster",
"data",
"itself",
"(",
"as",
"in",
"JPEG",
"/",
"GIF",
"/",
"PNG",
"file",
")"
] | train | https://github.com/sochotnicky/pytrailer/blob/f5ebcb14a53c32b7545a334191745e208a3cc319/pytrailer.py#L116-L123 |
sochotnicky/pytrailer | pytrailer.py | Movie.get_description | def get_description(self):
"""Returns description text as provided by the studio"""
if self._description:
return self._description
try:
trailerURL= "http://trailers.apple.com%s" % self.baseURL
response = urllib.request.urlopen(trailerURL)
Reader =... | python | def get_description(self):
"""Returns description text as provided by the studio"""
if self._description:
return self._description
try:
trailerURL= "http://trailers.apple.com%s" % self.baseURL
response = urllib.request.urlopen(trailerURL)
Reader =... | [
"def",
"get_description",
"(",
"self",
")",
":",
"if",
"self",
".",
"_description",
":",
"return",
"self",
".",
"_description",
"try",
":",
"trailerURL",
"=",
"\"http://trailers.apple.com%s\"",
"%",
"self",
".",
"baseURL",
"response",
"=",
"urllib",
".",
"requ... | Returns description text as provided by the studio | [
"Returns",
"description",
"text",
"as",
"provided",
"by",
"the",
"studio"
] | train | https://github.com/sochotnicky/pytrailer/blob/f5ebcb14a53c32b7545a334191745e208a3cc319/pytrailer.py#L130-L149 |
sochotnicky/pytrailer | pytrailer.py | WebIncParser.getTrailers | def getTrailers(self):
"""Returns dictionary with trailer names as keys and list of
trailer urls as values. Each trailer can have more links due
to different qualities.
data - HTML page containing Trailer names/links
Example:
{'Trailer':['url1','url2'],'Featurette':['ur... | python | def getTrailers(self):
"""Returns dictionary with trailer names as keys and list of
trailer urls as values. Each trailer can have more links due
to different qualities.
data - HTML page containing Trailer names/links
Example:
{'Trailer':['url1','url2'],'Featurette':['ur... | [
"def",
"getTrailers",
"(",
"self",
")",
":",
"response",
"=",
"urllib",
".",
"request",
".",
"urlopen",
"(",
"self",
".",
"URL",
")",
"logging",
".",
"info",
"(",
"\"Processing: \"",
"+",
"self",
".",
"URL",
")",
"data",
"=",
"response",
".",
"read",
... | Returns dictionary with trailer names as keys and list of
trailer urls as values. Each trailer can have more links due
to different qualities.
data - HTML page containing Trailer names/links
Example:
{'Trailer':['url1','url2'],'Featurette':['url1','url2']} | [
"Returns",
"dictionary",
"with",
"trailer",
"names",
"as",
"keys",
"and",
"list",
"of",
"trailer",
"urls",
"as",
"values",
".",
"Each",
"trailer",
"can",
"have",
"more",
"links",
"due",
"to",
"different",
"qualities",
"."
] | train | https://github.com/sochotnicky/pytrailer/blob/f5ebcb14a53c32b7545a334191745e208a3cc319/pytrailer.py#L195-L215 |
eddiejessup/metropack | metropack/draw.py | _unwrap_one_layer | def _unwrap_one_layer(r, L, n):
"""For a set of points in a 2 dimensional periodic system, extend the set of
points to tile the points at a given period.
Parameters
----------
r: float array, shape (:, 2).
Set of points.
L: float array, shape (2,)
System lengths.
n: integer.... | python | def _unwrap_one_layer(r, L, n):
"""For a set of points in a 2 dimensional periodic system, extend the set of
points to tile the points at a given period.
Parameters
----------
r: float array, shape (:, 2).
Set of points.
L: float array, shape (2,)
System lengths.
n: integer.... | [
"def",
"_unwrap_one_layer",
"(",
"r",
",",
"L",
",",
"n",
")",
":",
"try",
":",
"L",
"[",
"0",
"]",
"except",
"(",
"TypeError",
",",
"IndexError",
")",
":",
"L",
"=",
"np",
".",
"ones",
"(",
"[",
"r",
".",
"shape",
"[",
"1",
"]",
"]",
")",
... | For a set of points in a 2 dimensional periodic system, extend the set of
points to tile the points at a given period.
Parameters
----------
r: float array, shape (:, 2).
Set of points.
L: float array, shape (2,)
System lengths.
n: integer.
Period to unwrap.
Returns... | [
"For",
"a",
"set",
"of",
"points",
"in",
"a",
"2",
"dimensional",
"periodic",
"system",
"extend",
"the",
"set",
"of",
"points",
"to",
"tile",
"the",
"points",
"at",
"a",
"given",
"period",
"."
] | train | https://github.com/eddiejessup/metropack/blob/528b47d0f2f70f39e1490e41433f2da8c8b9d63c/metropack/draw.py#L6-L37 |
eddiejessup/metropack | metropack/draw.py | _unwrap_to_layer | def _unwrap_to_layer(r, L, n=1):
"""For a set of points in a 2 dimensional periodic system, extend the set of
points to tile the points up to to a given period.
Parameters
----------
r: float array, shape (:, 2).
Set of points.
L: float array, shape (2,)
System lengths.
n: i... | python | def _unwrap_to_layer(r, L, n=1):
"""For a set of points in a 2 dimensional periodic system, extend the set of
points to tile the points up to to a given period.
Parameters
----------
r: float array, shape (:, 2).
Set of points.
L: float array, shape (2,)
System lengths.
n: i... | [
"def",
"_unwrap_to_layer",
"(",
"r",
",",
"L",
",",
"n",
"=",
"1",
")",
":",
"rcu",
"=",
"[",
"]",
"for",
"i_n",
"in",
"range",
"(",
"n",
"+",
"1",
")",
":",
"rcu",
".",
"extend",
"(",
"_unwrap_one_layer",
"(",
"r",
",",
"L",
",",
"i_n",
")",... | For a set of points in a 2 dimensional periodic system, extend the set of
points to tile the points up to to a given period.
Parameters
----------
r: float array, shape (:, 2).
Set of points.
L: float array, shape (2,)
System lengths.
n: integer.
Period to unwrap up to.
... | [
"For",
"a",
"set",
"of",
"points",
"in",
"a",
"2",
"dimensional",
"periodic",
"system",
"extend",
"the",
"set",
"of",
"points",
"to",
"tile",
"the",
"points",
"up",
"to",
"to",
"a",
"given",
"period",
"."
] | train | https://github.com/eddiejessup/metropack/blob/528b47d0f2f70f39e1490e41433f2da8c8b9d63c/metropack/draw.py#L40-L62 |
eddiejessup/metropack | metropack/draw.py | draw_medium | def draw_medium(r, R, L, n=1, ax=None):
"""Draw circles representing circles in a two-dimensional periodic system.
Circles may be tiled up to a number of periods.
Parameters
----------
r: float array, shape (:, 2).
Set of points.
R: float
Circle radius.
L: float array, shape... | python | def draw_medium(r, R, L, n=1, ax=None):
"""Draw circles representing circles in a two-dimensional periodic system.
Circles may be tiled up to a number of periods.
Parameters
----------
r: float array, shape (:, 2).
Set of points.
R: float
Circle radius.
L: float array, shape... | [
"def",
"draw_medium",
"(",
"r",
",",
"R",
",",
"L",
",",
"n",
"=",
"1",
",",
"ax",
"=",
"None",
")",
":",
"if",
"ax",
"is",
"None",
":",
"ax",
"=",
"plt",
".",
"gca",
"(",
")",
"for",
"ru",
"in",
"_unwrap_to_layer",
"(",
"r",
",",
"L",
",",... | Draw circles representing circles in a two-dimensional periodic system.
Circles may be tiled up to a number of periods.
Parameters
----------
r: float array, shape (:, 2).
Set of points.
R: float
Circle radius.
L: float array, shape (2,)
System lengths.
n: integer.
... | [
"Draw",
"circles",
"representing",
"circles",
"in",
"a",
"two",
"-",
"dimensional",
"periodic",
"system",
".",
"Circles",
"may",
"be",
"tiled",
"up",
"to",
"a",
"number",
"of",
"periods",
"."
] | train | https://github.com/eddiejessup/metropack/blob/528b47d0f2f70f39e1490e41433f2da8c8b9d63c/metropack/draw.py#L65-L90 |
FujiMakoto/IPS-Vagrant | ips_vagrant/commands/new/__init__.py | cli | def cli(ctx, name, dname, license_key, ips_version, force, enable, ssl, spdy, gzip, cache, install, dev):
"""
Downloads and installs a new instance of the latest Invision Power Suite release.
"""
assert isinstance(ctx, Context)
login_session = ctx.get_login()
log = logging.getLogger('ipsv.new')
... | python | def cli(ctx, name, dname, license_key, ips_version, force, enable, ssl, spdy, gzip, cache, install, dev):
"""
Downloads and installs a new instance of the latest Invision Power Suite release.
"""
assert isinstance(ctx, Context)
login_session = ctx.get_login()
log = logging.getLogger('ipsv.new')
... | [
"def",
"cli",
"(",
"ctx",
",",
"name",
",",
"dname",
",",
"license_key",
",",
"ips_version",
",",
"force",
",",
"enable",
",",
"ssl",
",",
"spdy",
",",
"gzip",
",",
"cache",
",",
"install",
",",
"dev",
")",
":",
"assert",
"isinstance",
"(",
"ctx",
... | Downloads and installs a new instance of the latest Invision Power Suite release. | [
"Downloads",
"and",
"installs",
"a",
"new",
"instance",
"of",
"the",
"latest",
"Invision",
"Power",
"Suite",
"release",
"."
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/commands/new/__init__.py#L49-L266 |
DoWhileGeek/authentise-services | authentise_services/model.py | Model.upload | def upload(self, # pylint: disable=too-many-arguments
path,
name=None,
resize=False,
rotation=False,
callback_url=None,
callback_method=None,
auto_align=False, ):
"""Create a new model resource in the wareh... | python | def upload(self, # pylint: disable=too-many-arguments
path,
name=None,
resize=False,
rotation=False,
callback_url=None,
callback_method=None,
auto_align=False, ):
"""Create a new model resource in the wareh... | [
"def",
"upload",
"(",
"self",
",",
"# pylint: disable=too-many-arguments",
"path",
",",
"name",
"=",
"None",
",",
"resize",
"=",
"False",
",",
"rotation",
"=",
"False",
",",
"callback_url",
"=",
"None",
",",
"callback_method",
"=",
"None",
",",
"auto_align",
... | Create a new model resource in the warehouse and uploads the path contents to it | [
"Create",
"a",
"new",
"model",
"resource",
"in",
"the",
"warehouse",
"and",
"uploads",
"the",
"path",
"contents",
"to",
"it"
] | train | https://github.com/DoWhileGeek/authentise-services/blob/ee32bd7f7de15d3fb24c0a6374640d3a1ec8096d/authentise_services/model.py#L34-L70 |
DoWhileGeek/authentise-services | authentise_services/model.py | Model.download | def download(self, path):
"""downloads a model resource to the path"""
service_get_resp = requests.get(self.location, cookies={"session": self.session})
payload = service_get_resp.json()
self._state = payload["status"]
if self._state != "processed":
raise errors.Reso... | python | def download(self, path):
"""downloads a model resource to the path"""
service_get_resp = requests.get(self.location, cookies={"session": self.session})
payload = service_get_resp.json()
self._state = payload["status"]
if self._state != "processed":
raise errors.Reso... | [
"def",
"download",
"(",
"self",
",",
"path",
")",
":",
"service_get_resp",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"location",
",",
"cookies",
"=",
"{",
"\"session\"",
":",
"self",
".",
"session",
"}",
")",
"payload",
"=",
"service_get_resp",
".",... | downloads a model resource to the path | [
"downloads",
"a",
"model",
"resource",
"to",
"the",
"path"
] | train | https://github.com/DoWhileGeek/authentise-services/blob/ee32bd7f7de15d3fb24c0a6374640d3a1ec8096d/authentise_services/model.py#L72-L83 |
heikomuller/sco-datastore | scodata/modelrun.py | ModelRunState.to_dict | def to_dict(obj):
"""Generate a JSON serialization for the run state object.
Returns
-------
Json-like object
Json serialization of model run state object
"""
# Have text description of state in Json object (for readability)
json_obj = {'type' : repr(... | python | def to_dict(obj):
"""Generate a JSON serialization for the run state object.
Returns
-------
Json-like object
Json serialization of model run state object
"""
# Have text description of state in Json object (for readability)
json_obj = {'type' : repr(... | [
"def",
"to_dict",
"(",
"obj",
")",
":",
"# Have text description of state in Json object (for readability)",
"json_obj",
"=",
"{",
"'type'",
":",
"repr",
"(",
"obj",
")",
"}",
"# Add state-specific elementsTYPE_MODEL_RUN",
"if",
"obj",
".",
"is_failed",
":",
"json_obj",... | Generate a JSON serialization for the run state object.
Returns
-------
Json-like object
Json serialization of model run state object | [
"Generate",
"a",
"JSON",
"serialization",
"for",
"the",
"run",
"state",
"object",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/modelrun.py#L131-L146 |
heikomuller/sco-datastore | scodata/modelrun.py | DefaultModelRunManager.create_data_file_attachment | def create_data_file_attachment(self, identifier, resource_id, filename, mime_type=None):
"""Attach a given data file with a model run. The attached file is
identified by the resource identifier. If a resource with the given
identifier already exists it will be overwritten.
This operati... | python | def create_data_file_attachment(self, identifier, resource_id, filename, mime_type=None):
"""Attach a given data file with a model run. The attached file is
identified by the resource identifier. If a resource with the given
identifier already exists it will be overwritten.
This operati... | [
"def",
"create_data_file_attachment",
"(",
"self",
",",
"identifier",
",",
"resource_id",
",",
"filename",
",",
"mime_type",
"=",
"None",
")",
":",
"# Get model run to ensure that it exists",
"model_run",
"=",
"self",
".",
"get_object",
"(",
"identifier",
")",
"if",... | Attach a given data file with a model run. The attached file is
identified by the resource identifier. If a resource with the given
identifier already exists it will be overwritten.
This operation wil copy the file 'filename' into the attachments
directory for the model run with name 'r... | [
"Attach",
"a",
"given",
"data",
"file",
"with",
"a",
"model",
"run",
".",
"The",
"attached",
"file",
"is",
"identified",
"by",
"the",
"resource",
"identifier",
".",
"If",
"a",
"resource",
"with",
"the",
"given",
"identifier",
"already",
"exists",
"it",
"wi... | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/modelrun.py#L381-L454 |
heikomuller/sco-datastore | scodata/modelrun.py | DefaultModelRunManager.create_object | def create_object(self, name, experiment_id, model_id, argument_defs, arguments=None, properties=None):
"""Create a model run object with the given list of arguments. The
initial state of the object is RUNNING.
Raises ValueError if given arguments are invalid.
Parameters
------... | python | def create_object(self, name, experiment_id, model_id, argument_defs, arguments=None, properties=None):
"""Create a model run object with the given list of arguments. The
initial state of the object is RUNNING.
Raises ValueError if given arguments are invalid.
Parameters
------... | [
"def",
"create_object",
"(",
"self",
",",
"name",
",",
"experiment_id",
",",
"model_id",
",",
"argument_defs",
",",
"arguments",
"=",
"None",
",",
"properties",
"=",
"None",
")",
":",
"# Create a new object identifier.",
"identifier",
"=",
"str",
"(",
"uuid",
... | Create a model run object with the given list of arguments. The
initial state of the object is RUNNING.
Raises ValueError if given arguments are invalid.
Parameters
----------
name : string
User-provided name for the model run
experiment_id : string
... | [
"Create",
"a",
"model",
"run",
"object",
"with",
"the",
"given",
"list",
"of",
"arguments",
".",
"The",
"initial",
"state",
"of",
"the",
"object",
"is",
"RUNNING",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/modelrun.py#L456-L522 |
heikomuller/sco-datastore | scodata/modelrun.py | DefaultModelRunManager.delete_data_file_attachment | def delete_data_file_attachment(self, identifier, resource_id):
"""Delete attached file with given resource identifier from a mode run.
Raise ValueError if an image archive with the given resource identifier
is attached to the model run instead of a data file.
Parameters
------... | python | def delete_data_file_attachment(self, identifier, resource_id):
"""Delete attached file with given resource identifier from a mode run.
Raise ValueError if an image archive with the given resource identifier
is attached to the model run instead of a data file.
Parameters
------... | [
"def",
"delete_data_file_attachment",
"(",
"self",
",",
"identifier",
",",
"resource_id",
")",
":",
"# Get model run to ensure that it exists. If not return False",
"model_run",
"=",
"self",
".",
"get_object",
"(",
"identifier",
")",
"if",
"model_run",
"is",
"None",
":"... | Delete attached file with given resource identifier from a mode run.
Raise ValueError if an image archive with the given resource identifier
is attached to the model run instead of a data file.
Parameters
----------
identifier : string
Unique model run identifier
... | [
"Delete",
"attached",
"file",
"with",
"given",
"resource",
"identifier",
"from",
"a",
"mode",
"run",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/modelrun.py#L524-L555 |
heikomuller/sco-datastore | scodata/modelrun.py | DefaultModelRunManager.from_dict | def from_dict(self, document):
"""Create model run object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
PredictionHandle
Handle for model run object
"""... | python | def from_dict(self, document):
"""Create model run object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
PredictionHandle
Handle for model run object
"""... | [
"def",
"from_dict",
"(",
"self",
",",
"document",
")",
":",
"# Get object identifier from Json document",
"identifier",
"=",
"str",
"(",
"document",
"[",
"'_id'",
"]",
")",
"# Directories are simply named by object identifier",
"directory",
"=",
"os",
".",
"path",
"."... | Create model run object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
PredictionHandle
Handle for model run object | [
"Create",
"model",
"run",
"object",
"from",
"JSON",
"document",
"retrieved",
"from",
"database",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/modelrun.py#L557-L594 |
heikomuller/sco-datastore | scodata/modelrun.py | DefaultModelRunManager.get_data_file_attachment | def get_data_file_attachment(self, identifier, resource_id):
"""Get path to attached data file with given resource identifer. If no
data file with given id exists the result will be None.
Raise ValueError if an image archive with the given resource identifier
is attached to the model ru... | python | def get_data_file_attachment(self, identifier, resource_id):
"""Get path to attached data file with given resource identifer. If no
data file with given id exists the result will be None.
Raise ValueError if an image archive with the given resource identifier
is attached to the model ru... | [
"def",
"get_data_file_attachment",
"(",
"self",
",",
"identifier",
",",
"resource_id",
")",
":",
"# Get model run to ensure that it exists. If not return None",
"model_run",
"=",
"self",
".",
"get_object",
"(",
"identifier",
")",
"if",
"model_run",
"is",
"None",
":",
... | Get path to attached data file with given resource identifer. If no
data file with given id exists the result will be None.
Raise ValueError if an image archive with the given resource identifier
is attached to the model run instead of a data file.
Parameters
----------
... | [
"Get",
"path",
"to",
"attached",
"data",
"file",
"with",
"given",
"resource",
"identifer",
".",
"If",
"no",
"data",
"file",
"with",
"given",
"id",
"exists",
"the",
"result",
"will",
"be",
"None",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/modelrun.py#L596-L625 |
heikomuller/sco-datastore | scodata/modelrun.py | DefaultModelRunManager.to_dict | def to_dict(self, model_run):
"""Create a Json-like dictionary for a model run object. Extends the
basic object with run state, arguments, and optional prediction results
or error descriptions.
Parameters
----------
model_run : PredictionHandle
Returns
-... | python | def to_dict(self, model_run):
"""Create a Json-like dictionary for a model run object. Extends the
basic object with run state, arguments, and optional prediction results
or error descriptions.
Parameters
----------
model_run : PredictionHandle
Returns
-... | [
"def",
"to_dict",
"(",
"self",
",",
"model_run",
")",
":",
"# Get the basic Json object from the super class",
"json_obj",
"=",
"super",
"(",
"DefaultModelRunManager",
",",
"self",
")",
".",
"to_dict",
"(",
"model_run",
")",
"# Add run state",
"json_obj",
"[",
"'sta... | Create a Json-like dictionary for a model run object. Extends the
basic object with run state, arguments, and optional prediction results
or error descriptions.
Parameters
----------
model_run : PredictionHandle
Returns
-------
(JSON)
Json-li... | [
"Create",
"a",
"Json",
"-",
"like",
"dictionary",
"for",
"a",
"model",
"run",
"object",
".",
"Extends",
"the",
"basic",
"object",
"with",
"run",
"state",
"arguments",
"and",
"optional",
"prediction",
"results",
"or",
"error",
"descriptions",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/modelrun.py#L627-L658 |
heikomuller/sco-datastore | scodata/modelrun.py | DefaultModelRunManager.update_state | def update_state(self, identifier, state):
"""Update state of identified model run.
Raises exception if state change results in invalid run life cycle.
Parameters
----------
identifier : string
Unique model run identifier
state : ModelRunState
Ob... | python | def update_state(self, identifier, state):
"""Update state of identified model run.
Raises exception if state change results in invalid run life cycle.
Parameters
----------
identifier : string
Unique model run identifier
state : ModelRunState
Ob... | [
"def",
"update_state",
"(",
"self",
",",
"identifier",
",",
"state",
")",
":",
"# Get model run to ensure that it exists",
"model_run",
"=",
"self",
".",
"get_object",
"(",
"identifier",
")",
"if",
"model_run",
"is",
"None",
":",
"return",
"None",
"# Set timestamp... | Update state of identified model run.
Raises exception if state change results in invalid run life cycle.
Parameters
----------
identifier : string
Unique model run identifier
state : ModelRunState
Object representing new run state
Returns
... | [
"Update",
"state",
"of",
"identified",
"model",
"run",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/modelrun.py#L660-L707 |
OpenVolunteeringPlatform/django-ovp-projects | ovp_projects/views/project.py | ProjectResourceViewSet.partial_update | def partial_update(self, request, *args, **kwargs):
""" We do not include the mixin as we want only PATCH and no PUT """
instance = self.get_object()
serializer = self.get_serializer(instance, data=request.data, partial=True, context=self.get_serializer_context())
serializer.is_valid(raise_exception=Tru... | python | def partial_update(self, request, *args, **kwargs):
""" We do not include the mixin as we want only PATCH and no PUT """
instance = self.get_object()
serializer = self.get_serializer(instance, data=request.data, partial=True, context=self.get_serializer_context())
serializer.is_valid(raise_exception=Tru... | [
"def",
"partial_update",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
"=",
"self",
".",
"get_object",
"(",
")",
"serializer",
"=",
"self",
".",
"get_serializer",
"(",
"instance",
",",
"data",
"=",
"reque... | We do not include the mixin as we want only PATCH and no PUT | [
"We",
"do",
"not",
"include",
"the",
"mixin",
"as",
"we",
"want",
"only",
"PATCH",
"and",
"no",
"PUT"
] | train | https://github.com/OpenVolunteeringPlatform/django-ovp-projects/blob/239e27027ca99c7b44ee4f30bf55d06439d49251/ovp_projects/views/project.py#L46-L57 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/runner/connection_plugins/ssh.py | Connection.connect | def connect(self):
''' connect to the remote host '''
vvv("ESTABLISH CONNECTION FOR USER: %s" % self.runner.remote_user, host=self.host)
self.common_args = []
extra_args = C.ANSIBLE_SSH_ARGS
if extra_args is not None:
self.common_args += shlex.split(extra_args)
... | python | def connect(self):
''' connect to the remote host '''
vvv("ESTABLISH CONNECTION FOR USER: %s" % self.runner.remote_user, host=self.host)
self.common_args = []
extra_args = C.ANSIBLE_SSH_ARGS
if extra_args is not None:
self.common_args += shlex.split(extra_args)
... | [
"def",
"connect",
"(",
"self",
")",
":",
"vvv",
"(",
"\"ESTABLISH CONNECTION FOR USER: %s\"",
"%",
"self",
".",
"runner",
".",
"remote_user",
",",
"host",
"=",
"self",
".",
"host",
")",
"self",
".",
"common_args",
"=",
"[",
"]",
"extra_args",
"=",
"C",
"... | connect to the remote host | [
"connect",
"to",
"the",
"remote",
"host"
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/connection_plugins/ssh.py#L39-L65 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/runner/connection_plugins/ssh.py | Connection.exec_command | def exec_command(self, cmd, tmp_path, sudo_user,sudoable=False, executable='/bin/sh'):
''' run a command on the remote host '''
ssh_cmd = self._password_cmd()
ssh_cmd += ["ssh", "-tt", "-q"] + self.common_args + [self.host]
if not self.runner.sudo or not sudoable:
if execut... | python | def exec_command(self, cmd, tmp_path, sudo_user,sudoable=False, executable='/bin/sh'):
''' run a command on the remote host '''
ssh_cmd = self._password_cmd()
ssh_cmd += ["ssh", "-tt", "-q"] + self.common_args + [self.host]
if not self.runner.sudo or not sudoable:
if execut... | [
"def",
"exec_command",
"(",
"self",
",",
"cmd",
",",
"tmp_path",
",",
"sudo_user",
",",
"sudoable",
"=",
"False",
",",
"executable",
"=",
"'/bin/sh'",
")",
":",
"ssh_cmd",
"=",
"self",
".",
"_password_cmd",
"(",
")",
"ssh_cmd",
"+=",
"[",
"\"ssh\"",
",",... | run a command on the remote host | [
"run",
"a",
"command",
"on",
"the",
"remote",
"host"
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/connection_plugins/ssh.py#L85-L157 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.