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 |
|---|---|---|---|---|---|---|---|---|---|---|
andrewda/frc-livescore | livescore/simpleocr_utils/processor.py | ProcessorStack.set_parameters | def set_parameters(self, **args):
"""sets to all wrapped processors"""
not_used = set()
not_given = set()
for p in self.processors:
nu, ng = p.set_parameters(**args)
not_used = not_used.union(nu)
not_given = not_given.union(ng)
return not_used,... | python | def set_parameters(self, **args):
"""sets to all wrapped processors"""
not_used = set()
not_given = set()
for p in self.processors:
nu, ng = p.set_parameters(**args)
not_used = not_used.union(nu)
not_given = not_given.union(ng)
return not_used,... | [
"def",
"set_parameters",
"(",
"self",
",",
"*",
"*",
"args",
")",
":",
"not_used",
"=",
"set",
"(",
")",
"not_given",
"=",
"set",
"(",
")",
"for",
"p",
"in",
"self",
".",
"processors",
":",
"nu",
",",
"ng",
"=",
"p",
".",
"set_parameters",
"(",
"... | sets to all wrapped processors | [
"sets",
"to",
"all",
"wrapped",
"processors"
] | train | https://github.com/andrewda/frc-livescore/blob/71594cd6d2c8b6c5feb3889bb05552d09b8128b1/livescore/simpleocr_utils/processor.py#L137-L145 |
daskol/nls | nls/animation.py | AbstractAnimation.render | def render(self, filename):
"""Perform initialization of render, set quality and size video attributes and then call template method that
is defined in child class.
"""
self.elapsed_time = -time()
dpi = 100
fig = figure(figsize=(16, 9), dpi=dpi)
with self.writer.s... | python | def render(self, filename):
"""Perform initialization of render, set quality and size video attributes and then call template method that
is defined in child class.
"""
self.elapsed_time = -time()
dpi = 100
fig = figure(figsize=(16, 9), dpi=dpi)
with self.writer.s... | [
"def",
"render",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"elapsed_time",
"=",
"-",
"time",
"(",
")",
"dpi",
"=",
"100",
"fig",
"=",
"figure",
"(",
"figsize",
"=",
"(",
"16",
",",
"9",
")",
",",
"dpi",
"=",
"dpi",
")",
"with",
"self... | Perform initialization of render, set quality and size video attributes and then call template method that
is defined in child class. | [
"Perform",
"initialization",
"of",
"render",
"set",
"quality",
"and",
"size",
"video",
"attributes",
"and",
"then",
"call",
"template",
"method",
"that",
"is",
"defined",
"in",
"child",
"class",
"."
] | train | https://github.com/daskol/nls/blob/00bb4555e4f56e222dc6f54faf2e286567519626/nls/animation.py#L30-L41 |
daskol/nls | nls/animation.py | AbstractAnimation.report | def report(self):
"""Prints in standard output report about animation rendering. Namely, it prints seconds spent, number of
frames and step size that is used in functional animation.
"""
message = 'Elapsed in {0} seconds with {1} frames and {2} step.'
print(message.format(self.el... | python | def report(self):
"""Prints in standard output report about animation rendering. Namely, it prints seconds spent, number of
frames and step size that is used in functional animation.
"""
message = 'Elapsed in {0} seconds with {1} frames and {2} step.'
print(message.format(self.el... | [
"def",
"report",
"(",
"self",
")",
":",
"message",
"=",
"'Elapsed in {0} seconds with {1} frames and {2} step.'",
"print",
"(",
"message",
".",
"format",
"(",
"self",
".",
"elapsed_time",
",",
"self",
".",
"frames",
",",
"self",
".",
"step",
")",
")"
] | Prints in standard output report about animation rendering. Namely, it prints seconds spent, number of
frames and step size that is used in functional animation. | [
"Prints",
"in",
"standard",
"output",
"report",
"about",
"animation",
"rendering",
".",
"Namely",
"it",
"prints",
"seconds",
"spent",
"number",
"of",
"frames",
"and",
"step",
"size",
"that",
"is",
"used",
"in",
"functional",
"animation",
"."
] | train | https://github.com/daskol/nls/blob/00bb4555e4f56e222dc6f54faf2e286567519626/nls/animation.py#L48-L53 |
pytroll/posttroll | posttroll/subscriber.py | Subscriber.add | def add(self, address, topics=None):
"""Add *address* to the subscribing list for *topics*.
It topics is None we will subscibe to already specified topics.
"""
with self._lock:
if address in self.addresses:
return False
topics = self._magickfy_to... | python | def add(self, address, topics=None):
"""Add *address* to the subscribing list for *topics*.
It topics is None we will subscibe to already specified topics.
"""
with self._lock:
if address in self.addresses:
return False
topics = self._magickfy_to... | [
"def",
"add",
"(",
"self",
",",
"address",
",",
"topics",
"=",
"None",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"address",
"in",
"self",
".",
"addresses",
":",
"return",
"False",
"topics",
"=",
"self",
".",
"_magickfy_topics",
"(",
"topics",
... | Add *address* to the subscribing list for *topics*.
It topics is None we will subscibe to already specified topics. | [
"Add",
"*",
"address",
"*",
"to",
"the",
"subscribing",
"list",
"for",
"*",
"topics",
"*",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/subscriber.py#L90-L110 |
pytroll/posttroll | posttroll/subscriber.py | Subscriber.remove | def remove(self, address):
"""Remove *address* from the subscribing list for *topics*.
"""
with self._lock:
try:
subscriber = self.addr_sub[address]
except KeyError:
return False
LOGGER.info("Subscriber removing address %s", str... | python | def remove(self, address):
"""Remove *address* from the subscribing list for *topics*.
"""
with self._lock:
try:
subscriber = self.addr_sub[address]
except KeyError:
return False
LOGGER.info("Subscriber removing address %s", str... | [
"def",
"remove",
"(",
"self",
",",
"address",
")",
":",
"with",
"self",
".",
"_lock",
":",
"try",
":",
"subscriber",
"=",
"self",
".",
"addr_sub",
"[",
"address",
"]",
"except",
"KeyError",
":",
"return",
"False",
"LOGGER",
".",
"info",
"(",
"\"Subscri... | Remove *address* from the subscribing list for *topics*. | [
"Remove",
"*",
"address",
"*",
"from",
"the",
"subscribing",
"list",
"for",
"*",
"topics",
"*",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/subscriber.py#L112-L126 |
pytroll/posttroll | posttroll/subscriber.py | Subscriber.update | def update(self, addresses):
"""Updating with a set of addresses.
"""
if isinstance(addresses, six.string_types):
addresses = [addresses, ]
s0_, s1_ = set(self.addresses), set(addresses)
sr_, sa_ = s0_.difference(s1_), s1_.difference(s0_)
for a__ in sr_:
... | python | def update(self, addresses):
"""Updating with a set of addresses.
"""
if isinstance(addresses, six.string_types):
addresses = [addresses, ]
s0_, s1_ = set(self.addresses), set(addresses)
sr_, sa_ = s0_.difference(s1_), s1_.difference(s0_)
for a__ in sr_:
... | [
"def",
"update",
"(",
"self",
",",
"addresses",
")",
":",
"if",
"isinstance",
"(",
"addresses",
",",
"six",
".",
"string_types",
")",
":",
"addresses",
"=",
"[",
"addresses",
",",
"]",
"s0_",
",",
"s1_",
"=",
"set",
"(",
"self",
".",
"addresses",
")"... | Updating with a set of addresses. | [
"Updating",
"with",
"a",
"set",
"of",
"addresses",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/subscriber.py#L128-L139 |
pytroll/posttroll | posttroll/subscriber.py | Subscriber.add_hook_sub | def add_hook_sub(self, address, topics, callback):
"""Specify a *callback* in the same stream (thread) as the main receive
loop. The callback will be called with the received messages from the
specified subscription.
Good for operations, which is required to be done in the same thread a... | python | def add_hook_sub(self, address, topics, callback):
"""Specify a *callback* in the same stream (thread) as the main receive
loop. The callback will be called with the received messages from the
specified subscription.
Good for operations, which is required to be done in the same thread a... | [
"def",
"add_hook_sub",
"(",
"self",
",",
"address",
",",
"topics",
",",
"callback",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"Subscriber adding SUB hook %s for topics %s\"",
",",
"str",
"(",
"address",
")",
",",
"str",
"(",
"topics",
")",
")",
"socket",
"=",
... | Specify a *callback* in the same stream (thread) as the main receive
loop. The callback will be called with the received messages from the
specified subscription.
Good for operations, which is required to be done in the same thread as
the main recieve loop (e.q operations on the underly... | [
"Specify",
"a",
"*",
"callback",
"*",
"in",
"the",
"same",
"stream",
"(",
"thread",
")",
"as",
"the",
"main",
"receive",
"loop",
".",
"The",
"callback",
"will",
"be",
"called",
"with",
"the",
"received",
"messages",
"from",
"the",
"specified",
"subscriptio... | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/subscriber.py#L141-L155 |
pytroll/posttroll | posttroll/subscriber.py | Subscriber.add_hook_pull | def add_hook_pull(self, address, callback):
"""Same as above, but with a PULL socket.
(e.g good for pushed 'inproc' messages from another thread).
"""
LOGGER.info("Subscriber adding PULL hook %s", str(address))
socket = get_context().socket(PULL)
socket.connect(address)
... | python | def add_hook_pull(self, address, callback):
"""Same as above, but with a PULL socket.
(e.g good for pushed 'inproc' messages from another thread).
"""
LOGGER.info("Subscriber adding PULL hook %s", str(address))
socket = get_context().socket(PULL)
socket.connect(address)
... | [
"def",
"add_hook_pull",
"(",
"self",
",",
"address",
",",
"callback",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"Subscriber adding PULL hook %s\"",
",",
"str",
"(",
"address",
")",
")",
"socket",
"=",
"get_context",
"(",
")",
".",
"socket",
"(",
"PULL",
")",... | Same as above, but with a PULL socket.
(e.g good for pushed 'inproc' messages from another thread). | [
"Same",
"as",
"above",
"but",
"with",
"a",
"PULL",
"socket",
".",
"(",
"e",
".",
"g",
"good",
"for",
"pushed",
"inproc",
"messages",
"from",
"another",
"thread",
")",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/subscriber.py#L157-L164 |
pytroll/posttroll | posttroll/subscriber.py | Subscriber._add_hook | def _add_hook(self, socket, callback):
"""Generic hook. The passed socket has to be "receive only".
"""
self._hooks.append(socket)
self._hooks_cb[socket] = callback
if self.poller:
self.poller.register(socket, POLLIN) | python | def _add_hook(self, socket, callback):
"""Generic hook. The passed socket has to be "receive only".
"""
self._hooks.append(socket)
self._hooks_cb[socket] = callback
if self.poller:
self.poller.register(socket, POLLIN) | [
"def",
"_add_hook",
"(",
"self",
",",
"socket",
",",
"callback",
")",
":",
"self",
".",
"_hooks",
".",
"append",
"(",
"socket",
")",
"self",
".",
"_hooks_cb",
"[",
"socket",
"]",
"=",
"callback",
"if",
"self",
".",
"poller",
":",
"self",
".",
"poller... | Generic hook. The passed socket has to be "receive only". | [
"Generic",
"hook",
".",
"The",
"passed",
"socket",
"has",
"to",
"be",
"receive",
"only",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/subscriber.py#L166-L172 |
pytroll/posttroll | posttroll/subscriber.py | Subscriber.recv | def recv(self, timeout=None):
"""Receive, optionally with *timeout* in seconds.
"""
if timeout:
timeout *= 1000.
for sub in list(self.subscribers) + self._hooks:
self.poller.register(sub, POLLIN)
self._loop = True
try:
while self._loop... | python | def recv(self, timeout=None):
"""Receive, optionally with *timeout* in seconds.
"""
if timeout:
timeout *= 1000.
for sub in list(self.subscribers) + self._hooks:
self.poller.register(sub, POLLIN)
self._loop = True
try:
while self._loop... | [
"def",
"recv",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"timeout",
":",
"timeout",
"*=",
"1000.",
"for",
"sub",
"in",
"list",
"(",
"self",
".",
"subscribers",
")",
"+",
"self",
".",
"_hooks",
":",
"self",
".",
"poller",
".",
"regis... | Receive, optionally with *timeout* in seconds. | [
"Receive",
"optionally",
"with",
"*",
"timeout",
"*",
"in",
"seconds",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/subscriber.py#L186-L223 |
pytroll/posttroll | posttroll/subscriber.py | Subscriber.close | def close(self):
"""Close the subscriber: stop it and close the local subscribers.
"""
self.stop()
for sub in list(self.subscribers) + self._hooks:
try:
sub.setsockopt(LINGER, 1)
sub.close()
except ZMQError:
pass | python | def close(self):
"""Close the subscriber: stop it and close the local subscribers.
"""
self.stop()
for sub in list(self.subscribers) + self._hooks:
try:
sub.setsockopt(LINGER, 1)
sub.close()
except ZMQError:
pass | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"stop",
"(",
")",
"for",
"sub",
"in",
"list",
"(",
"self",
".",
"subscribers",
")",
"+",
"self",
".",
"_hooks",
":",
"try",
":",
"sub",
".",
"setsockopt",
"(",
"LINGER",
",",
"1",
")",
"sub",
... | Close the subscriber: stop it and close the local subscribers. | [
"Close",
"the",
"subscriber",
":",
"stop",
"it",
"and",
"close",
"the",
"local",
"subscribers",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/subscriber.py#L233-L242 |
pytroll/posttroll | posttroll/subscriber.py | Subscriber._magickfy_topics | def _magickfy_topics(topics):
"""Add the magick to the topics if missing.
"""
# If topic does not start with messages._MAGICK (pytroll:/), it will be
# prepended.
if topics is None:
return None
if isinstance(topics, six.string_types):
topics = [top... | python | def _magickfy_topics(topics):
"""Add the magick to the topics if missing.
"""
# If topic does not start with messages._MAGICK (pytroll:/), it will be
# prepended.
if topics is None:
return None
if isinstance(topics, six.string_types):
topics = [top... | [
"def",
"_magickfy_topics",
"(",
"topics",
")",
":",
"# If topic does not start with messages._MAGICK (pytroll:/), it will be",
"# prepended.",
"if",
"topics",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"topics",
",",
"six",
".",
"string_types",
")",
... | Add the magick to the topics if missing. | [
"Add",
"the",
"magick",
"to",
"the",
"topics",
"if",
"missing",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/subscriber.py#L245-L262 |
pytroll/posttroll | posttroll/subscriber.py | NSSubscriber.start | def start(self):
"""Start the subscriber.
"""
def _get_addr_loop(service, timeout):
"""Try to get the address of *service* until for *timeout* seconds.
"""
then = datetime.now() + timedelta(seconds=timeout)
while datetime.now() < then:
... | python | def start(self):
"""Start the subscriber.
"""
def _get_addr_loop(service, timeout):
"""Try to get the address of *service* until for *timeout* seconds.
"""
then = datetime.now() + timedelta(seconds=timeout)
while datetime.now() < then:
... | [
"def",
"start",
"(",
"self",
")",
":",
"def",
"_get_addr_loop",
"(",
"service",
",",
"timeout",
")",
":",
"\"\"\"Try to get the address of *service* until for *timeout* seconds.\n \"\"\"",
"then",
"=",
"datetime",
".",
"now",
"(",
")",
"+",
"timedelta",
"("... | Start the subscriber. | [
"Start",
"the",
"subscriber",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/subscriber.py#L306-L343 |
pytroll/posttroll | posttroll/subscriber.py | _AddressListener.handle_msg | def handle_msg(self, msg):
"""handle the message *msg*.
"""
addr_ = msg.data["URI"]
status = msg.data.get('status', True)
if status:
service = msg.data.get('service')
for service in self.services:
if not service or service in service:
... | python | def handle_msg(self, msg):
"""handle the message *msg*.
"""
addr_ = msg.data["URI"]
status = msg.data.get('status', True)
if status:
service = msg.data.get('service')
for service in self.services:
if not service or service in service:
... | [
"def",
"handle_msg",
"(",
"self",
",",
"msg",
")",
":",
"addr_",
"=",
"msg",
".",
"data",
"[",
"\"URI\"",
"]",
"status",
"=",
"msg",
".",
"data",
".",
"get",
"(",
"'status'",
",",
"True",
")",
"if",
"status",
":",
"service",
"=",
"msg",
".",
"dat... | handle the message *msg*. | [
"handle",
"the",
"message",
"*",
"msg",
"*",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/subscriber.py#L399-L414 |
thespacedoctor/sherlock | sherlock/transient_classifier.py | transient_classifier.classify | def classify(self):
"""
*classify the transients selected from the transient selection query in the settings file or passed in via the CL or other code*
**Return:**
- ``crossmatches`` -- list of dictionaries of crossmatched associated sources
- ``classifications`` -- the... | python | def classify(self):
"""
*classify the transients selected from the transient selection query in the settings file or passed in via the CL or other code*
**Return:**
- ``crossmatches`` -- list of dictionaries of crossmatched associated sources
- ``classifications`` -- the... | [
"def",
"classify",
"(",
"self",
")",
":",
"global",
"theseBatches",
"global",
"crossmatchArray",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``classify`` method'",
")",
"remaining",
"=",
"1",
"# THE COLUMN MAPS - WHICH COLUMNS IN THE CATALOGUE TABLES = RA, DEC,",
... | *classify the transients selected from the transient selection query in the settings file or passed in via the CL or other code*
**Return:**
- ``crossmatches`` -- list of dictionaries of crossmatched associated sources
- ``classifications`` -- the classifications assigned to the transie... | [
"*",
"classify",
"the",
"transients",
"selected",
"from",
"the",
"transient",
"selection",
"query",
"in",
"the",
"settings",
"file",
"or",
"passed",
"in",
"via",
"the",
"CL",
"or",
"other",
"code",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L191-L438 |
thespacedoctor/sherlock | sherlock/transient_classifier.py | transient_classifier._get_transient_metadata_from_database_list | def _get_transient_metadata_from_database_list(
self):
"""use the transient query in the settings file to generate a list of transients to corssmatch and classify
**Return:**
- ``transientsMetadataList``
.. todo ::
- update key arguments values and definit... | python | def _get_transient_metadata_from_database_list(
self):
"""use the transient query in the settings file to generate a list of transients to corssmatch and classify
**Return:**
- ``transientsMetadataList``
.. todo ::
- update key arguments values and definit... | [
"def",
"_get_transient_metadata_from_database_list",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_get_transient_metadata_from_database_list`` method'",
")",
"sqlQuery",
"=",
"self",
".",
"settings",
"[",
"\"database settings\"",
"]",
"["... | use the transient query in the settings file to generate a list of transients to corssmatch and classify
**Return:**
- ``transientsMetadataList``
.. todo ::
- update key arguments values and definitions with defaults
- update return values and definitions
... | [
"use",
"the",
"transient",
"query",
"in",
"the",
"settings",
"file",
"to",
"generate",
"a",
"list",
"of",
"transients",
"to",
"corssmatch",
"and",
"classify"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L440-L477 |
thespacedoctor/sherlock | sherlock/transient_classifier.py | transient_classifier._update_ned_stream | def _update_ned_stream(
self,
transientsMetadataList
):
""" update the NED stream within the catalogues database at the locations of the transients
**Key Arguments:**
- ``transientsMetadataList`` -- the list of transient metadata lifted from the database.
.. tod... | python | def _update_ned_stream(
self,
transientsMetadataList
):
""" update the NED stream within the catalogues database at the locations of the transients
**Key Arguments:**
- ``transientsMetadataList`` -- the list of transient metadata lifted from the database.
.. tod... | [
"def",
"_update_ned_stream",
"(",
"self",
",",
"transientsMetadataList",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_update_ned_stream`` method'",
")",
"coordinateList",
"=",
"[",
"]",
"for",
"i",
"in",
"transientsMetadataList",
":",
"# thisLi... | update the NED stream within the catalogues database at the locations of the transients
**Key Arguments:**
- ``transientsMetadataList`` -- the list of transient metadata lifted from the database.
.. todo ::
- update key arguments values and definitions with defaults
... | [
"update",
"the",
"NED",
"stream",
"within",
"the",
"catalogues",
"database",
"at",
"the",
"locations",
"of",
"the",
"transients"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L479-L540 |
thespacedoctor/sherlock | sherlock/transient_classifier.py | transient_classifier._remove_previous_ned_queries | def _remove_previous_ned_queries(
self,
coordinateList):
"""iterate through the transient locations to see if we have recent local NED coverage of that area already
**Key Arguments:**
- ``coordinateList`` -- set of coordinate to check for previous queries
**... | python | def _remove_previous_ned_queries(
self,
coordinateList):
"""iterate through the transient locations to see if we have recent local NED coverage of that area already
**Key Arguments:**
- ``coordinateList`` -- set of coordinate to check for previous queries
**... | [
"def",
"_remove_previous_ned_queries",
"(",
"self",
",",
"coordinateList",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_remove_previous_ned_queries`` method'",
")",
"# 1 DEGREE QUERY RADIUS",
"radius",
"=",
"60.",
"*",
"60.",
"updatedCoordinateList",... | iterate through the transient locations to see if we have recent local NED coverage of that area already
**Key Arguments:**
- ``coordinateList`` -- set of coordinate to check for previous queries
**Return:**
- ``updatedCoordinateList`` -- coordinate list with previous queries r... | [
"iterate",
"through",
"the",
"transient",
"locations",
"to",
"see",
"if",
"we",
"have",
"recent",
"local",
"NED",
"coverage",
"of",
"that",
"area",
"already"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L542-L621 |
thespacedoctor/sherlock | sherlock/transient_classifier.py | transient_classifier._crossmatch_transients_against_catalogues | def _crossmatch_transients_against_catalogues(
self,
transientsMetadataListIndex,
colMaps):
"""run the transients through the crossmatch algorithm in the settings file
**Key Arguments:**
- ``transientsMetadataListIndex`` -- the list of transient metadata... | python | def _crossmatch_transients_against_catalogues(
self,
transientsMetadataListIndex,
colMaps):
"""run the transients through the crossmatch algorithm in the settings file
**Key Arguments:**
- ``transientsMetadataListIndex`` -- the list of transient metadata... | [
"def",
"_crossmatch_transients_against_catalogues",
"(",
"self",
",",
"transientsMetadataListIndex",
",",
"colMaps",
")",
":",
"global",
"theseBatches",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_crossmatch_transients_against_catalogues`` method'",
")",
"# SETUP... | run the transients through the crossmatch algorithm in the settings file
**Key Arguments:**
- ``transientsMetadataListIndex`` -- the list of transient metadata lifted from the database.
- ``colMaps`` -- dictionary of dictionaries with the name of the database-view (e.g. `tcs_view_agn_m... | [
"run",
"the",
"transients",
"through",
"the",
"crossmatch",
"algorithm",
"in",
"the",
"settings",
"file"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L623-L676 |
thespacedoctor/sherlock | sherlock/transient_classifier.py | transient_classifier._update_transient_database | def _update_transient_database(
self,
crossmatches,
classifications,
transientsMetadataList,
colMaps):
""" update transient database with classifications and crossmatch results
**Key Arguments:**
- ``crossmatches`` -- the crossmatc... | python | def _update_transient_database(
self,
crossmatches,
classifications,
transientsMetadataList,
colMaps):
""" update transient database with classifications and crossmatch results
**Key Arguments:**
- ``crossmatches`` -- the crossmatc... | [
"def",
"_update_transient_database",
"(",
"self",
",",
"crossmatches",
",",
"classifications",
",",
"transientsMetadataList",
",",
"colMaps",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_update_transient_database`` method'",
")",
"import",
"time",
... | update transient database with classifications and crossmatch results
**Key Arguments:**
- ``crossmatches`` -- the crossmatches and associations resulting from the catlaogue crossmatches
- ``classifications`` -- the classifications assigned to the transients post-crossmatches (dictionar... | [
"update",
"transient",
"database",
"with",
"classifications",
"and",
"crossmatch",
"results"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L678-L789 |
thespacedoctor/sherlock | sherlock/transient_classifier.py | transient_classifier._rank_classifications | def _rank_classifications(
self,
crossmatchArray,
colMaps):
"""*rank the classifications returned from the catalogue crossmatcher, annotate the results with a classification rank-number (most likely = 1) and a rank-score (weight of classification)*
**Key Arguments:**... | python | def _rank_classifications(
self,
crossmatchArray,
colMaps):
"""*rank the classifications returned from the catalogue crossmatcher, annotate the results with a classification rank-number (most likely = 1) and a rank-score (weight of classification)*
**Key Arguments:**... | [
"def",
"_rank_classifications",
"(",
"self",
",",
"crossmatchArray",
",",
"colMaps",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_rank_classifications`` method'",
")",
"crossmatches",
"=",
"crossmatchArray",
"# GROUP CROSSMATCHES INTO DISTINCT SOURCES ... | *rank the classifications returned from the catalogue crossmatcher, annotate the results with a classification rank-number (most likely = 1) and a rank-score (weight of classification)*
**Key Arguments:**
- ``crossmatchArrayIndex`` -- the index of list of unranked crossmatch classifications
... | [
"*",
"rank",
"the",
"classifications",
"returned",
"from",
"the",
"catalogue",
"crossmatcher",
"annotate",
"the",
"results",
"with",
"a",
"classification",
"rank",
"-",
"number",
"(",
"most",
"likely",
"=",
"1",
")",
"and",
"a",
"rank",
"-",
"score",
"(",
... | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L791-L1051 |
thespacedoctor/sherlock | sherlock/transient_classifier.py | transient_classifier._print_results_to_stdout | def _print_results_to_stdout(
self,
classifications,
crossmatches):
"""*print the classification and crossmatch results for a single transient object to stdout*
**Key Arguments:**
- ``crossmatches`` -- the unranked crossmatch classifications
-... | python | def _print_results_to_stdout(
self,
classifications,
crossmatches):
"""*print the classification and crossmatch results for a single transient object to stdout*
**Key Arguments:**
- ``crossmatches`` -- the unranked crossmatch classifications
-... | [
"def",
"_print_results_to_stdout",
"(",
"self",
",",
"classifications",
",",
"crossmatches",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_print_results_to_stdout`` method'",
")",
"if",
"self",
".",
"verbose",
"==",
"0",
":",
"return",
"if",
... | *print the classification and crossmatch results for a single transient object to stdout*
**Key Arguments:**
- ``crossmatches`` -- the unranked crossmatch classifications
- ``classifications`` -- the classifications assigned to the transients post-crossmatches (dictionary of rank ordere... | [
"*",
"print",
"the",
"classification",
"and",
"crossmatch",
"results",
"for",
"a",
"single",
"transient",
"object",
"to",
"stdout",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L1053-L1163 |
thespacedoctor/sherlock | sherlock/transient_classifier.py | transient_classifier._consolidate_coordinateList | def _consolidate_coordinateList(
self,
coordinateList):
"""*match the coordinate list against itself with the parameters of the NED search queries to minimise duplicated NED queries*
**Key Arguments:**
- ``coordinateList`` -- the original coordinateList.
**R... | python | def _consolidate_coordinateList(
self,
coordinateList):
"""*match the coordinate list against itself with the parameters of the NED search queries to minimise duplicated NED queries*
**Key Arguments:**
- ``coordinateList`` -- the original coordinateList.
**R... | [
"def",
"_consolidate_coordinateList",
"(",
"self",
",",
"coordinateList",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_consolidate_coordinateList`` method'",
")",
"raList",
"=",
"[",
"]",
"raList",
"[",
":",
"]",
"=",
"np",
".",
"array",
... | *match the coordinate list against itself with the parameters of the NED search queries to minimise duplicated NED queries*
**Key Arguments:**
- ``coordinateList`` -- the original coordinateList.
**Return:**
- ``updatedCoordinateList`` -- the coordinate list with duplicated sea... | [
"*",
"match",
"the",
"coordinate",
"list",
"against",
"itself",
"with",
"the",
"parameters",
"of",
"the",
"NED",
"search",
"queries",
"to",
"minimise",
"duplicated",
"NED",
"queries",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L1165-L1229 |
thespacedoctor/sherlock | sherlock/transient_classifier.py | transient_classifier.classification_annotations | def classification_annotations(
self):
"""*add a detialed classification annotation to each classification in the sherlock_classifications table*
**Key Arguments:**
# -
**Return:**
- None
**Usage:**
.. todo::
- add usag... | python | def classification_annotations(
self):
"""*add a detialed classification annotation to each classification in the sherlock_classifications table*
**Key Arguments:**
# -
**Return:**
- None
**Usage:**
.. todo::
- add usag... | [
"def",
"classification_annotations",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``classification_annotations`` method'",
")",
"from",
"fundamentals",
".",
"mysql",
"import",
"readquery",
"sqlQuery",
"=",
"u\"\"\"\n select * fro... | *add a detialed classification annotation to each classification in the sherlock_classifications table*
**Key Arguments:**
# -
**Return:**
- None
**Usage:**
.. todo::
- add usage info
- create a sublime snippet for usage
... | [
"*",
"add",
"a",
"detialed",
"classification",
"annotation",
"to",
"each",
"classification",
"in",
"the",
"sherlock_classifications",
"table",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L1231-L1287 |
thespacedoctor/sherlock | sherlock/transient_classifier.py | transient_classifier.update_classification_annotations_and_summaries | def update_classification_annotations_and_summaries(
self,
updatePeakMagnitudes=True):
"""*update classification annotations and summaries*
**Key Arguments:**
- ``updatePeakMagnitudes`` -- update the peak magnitudes in the annotations to give absolute magnitudes. Def... | python | def update_classification_annotations_and_summaries(
self,
updatePeakMagnitudes=True):
"""*update classification annotations and summaries*
**Key Arguments:**
- ``updatePeakMagnitudes`` -- update the peak magnitudes in the annotations to give absolute magnitudes. Def... | [
"def",
"update_classification_annotations_and_summaries",
"(",
"self",
",",
"updatePeakMagnitudes",
"=",
"True",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``update_classification_annotations_and_summaries`` method'",
")",
"# import time",
"# start_time = t... | *update classification annotations and summaries*
**Key Arguments:**
- ``updatePeakMagnitudes`` -- update the peak magnitudes in the annotations to give absolute magnitudes. Default *True*
**Return:**
- None
**Usage:**
.. todo::
- add ... | [
"*",
"update",
"classification",
"annotations",
"and",
"summaries",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L1290-L1551 |
thespacedoctor/sherlock | sherlock/transient_classifier.py | transient_classifier.update_peak_magnitudes | def update_peak_magnitudes(
self):
"""*update peak magnitudes*
**Key Arguments:**
# -
**Return:**
- None
**Usage:**
.. todo::
- add usage info
- create a sublime snippet for usage
- write... | python | def update_peak_magnitudes(
self):
"""*update peak magnitudes*
**Key Arguments:**
# -
**Return:**
- None
**Usage:**
.. todo::
- add usage info
- create a sublime snippet for usage
- write... | [
"def",
"update_peak_magnitudes",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``update_peak_magnitudes`` method'",
")",
"sqlQuery",
"=",
"self",
".",
"settings",
"[",
"\"database settings\"",
"]",
"[",
"\"transients\"",
"]",
"[",
"\... | *update peak magnitudes*
**Key Arguments:**
# -
**Return:**
- None
**Usage:**
.. todo::
- add usage info
- create a sublime snippet for usage
- write a command-line tool for this method
- upd... | [
"*",
"update",
"peak",
"magnitudes",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L1554-L1611 |
thespacedoctor/sherlock | sherlock/transient_classifier.py | transient_classifier._create_tables_if_not_exist | def _create_tables_if_not_exist(
self):
"""*create the sherlock helper tables if they don't yet exist*
**Key Arguments:**
# -
**Return:**
- None
**Usage:**
.. todo::
- add usage info
- create a sublime s... | python | def _create_tables_if_not_exist(
self):
"""*create the sherlock helper tables if they don't yet exist*
**Key Arguments:**
# -
**Return:**
- None
**Usage:**
.. todo::
- add usage info
- create a sublime s... | [
"def",
"_create_tables_if_not_exist",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_create_tables_if_not_exist`` method'",
")",
"transientTable",
"=",
"self",
".",
"settings",
"[",
"\"database settings\"",
"]",
"[",
"\"transients\"",
... | *create the sherlock helper tables if they don't yet exist*
**Key Arguments:**
# -
**Return:**
- None
**Usage:**
.. todo::
- add usage info
- create a sublime snippet for usage
- write a command-line tool fo... | [
"*",
"create",
"the",
"sherlock",
"helper",
"tables",
"if",
"they",
"don",
"t",
"yet",
"exist",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L1613-L1823 |
Clinical-Genomics/trailblazer | trailblazer/cli/check.py | check | def check(context: click.Context, family: str):
"""Delete an analysis log from the database."""
analysis_obj = context.obj['store'].analyses(family=family).first()
if analysis_obj is None:
LOG.error('no analysis found')
context.abort()
config_path = Path(analysis_obj.config_path)
if... | python | def check(context: click.Context, family: str):
"""Delete an analysis log from the database."""
analysis_obj = context.obj['store'].analyses(family=family).first()
if analysis_obj is None:
LOG.error('no analysis found')
context.abort()
config_path = Path(analysis_obj.config_path)
if... | [
"def",
"check",
"(",
"context",
":",
"click",
".",
"Context",
",",
"family",
":",
"str",
")",
":",
"analysis_obj",
"=",
"context",
".",
"obj",
"[",
"'store'",
"]",
".",
"analyses",
"(",
"family",
"=",
"family",
")",
".",
"first",
"(",
")",
"if",
"a... | Delete an analysis log from the database. | [
"Delete",
"an",
"analysis",
"log",
"from",
"the",
"database",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/cli/check.py#L16-L84 |
Clinical-Genomics/trailblazer | trailblazer/mip/fastq.py | FastqHandler.name_file | def name_file(lane: int, flowcell: str, sample: str, read: int,
undetermined: bool=False, date: dt.datetime=None, index: str=None) -> str:
"""Name a FASTQ file following MIP conventions."""
flowcell = f"{flowcell}-undetermined" if undetermined else flowcell
date_str = date.strf... | python | def name_file(lane: int, flowcell: str, sample: str, read: int,
undetermined: bool=False, date: dt.datetime=None, index: str=None) -> str:
"""Name a FASTQ file following MIP conventions."""
flowcell = f"{flowcell}-undetermined" if undetermined else flowcell
date_str = date.strf... | [
"def",
"name_file",
"(",
"lane",
":",
"int",
",",
"flowcell",
":",
"str",
",",
"sample",
":",
"str",
",",
"read",
":",
"int",
",",
"undetermined",
":",
"bool",
"=",
"False",
",",
"date",
":",
"dt",
".",
"datetime",
"=",
"None",
",",
"index",
":",
... | Name a FASTQ file following MIP conventions. | [
"Name",
"a",
"FASTQ",
"file",
"following",
"MIP",
"conventions",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/mip/fastq.py#L13-L19 |
Clinical-Genomics/trailblazer | trailblazer/mip/fastq.py | FastqHandler.link | def link(self, family: str, sample: str, analysis_type: str, files: List[str]):
"""Link FASTQ files for a sample."""
root_dir = Path(self.families_dir) / family / analysis_type / sample / 'fastq'
root_dir.mkdir(parents=True, exist_ok=True)
for fastq_data in files:
fastq_path ... | python | def link(self, family: str, sample: str, analysis_type: str, files: List[str]):
"""Link FASTQ files for a sample."""
root_dir = Path(self.families_dir) / family / analysis_type / sample / 'fastq'
root_dir.mkdir(parents=True, exist_ok=True)
for fastq_data in files:
fastq_path ... | [
"def",
"link",
"(",
"self",
",",
"family",
":",
"str",
",",
"sample",
":",
"str",
",",
"analysis_type",
":",
"str",
",",
"files",
":",
"List",
"[",
"str",
"]",
")",
":",
"root_dir",
"=",
"Path",
"(",
"self",
".",
"families_dir",
")",
"/",
"family",... | Link FASTQ files for a sample. | [
"Link",
"FASTQ",
"files",
"for",
"a",
"sample",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/mip/fastq.py#L21-L39 |
thespacedoctor/sherlock | sherlock/commonutils/getpackagepath.py | getpackagepath | def getpackagepath():
"""
*Get the root path for this python package - used in unit testing code*
"""
moduleDirectory = os.path.dirname(__file__)
packagePath = os.path.dirname(__file__) + "/../"
return packagePath | python | def getpackagepath():
"""
*Get the root path for this python package - used in unit testing code*
"""
moduleDirectory = os.path.dirname(__file__)
packagePath = os.path.dirname(__file__) + "/../"
return packagePath | [
"def",
"getpackagepath",
"(",
")",
":",
"moduleDirectory",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"packagePath",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"+",
"\"/../\"",
"return",
"packagePath"
] | *Get the root path for this python package - used in unit testing code* | [
"*",
"Get",
"the",
"root",
"path",
"for",
"this",
"python",
"package",
"-",
"used",
"in",
"unit",
"testing",
"code",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/commonutils/getpackagepath.py#L15-L22 |
pytroll/posttroll | posttroll/bbmcast.py | mcast_sender | def mcast_sender(mcgroup=MC_GROUP):
"""Non-object interface for sending multicast messages.
"""
sock = socket(AF_INET, SOCK_DGRAM)
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
if _is_broadcast_group(mcgroup):
group = '<broadcast>'
sock.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
elif... | python | def mcast_sender(mcgroup=MC_GROUP):
"""Non-object interface for sending multicast messages.
"""
sock = socket(AF_INET, SOCK_DGRAM)
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
if _is_broadcast_group(mcgroup):
group = '<broadcast>'
sock.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
elif... | [
"def",
"mcast_sender",
"(",
"mcgroup",
"=",
"MC_GROUP",
")",
":",
"sock",
"=",
"socket",
"(",
"AF_INET",
",",
"SOCK_DGRAM",
")",
"sock",
".",
"setsockopt",
"(",
"SOL_SOCKET",
",",
"SO_REUSEADDR",
",",
"1",
")",
"if",
"_is_broadcast_group",
"(",
"mcgroup",
... | Non-object interface for sending multicast messages. | [
"Non",
"-",
"object",
"interface",
"for",
"sending",
"multicast",
"messages",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/bbmcast.py#L80-L95 |
pytroll/posttroll | posttroll/bbmcast.py | mcast_receiver | def mcast_receiver(port, mcgroup=MC_GROUP):
"""Open a UDP socket, bind it to a port and select a multicast group.
"""
if _is_broadcast_group(mcgroup):
group = None
else:
group = mcgroup
# Create a socket
sock = socket(AF_INET, SOCK_DGRAM)
# Allow multiple copies of this pr... | python | def mcast_receiver(port, mcgroup=MC_GROUP):
"""Open a UDP socket, bind it to a port and select a multicast group.
"""
if _is_broadcast_group(mcgroup):
group = None
else:
group = mcgroup
# Create a socket
sock = socket(AF_INET, SOCK_DGRAM)
# Allow multiple copies of this pr... | [
"def",
"mcast_receiver",
"(",
"port",
",",
"mcgroup",
"=",
"MC_GROUP",
")",
":",
"if",
"_is_broadcast_group",
"(",
"mcgroup",
")",
":",
"group",
"=",
"None",
"else",
":",
"group",
"=",
"mcgroup",
"# Create a socket",
"sock",
"=",
"socket",
"(",
"AF_INET",
... | Open a UDP socket, bind it to a port and select a multicast group. | [
"Open",
"a",
"UDP",
"socket",
"bind",
"it",
"to",
"a",
"port",
"and",
"select",
"a",
"multicast",
"group",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/bbmcast.py#L135-L175 |
pytroll/posttroll | posttroll/bbmcast.py | MulticastReceiver.close | def close(self):
"""Close the receiver.
"""
self.socket.setsockopt(SOL_SOCKET, SO_LINGER,
struct.pack('ii', 1, 1))
self.socket.close() | python | def close(self):
"""Close the receiver.
"""
self.socket.setsockopt(SOL_SOCKET, SO_LINGER,
struct.pack('ii', 1, 1))
self.socket.close() | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"socket",
".",
"setsockopt",
"(",
"SOL_SOCKET",
",",
"SO_LINGER",
",",
"struct",
".",
"pack",
"(",
"'ii'",
",",
"1",
",",
"1",
")",
")",
"self",
".",
"socket",
".",
"close",
"(",
")"
] | Close the receiver. | [
"Close",
"the",
"receiver",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/bbmcast.py#L125-L130 |
contentful-labs/contentful.py | contentful/cda/errors.py | api_exception | def api_exception(http_code):
"""Convenience decorator to associate HTTP status codes with :class:`.ApiError` subclasses.
:param http_code: (int) HTTP status code.
:return: wrapper function.
"""
def wrapper(*args):
code = args[0]
ErrorMapping.mapping[http_code] = code
return... | python | def api_exception(http_code):
"""Convenience decorator to associate HTTP status codes with :class:`.ApiError` subclasses.
:param http_code: (int) HTTP status code.
:return: wrapper function.
"""
def wrapper(*args):
code = args[0]
ErrorMapping.mapping[http_code] = code
return... | [
"def",
"api_exception",
"(",
"http_code",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
")",
":",
"code",
"=",
"args",
"[",
"0",
"]",
"ErrorMapping",
".",
"mapping",
"[",
"http_code",
"]",
"=",
"code",
"return",
"code",
"return",
"wrapper"
] | Convenience decorator to associate HTTP status codes with :class:`.ApiError` subclasses.
:param http_code: (int) HTTP status code.
:return: wrapper function. | [
"Convenience",
"decorator",
"to",
"associate",
"HTTP",
"status",
"codes",
"with",
":",
"class",
":",
".",
"ApiError",
"subclasses",
"."
] | train | https://github.com/contentful-labs/contentful.py/blob/d9eb4a68abcad33e4766e2be8c7b35e605210b5a/contentful/cda/errors.py#L23-L33 |
Clinical-Genomics/trailblazer | trailblazer/log.py | LogAnalysis._delete_temp_logs | def _delete_temp_logs(self, family_name: str):
"""Delete temporary logs for the current family."""
for temp_log in self.store.analyses(family=family_name, temp=True):
log.debug(f"delete temporary log: {temp_log.id} - {temp_log.status}")
temp_log.delete() | python | def _delete_temp_logs(self, family_name: str):
"""Delete temporary logs for the current family."""
for temp_log in self.store.analyses(family=family_name, temp=True):
log.debug(f"delete temporary log: {temp_log.id} - {temp_log.status}")
temp_log.delete() | [
"def",
"_delete_temp_logs",
"(",
"self",
",",
"family_name",
":",
"str",
")",
":",
"for",
"temp_log",
"in",
"self",
".",
"store",
".",
"analyses",
"(",
"family",
"=",
"family_name",
",",
"temp",
"=",
"True",
")",
":",
"log",
".",
"debug",
"(",
"f\"dele... | Delete temporary logs for the current family. | [
"Delete",
"temporary",
"logs",
"for",
"the",
"current",
"family",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/log.py#L44-L48 |
Clinical-Genomics/trailblazer | trailblazer/log.py | LogAnalysis.parse | def parse(cls, config_data: dict, sampleinfo_data: dict, sacct_jobs: List[dict],
jobs: int) -> dict:
"""Parse information about a run."""
analysis_types = [sample['type'] for sample in config_data['samples']]
run_data = {
'user': config_data['email'],
'famil... | python | def parse(cls, config_data: dict, sampleinfo_data: dict, sacct_jobs: List[dict],
jobs: int) -> dict:
"""Parse information about a run."""
analysis_types = [sample['type'] for sample in config_data['samples']]
run_data = {
'user': config_data['email'],
'famil... | [
"def",
"parse",
"(",
"cls",
",",
"config_data",
":",
"dict",
",",
"sampleinfo_data",
":",
"dict",
",",
"sacct_jobs",
":",
"List",
"[",
"dict",
"]",
",",
"jobs",
":",
"int",
")",
"->",
"dict",
":",
"analysis_types",
"=",
"[",
"sample",
"[",
"'type'",
... | Parse information about a run. | [
"Parse",
"information",
"about",
"a",
"run",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/log.py#L51-L74 |
Clinical-Genomics/trailblazer | trailblazer/log.py | LogAnalysis._parse_sacct | def _parse_sacct(sacct_jobs: List[dict], jobs_count: int=None):
"""Parse out info from Sacct log."""
failed_jobs = sacct_api.filter_jobs(sacct_jobs, failed=True)
completed_jobs = [job for job in sacct_jobs if job['is_completed']]
last_job_end = completed_jobs[-1]['end'] if len(completed_... | python | def _parse_sacct(sacct_jobs: List[dict], jobs_count: int=None):
"""Parse out info from Sacct log."""
failed_jobs = sacct_api.filter_jobs(sacct_jobs, failed=True)
completed_jobs = [job for job in sacct_jobs if job['is_completed']]
last_job_end = completed_jobs[-1]['end'] if len(completed_... | [
"def",
"_parse_sacct",
"(",
"sacct_jobs",
":",
"List",
"[",
"dict",
"]",
",",
"jobs_count",
":",
"int",
"=",
"None",
")",
":",
"failed_jobs",
"=",
"sacct_api",
".",
"filter_jobs",
"(",
"sacct_jobs",
",",
"failed",
"=",
"True",
")",
"completed_jobs",
"=",
... | Parse out info from Sacct log. | [
"Parse",
"out",
"info",
"from",
"Sacct",
"log",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/log.py#L77-L95 |
Clinical-Genomics/trailblazer | trailblazer/log.py | LogAnalysis._get_analysis_type | def _get_analysis_type(analysis_types: List[str]) -> str:
"""Determine the overall analysis type."""
types_set = set(analysis_types)
return types_set.pop() if len(types_set) == 1 else 'wgs' | python | def _get_analysis_type(analysis_types: List[str]) -> str:
"""Determine the overall analysis type."""
types_set = set(analysis_types)
return types_set.pop() if len(types_set) == 1 else 'wgs' | [
"def",
"_get_analysis_type",
"(",
"analysis_types",
":",
"List",
"[",
"str",
"]",
")",
"->",
"str",
":",
"types_set",
"=",
"set",
"(",
"analysis_types",
")",
"return",
"types_set",
".",
"pop",
"(",
")",
"if",
"len",
"(",
"types_set",
")",
"==",
"1",
"e... | Determine the overall analysis type. | [
"Determine",
"the",
"overall",
"analysis",
"type",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/log.py#L108-L111 |
Clinical-Genomics/trailblazer | trailblazer/log.py | LogAnalysis.build | def build(self, run_data: dict) -> models.Analysis:
"""Build a new Analysis object."""
existing_run = self.store.find_analysis(family=run_data['family'],
started_at=run_data['started_at'],
status=run_data['st... | python | def build(self, run_data: dict) -> models.Analysis:
"""Build a new Analysis object."""
existing_run = self.store.find_analysis(family=run_data['family'],
started_at=run_data['started_at'],
status=run_data['st... | [
"def",
"build",
"(",
"self",
",",
"run_data",
":",
"dict",
")",
"->",
"models",
".",
"Analysis",
":",
"existing_run",
"=",
"self",
".",
"store",
".",
"find_analysis",
"(",
"family",
"=",
"run_data",
"[",
"'family'",
"]",
",",
"started_at",
"=",
"run_data... | Build a new Analysis object. | [
"Build",
"a",
"new",
"Analysis",
"object",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/log.py#L113-L126 |
capless/valley | valley/mixins.py | VariableMixin.get_default_value | def get_default_value(self):
""" return default value """
default = self.default_value
if isinstance(default, collections.Callable):
default = default()
return default | python | def get_default_value(self):
""" return default value """
default = self.default_value
if isinstance(default, collections.Callable):
default = default()
return default | [
"def",
"get_default_value",
"(",
"self",
")",
":",
"default",
"=",
"self",
".",
"default_value",
"if",
"isinstance",
"(",
"default",
",",
"collections",
".",
"Callable",
")",
":",
"default",
"=",
"default",
"(",
")",
"return",
"default"
] | return default value | [
"return",
"default",
"value"
] | train | https://github.com/capless/valley/blob/491e4203e428a9e92264e204d44a1df96a570bbc/valley/mixins.py#L32-L37 |
OpenEnergyPlatform/oedialect | oedialect/dialect.py | OEExecutionContext._init_compiled | def _init_compiled(cls, dialect, connection, dbapi_connection,
compiled, parameters):
"""Initialize execution context for a Compiled construct."""
self = cls.__new__(cls)
self.root_connection = connection
self._dbapi_connection = dbapi_connection
self.dial... | python | def _init_compiled(cls, dialect, connection, dbapi_connection,
compiled, parameters):
"""Initialize execution context for a Compiled construct."""
self = cls.__new__(cls)
self.root_connection = connection
self._dbapi_connection = dbapi_connection
self.dial... | [
"def",
"_init_compiled",
"(",
"cls",
",",
"dialect",
",",
"connection",
",",
"dbapi_connection",
",",
"compiled",
",",
"parameters",
")",
":",
"self",
"=",
"cls",
".",
"__new__",
"(",
"cls",
")",
"self",
".",
"root_connection",
"=",
"connection",
"self",
"... | Initialize execution context for a Compiled construct. | [
"Initialize",
"execution",
"context",
"for",
"a",
"Compiled",
"construct",
"."
] | train | https://github.com/OpenEnergyPlatform/oedialect/blob/40a8d9e9b272ea4674d2c40dd6b3e6cc15f91c1e/oedialect/dialect.py#L38-L139 |
fabianvf/python-rake | RAKE/RAKE.py | split_sentences | def split_sentences(text):
"""
Utility function to return a list of sentences.
@param text The text that must be split in to sentences.
"""
sentence_delimiters = re.compile(u'[.!?,;:\t\\\\"\\(\\)\\\'\u2019\u2013]|\\s\\-\\s')
sentences = sentence_delimiters.split(text)
return sentences | python | def split_sentences(text):
"""
Utility function to return a list of sentences.
@param text The text that must be split in to sentences.
"""
sentence_delimiters = re.compile(u'[.!?,;:\t\\\\"\\(\\)\\\'\u2019\u2013]|\\s\\-\\s')
sentences = sentence_delimiters.split(text)
return sentences | [
"def",
"split_sentences",
"(",
"text",
")",
":",
"sentence_delimiters",
"=",
"re",
".",
"compile",
"(",
"u'[.!?,;:\\t\\\\\\\\\"\\\\(\\\\)\\\\\\'\\u2019\\u2013]|\\\\s\\\\-\\\\s'",
")",
"sentences",
"=",
"sentence_delimiters",
".",
"split",
"(",
"text",
")",
"return",
"se... | Utility function to return a list of sentences.
@param text The text that must be split in to sentences. | [
"Utility",
"function",
"to",
"return",
"a",
"list",
"of",
"sentences",
"."
] | train | https://github.com/fabianvf/python-rake/blob/54357322c40c7dd975144a189bbc9da0f9c29060/RAKE/RAKE.py#L88-L95 |
crccheck/django-object-actions | django_object_actions/utils.py | takes_instance_or_queryset | def takes_instance_or_queryset(func):
"""Decorator that makes standard Django admin actions compatible."""
@wraps(func)
def decorated_function(self, request, queryset):
# func follows the prototype documented at:
# https://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#writing-acti... | python | def takes_instance_or_queryset(func):
"""Decorator that makes standard Django admin actions compatible."""
@wraps(func)
def decorated_function(self, request, queryset):
# func follows the prototype documented at:
# https://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#writing-acti... | [
"def",
"takes_instance_or_queryset",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"decorated_function",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"# func follows the prototype documented at:",
"# https://docs.djangoproject.com/en/dev/ref/con... | Decorator that makes standard Django admin actions compatible. | [
"Decorator",
"that",
"makes",
"standard",
"Django",
"admin",
"actions",
"compatible",
"."
] | train | https://github.com/crccheck/django-object-actions/blob/fb908697a609f46889af15b543d444e5e19d6be2/django_object_actions/utils.py#L280-L299 |
crccheck/django-object-actions | django_object_actions/utils.py | BaseDjangoObjectActions.get_urls | def get_urls(self):
"""Prepend `get_urls` with our own patterns."""
urls = super(BaseDjangoObjectActions, self).get_urls()
return self._get_action_urls() + urls | python | def get_urls(self):
"""Prepend `get_urls` with our own patterns."""
urls = super(BaseDjangoObjectActions, self).get_urls()
return self._get_action_urls() + urls | [
"def",
"get_urls",
"(",
"self",
")",
":",
"urls",
"=",
"super",
"(",
"BaseDjangoObjectActions",
",",
"self",
")",
".",
"get_urls",
"(",
")",
"return",
"self",
".",
"_get_action_urls",
"(",
")",
"+",
"urls"
] | Prepend `get_urls` with our own patterns. | [
"Prepend",
"get_urls",
"with",
"our",
"own",
"patterns",
"."
] | train | https://github.com/crccheck/django-object-actions/blob/fb908697a609f46889af15b543d444e5e19d6be2/django_object_actions/utils.py#L46-L49 |
crccheck/django-object-actions | django_object_actions/utils.py | BaseDjangoObjectActions._get_action_urls | def _get_action_urls(self):
"""Get the url patterns that route each action to a view."""
actions = {}
model_name = self.model._meta.model_name
# e.g.: polls_poll
base_url_name = '%s_%s' % (self.model._meta.app_label, model_name)
# e.g.: polls_poll_actions
model_a... | python | def _get_action_urls(self):
"""Get the url patterns that route each action to a view."""
actions = {}
model_name = self.model._meta.model_name
# e.g.: polls_poll
base_url_name = '%s_%s' % (self.model._meta.app_label, model_name)
# e.g.: polls_poll_actions
model_a... | [
"def",
"_get_action_urls",
"(",
"self",
")",
":",
"actions",
"=",
"{",
"}",
"model_name",
"=",
"self",
".",
"model",
".",
"_meta",
".",
"model_name",
"# e.g.: polls_poll",
"base_url_name",
"=",
"'%s_%s'",
"%",
"(",
"self",
".",
"model",
".",
"_meta",
".",
... | Get the url patterns that route each action to a view. | [
"Get",
"the",
"url",
"patterns",
"that",
"route",
"each",
"action",
"to",
"a",
"view",
"."
] | train | https://github.com/crccheck/django-object-actions/blob/fb908697a609f46889af15b543d444e5e19d6be2/django_object_actions/utils.py#L105-L146 |
crccheck/django-object-actions | django_object_actions/utils.py | BaseDjangoObjectActions._get_tool_dict | def _get_tool_dict(self, tool_name):
"""Represents the tool as a dict with extra meta."""
tool = getattr(self, tool_name)
standard_attrs, custom_attrs = self._get_button_attrs(tool)
return dict(
name=tool_name,
label=getattr(tool, 'label', tool_name),
... | python | def _get_tool_dict(self, tool_name):
"""Represents the tool as a dict with extra meta."""
tool = getattr(self, tool_name)
standard_attrs, custom_attrs = self._get_button_attrs(tool)
return dict(
name=tool_name,
label=getattr(tool, 'label', tool_name),
... | [
"def",
"_get_tool_dict",
"(",
"self",
",",
"tool_name",
")",
":",
"tool",
"=",
"getattr",
"(",
"self",
",",
"tool_name",
")",
"standard_attrs",
",",
"custom_attrs",
"=",
"self",
".",
"_get_button_attrs",
"(",
"tool",
")",
"return",
"dict",
"(",
"name",
"="... | Represents the tool as a dict with extra meta. | [
"Represents",
"the",
"tool",
"as",
"a",
"dict",
"with",
"extra",
"meta",
"."
] | train | https://github.com/crccheck/django-object-actions/blob/fb908697a609f46889af15b543d444e5e19d6be2/django_object_actions/utils.py#L148-L157 |
crccheck/django-object-actions | django_object_actions/utils.py | BaseDjangoObjectActions._get_button_attrs | def _get_button_attrs(self, tool):
"""
Get the HTML attributes associated with a tool.
There are some standard attributes (class and title) that the template
will always want. Any number of additional attributes can be specified
and passed on. This is kinda awkward and due for a... | python | def _get_button_attrs(self, tool):
"""
Get the HTML attributes associated with a tool.
There are some standard attributes (class and title) that the template
will always want. Any number of additional attributes can be specified
and passed on. This is kinda awkward and due for a... | [
"def",
"_get_button_attrs",
"(",
"self",
",",
"tool",
")",
":",
"attrs",
"=",
"getattr",
"(",
"tool",
",",
"'attrs'",
",",
"{",
"}",
")",
"# href is not allowed to be set. should an exception be raised instead?",
"if",
"'href'",
"in",
"attrs",
":",
"attrs",
".",
... | Get the HTML attributes associated with a tool.
There are some standard attributes (class and title) that the template
will always want. Any number of additional attributes can be specified
and passed on. This is kinda awkward and due for a refactor for
readability. | [
"Get",
"the",
"HTML",
"attributes",
"associated",
"with",
"a",
"tool",
"."
] | train | https://github.com/crccheck/django-object-actions/blob/fb908697a609f46889af15b543d444e5e19d6be2/django_object_actions/utils.py#L159-L188 |
crccheck/django-object-actions | example_project/polls/admin.py | PollAdmin.question_mark | def question_mark(self, request, obj):
"""Add a question mark."""
obj.question = obj.question + '?'
obj.save() | python | def question_mark(self, request, obj):
"""Add a question mark."""
obj.question = obj.question + '?'
obj.save() | [
"def",
"question_mark",
"(",
"self",
",",
"request",
",",
"obj",
")",
":",
"obj",
".",
"question",
"=",
"obj",
".",
"question",
"+",
"'?'",
"obj",
".",
"save",
"(",
")"
] | Add a question mark. | [
"Add",
"a",
"question",
"mark",
"."
] | train | https://github.com/crccheck/django-object-actions/blob/fb908697a609f46889af15b543d444e5e19d6be2/example_project/polls/admin.py#L115-L118 |
InfoAgeTech/django-core | django_core/html/builders.py | build_link | def build_link(href, text, cls=None, icon_class=None, **attrs):
"""Builds an html link.
:param href: link for the anchor element
:param text: text for the anchor element
:param attrs: other attribute kwargs
>>> build_link('xyz.com', 'hello', 'big')
u'<a href="xyz.com" class="big">hello</a>'
... | python | def build_link(href, text, cls=None, icon_class=None, **attrs):
"""Builds an html link.
:param href: link for the anchor element
:param text: text for the anchor element
:param attrs: other attribute kwargs
>>> build_link('xyz.com', 'hello', 'big')
u'<a href="xyz.com" class="big">hello</a>'
... | [
"def",
"build_link",
"(",
"href",
",",
"text",
",",
"cls",
"=",
"None",
",",
"icon_class",
"=",
"None",
",",
"*",
"*",
"attrs",
")",
":",
"return",
"build_html_element",
"(",
"tag",
"=",
"'a'",
",",
"text",
"=",
"text",
",",
"href",
"=",
"href",
",... | Builds an html link.
:param href: link for the anchor element
:param text: text for the anchor element
:param attrs: other attribute kwargs
>>> build_link('xyz.com', 'hello', 'big')
u'<a href="xyz.com" class="big">hello</a>'
>>> build_link('xyz.com', 'hello', 'big', 'fa fa-times')
u'<a hre... | [
"Builds",
"an",
"html",
"link",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/html/builders.py#L8-L25 |
InfoAgeTech/django-core | django_core/html/builders.py | build_html_element | def build_html_element(tag, text=None, icon_class=None, cls=None, **kwargs):
"""Builds an html element.
:param tag: the html tag to build ('a', 'div', 'img', etc)
:param icon_class: the class to apply to an icon element. This only
applies to elements that allow a closing tag.
:param cls: the c... | python | def build_html_element(tag, text=None, icon_class=None, cls=None, **kwargs):
"""Builds an html element.
:param tag: the html tag to build ('a', 'div', 'img', etc)
:param icon_class: the class to apply to an icon element. This only
applies to elements that allow a closing tag.
:param cls: the c... | [
"def",
"build_html_element",
"(",
"tag",
",",
"text",
"=",
"None",
",",
"icon_class",
"=",
"None",
",",
"cls",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"cls",
"is",
"not",
"None",
":",
"kwargs",
"[",
"'class'",
"]",
"=",
"cls",
"tag_at... | Builds an html element.
:param tag: the html tag to build ('a', 'div', 'img', etc)
:param icon_class: the class to apply to an icon element. This only
applies to elements that allow a closing tag.
:param cls: the css class to apply to the tag. This can also be passed
in as a kwarg as "cla... | [
"Builds",
"an",
"html",
"element",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/html/builders.py#L28-L62 |
edx/edx-django-release-util | release_util/management/commands/__init__.py | dump_migration_session_state | def dump_migration_session_state(raw):
"""
Serialize a migration session state to yaml using nicer formatting
Args:
raw: object to serialize
Returns: string (of yaml)
Specifically, this forces the "output" member of state step dicts (e.g.
state[0]['output']) to use block formatting. Fo... | python | def dump_migration_session_state(raw):
"""
Serialize a migration session state to yaml using nicer formatting
Args:
raw: object to serialize
Returns: string (of yaml)
Specifically, this forces the "output" member of state step dicts (e.g.
state[0]['output']) to use block formatting. Fo... | [
"def",
"dump_migration_session_state",
"(",
"raw",
")",
":",
"class",
"BlockStyle",
"(",
"str",
")",
":",
"pass",
"class",
"SessionDumper",
"(",
"yaml",
".",
"SafeDumper",
")",
":",
"pass",
"def",
"str_block_formatter",
"(",
"dumper",
",",
"data",
")",
":",
... | Serialize a migration session state to yaml using nicer formatting
Args:
raw: object to serialize
Returns: string (of yaml)
Specifically, this forces the "output" member of state step dicts (e.g.
state[0]['output']) to use block formatting. For example, rather than this:
- migration: [app... | [
"Serialize",
"a",
"migration",
"session",
"state",
"to",
"yaml",
"using",
"nicer",
"formatting"
] | train | https://github.com/edx/edx-django-release-util/blob/de0fde41d6a19885ab7dc309472b94fd0fccbc1d/release_util/management/commands/__init__.py#L16-L48 |
edx/edx-django-release-util | release_util/management/commands/__init__.py | MigrationSession.add_migrations | def add_migrations(self, migrations):
"""
Add migrations to be applied.
Args:
migrations: a list of migrations to add of the form [(app, migration_name), ...]
Raises:
MigrationSessionError if called on a closed MigrationSession
"""
if self.__close... | python | def add_migrations(self, migrations):
"""
Add migrations to be applied.
Args:
migrations: a list of migrations to add of the form [(app, migration_name), ...]
Raises:
MigrationSessionError if called on a closed MigrationSession
"""
if self.__close... | [
"def",
"add_migrations",
"(",
"self",
",",
"migrations",
")",
":",
"if",
"self",
".",
"__closed",
":",
"raise",
"MigrationSessionError",
"(",
"\"Can't change applied session\"",
")",
"self",
".",
"_to_apply",
".",
"extend",
"(",
"migrations",
")"
] | Add migrations to be applied.
Args:
migrations: a list of migrations to add of the form [(app, migration_name), ...]
Raises:
MigrationSessionError if called on a closed MigrationSession | [
"Add",
"migrations",
"to",
"be",
"applied",
"."
] | train | https://github.com/edx/edx-django-release-util/blob/de0fde41d6a19885ab7dc309472b94fd0fccbc1d/release_util/management/commands/__init__.py#L146-L157 |
edx/edx-django-release-util | release_util/management/commands/__init__.py | MigrationSession._get_unapplied_migrations | def _get_unapplied_migrations(self, loader):
"""
Output a list of unapplied migrations in the form [['migration1', migration2'], ...].
This implementation is mostly copied from the Django 'showmigrations' mgmt command.
https://github.com/django/django/blob/stable/1.8.x/django/core/manage... | python | def _get_unapplied_migrations(self, loader):
"""
Output a list of unapplied migrations in the form [['migration1', migration2'], ...].
This implementation is mostly copied from the Django 'showmigrations' mgmt command.
https://github.com/django/django/blob/stable/1.8.x/django/core/manage... | [
"def",
"_get_unapplied_migrations",
"(",
"self",
",",
"loader",
")",
":",
"unapplied",
"=",
"[",
"]",
"graph",
"=",
"loader",
".",
"graph",
"plan",
"=",
"[",
"]",
"seen",
"=",
"set",
"(",
")",
"# Generate the plan, in the order that migrations have been/should be ... | Output a list of unapplied migrations in the form [['migration1', migration2'], ...].
This implementation is mostly copied from the Django 'showmigrations' mgmt command.
https://github.com/django/django/blob/stable/1.8.x/django/core/management/commands/showmigrations.py
This should only be call... | [
"Output",
"a",
"list",
"of",
"unapplied",
"migrations",
"in",
"the",
"form",
"[[",
"migration1",
"migration2",
"]",
"...",
"]",
".",
"This",
"implementation",
"is",
"mostly",
"copied",
"from",
"the",
"Django",
"showmigrations",
"mgmt",
"command",
".",
"https",... | train | https://github.com/edx/edx-django-release-util/blob/de0fde41d6a19885ab7dc309472b94fd0fccbc1d/release_util/management/commands/__init__.py#L159-L184 |
edx/edx-django-release-util | release_util/management/commands/__init__.py | MigrationSession._get_current_migration_state | def _get_current_migration_state(self, loader, apps):
"""
Extract the most recent migrations from the relevant apps.
If no migrations have been performed, return 'zero' as the most recent migration for the app.
This should only be called from list_migrations().
"""
# Onl... | python | def _get_current_migration_state(self, loader, apps):
"""
Extract the most recent migrations from the relevant apps.
If no migrations have been performed, return 'zero' as the most recent migration for the app.
This should only be called from list_migrations().
"""
# Onl... | [
"def",
"_get_current_migration_state",
"(",
"self",
",",
"loader",
",",
"apps",
")",
":",
"# Only care about applied migrations for the passed-in apps.",
"apps",
"=",
"set",
"(",
"apps",
")",
"relevant_applied",
"=",
"[",
"migration",
"for",
"migration",
"in",
"loader... | Extract the most recent migrations from the relevant apps.
If no migrations have been performed, return 'zero' as the most recent migration for the app.
This should only be called from list_migrations(). | [
"Extract",
"the",
"most",
"recent",
"migrations",
"from",
"the",
"relevant",
"apps",
".",
"If",
"no",
"migrations",
"have",
"been",
"performed",
"return",
"zero",
"as",
"the",
"most",
"recent",
"migration",
"for",
"the",
"app",
"."
] | train | https://github.com/edx/edx-django-release-util/blob/de0fde41d6a19885ab7dc309472b94fd0fccbc1d/release_util/management/commands/__init__.py#L186-L203 |
edx/edx-django-release-util | release_util/management/commands/__init__.py | MigrationSession.list_migrations | def list_migrations(self):
"""
Returns a tuple of unapplied, current
"Unapplied" is a list of unapplied migrations. "Current" is a list of the current migration
states for apps with unapplied migrations.
Both are tuples of the form (app, migration_name).
"""
con... | python | def list_migrations(self):
"""
Returns a tuple of unapplied, current
"Unapplied" is a list of unapplied migrations. "Current" is a list of the current migration
states for apps with unapplied migrations.
Both are tuples of the form (app, migration_name).
"""
con... | [
"def",
"list_migrations",
"(",
"self",
")",
":",
"connection",
"=",
"connections",
"[",
"self",
".",
"_database_name",
"]",
"loader",
"=",
"MigrationLoader",
"(",
"connection",
",",
"ignore_no_migrations",
"=",
"True",
")",
"unapplied",
"=",
"self",
".",
"_get... | Returns a tuple of unapplied, current
"Unapplied" is a list of unapplied migrations. "Current" is a list of the current migration
states for apps with unapplied migrations.
Both are tuples of the form (app, migration_name). | [
"Returns",
"a",
"tuple",
"of",
"unapplied",
"current"
] | train | https://github.com/edx/edx-django-release-util/blob/de0fde41d6a19885ab7dc309472b94fd0fccbc1d/release_util/management/commands/__init__.py#L205-L218 |
edx/edx-django-release-util | release_util/management/commands/__init__.py | MigrationSession._parse_migrate_output | def _parse_migrate_output(self, output):
"""
Args:
output: str, output of "manage.py migrate"
Returns (succeeded: list(tuple), failed: tuple or None)
Both tuples are of the form (app, migration)
"""
failed = None
succeeded = []
# Mark migratio... | python | def _parse_migrate_output(self, output):
"""
Args:
output: str, output of "manage.py migrate"
Returns (succeeded: list(tuple), failed: tuple or None)
Both tuples are of the form (app, migration)
"""
failed = None
succeeded = []
# Mark migratio... | [
"def",
"_parse_migrate_output",
"(",
"self",
",",
"output",
")",
":",
"failed",
"=",
"None",
"succeeded",
"=",
"[",
"]",
"# Mark migrations:",
"# - before exception migration as success",
"# - exception migration as failed",
"for",
"line",
"in",
"output",
".",
"split",
... | Args:
output: str, output of "manage.py migrate"
Returns (succeeded: list(tuple), failed: tuple or None)
Both tuples are of the form (app, migration) | [
"Args",
":",
"output",
":",
"str",
"output",
"of",
"manage",
".",
"py",
"migrate",
"Returns",
"(",
"succeeded",
":",
"list",
"(",
"tuple",
")",
"failed",
":",
"tuple",
"or",
"None",
")",
"Both",
"tuples",
"are",
"of",
"the",
"form",
"(",
"app",
"migr... | train | https://github.com/edx/edx-django-release-util/blob/de0fde41d6a19885ab7dc309472b94fd0fccbc1d/release_util/management/commands/__init__.py#L220-L245 |
edx/edx-django-release-util | release_util/management/commands/__init__.py | MigrationSession.__apply | def __apply(self, migration=None, run_all=False):
"""
If a migration is supplied, runs that migration and appends to state.
If run_all==True, runs all migrations.
Raises a ValueError if neither "migration" nor "run_all" are provided.
"""
out = StringIO()
trace = N... | python | def __apply(self, migration=None, run_all=False):
"""
If a migration is supplied, runs that migration and appends to state.
If run_all==True, runs all migrations.
Raises a ValueError if neither "migration" nor "run_all" are provided.
"""
out = StringIO()
trace = N... | [
"def",
"__apply",
"(",
"self",
",",
"migration",
"=",
"None",
",",
"run_all",
"=",
"False",
")",
":",
"out",
"=",
"StringIO",
"(",
")",
"trace",
"=",
"None",
"migrate_kwargs",
"=",
"{",
"'interactive'",
":",
"False",
",",
"'stdout'",
":",
"out",
",",
... | If a migration is supplied, runs that migration and appends to state.
If run_all==True, runs all migrations.
Raises a ValueError if neither "migration" nor "run_all" are provided. | [
"If",
"a",
"migration",
"is",
"supplied",
"runs",
"that",
"migration",
"and",
"appends",
"to",
"state",
".",
"If",
"run_all",
"==",
"True",
"runs",
"all",
"migrations",
".",
"Raises",
"a",
"ValueError",
"if",
"neither",
"migration",
"nor",
"run_all",
"are",
... | train | https://github.com/edx/edx-django-release-util/blob/de0fde41d6a19885ab7dc309472b94fd0fccbc1d/release_util/management/commands/__init__.py#L247-L292 |
edx/edx-django-release-util | release_util/management/commands/__init__.py | MigrationSession.apply | def apply(self):
"""
Applies all migrations that have been added.
Note that some migrations depend on others, so you might end up
running more than one.
"""
if self.__closed:
raise MigrationSessionError("Can't apply applied session")
try:
w... | python | def apply(self):
"""
Applies all migrations that have been added.
Note that some migrations depend on others, so you might end up
running more than one.
"""
if self.__closed:
raise MigrationSessionError("Can't apply applied session")
try:
w... | [
"def",
"apply",
"(",
"self",
")",
":",
"if",
"self",
".",
"__closed",
":",
"raise",
"MigrationSessionError",
"(",
"\"Can't apply applied session\"",
")",
"try",
":",
"while",
"self",
".",
"_to_apply",
":",
"self",
".",
"__apply",
"(",
"migration",
"=",
"self... | Applies all migrations that have been added.
Note that some migrations depend on others, so you might end up
running more than one. | [
"Applies",
"all",
"migrations",
"that",
"have",
"been",
"added",
".",
"Note",
"that",
"some",
"migrations",
"depend",
"on",
"others",
"so",
"you",
"might",
"end",
"up",
"running",
"more",
"than",
"one",
"."
] | train | https://github.com/edx/edx-django-release-util/blob/de0fde41d6a19885ab7dc309472b94fd0fccbc1d/release_util/management/commands/__init__.py#L294-L308 |
edx/edx-django-release-util | release_util/management/commands/__init__.py | MigrationSession.apply_all | def apply_all(self):
"""
Applies all Django model migrations at once, recording the result.
"""
if self.__closed:
raise MigrationSessionError("Can't apply applied session")
if self._to_apply:
raise MigrationSessionError("Can't apply_all with migrations add... | python | def apply_all(self):
"""
Applies all Django model migrations at once, recording the result.
"""
if self.__closed:
raise MigrationSessionError("Can't apply applied session")
if self._to_apply:
raise MigrationSessionError("Can't apply_all with migrations add... | [
"def",
"apply_all",
"(",
"self",
")",
":",
"if",
"self",
".",
"__closed",
":",
"raise",
"MigrationSessionError",
"(",
"\"Can't apply applied session\"",
")",
"if",
"self",
".",
"_to_apply",
":",
"raise",
"MigrationSessionError",
"(",
"\"Can't apply_all with migrations... | Applies all Django model migrations at once, recording the result. | [
"Applies",
"all",
"Django",
"model",
"migrations",
"at",
"once",
"recording",
"the",
"result",
"."
] | train | https://github.com/edx/edx-django-release-util/blob/de0fde41d6a19885ab7dc309472b94fd0fccbc1d/release_util/management/commands/__init__.py#L310-L324 |
InfoAgeTech/django-core | django_core/mail/sending.py | send_email_from_template | def send_email_from_template(to_email, from_email, subject,
markdown_template=None,
text_template=None, html_template=None,
fail_silently=False, context=None,
**kwargs):
"""Send an email from a templa... | python | def send_email_from_template(to_email, from_email, subject,
markdown_template=None,
text_template=None, html_template=None,
fail_silently=False, context=None,
**kwargs):
"""Send an email from a templa... | [
"def",
"send_email_from_template",
"(",
"to_email",
",",
"from_email",
",",
"subject",
",",
"markdown_template",
"=",
"None",
",",
"text_template",
"=",
"None",
",",
"html_template",
"=",
"None",
",",
"fail_silently",
"=",
"False",
",",
"context",
"=",
"None",
... | Send an email from a template.
:param to_email: the email address to send the email to
:param from_email: the email address the email will be from
:param subject: the subject of the email
:param markdown_template: the markdown syntax template to use for the
email. If provided, this will generat... | [
"Send",
"an",
"email",
"from",
"a",
"template",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/mail/sending.py#L9-L39 |
InfoAgeTech/django-core | django_core/mail/sending.py | send_emails_from_template | def send_emails_from_template(to_emails, from_email, subject,
markdown_template=None, text_template=None,
html_template=None, fail_silently=False,
context=None, attachments=None, **kwargs):
"""Send many emails from single temp... | python | def send_emails_from_template(to_emails, from_email, subject,
markdown_template=None, text_template=None,
html_template=None, fail_silently=False,
context=None, attachments=None, **kwargs):
"""Send many emails from single temp... | [
"def",
"send_emails_from_template",
"(",
"to_emails",
",",
"from_email",
",",
"subject",
",",
"markdown_template",
"=",
"None",
",",
"text_template",
"=",
"None",
",",
"html_template",
"=",
"None",
",",
"fail_silently",
"=",
"False",
",",
"context",
"=",
"None",... | Send many emails from single template. Each email address listed in the
``to_emails`` will receive an separate email.
:param to_emails: list of email address to send the email to
:param from_email: the email address the email will be from
:param subject: the subject of the email
:param markdown_te... | [
"Send",
"many",
"emails",
"from",
"single",
"template",
".",
"Each",
"email",
"address",
"listed",
"in",
"the",
"to_emails",
"will",
"receive",
"an",
"separate",
"email",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/mail/sending.py#L42-L116 |
MarcoFavorito/flloat | flloat/syntax/pl.py | PLFormula.all_models | def all_models(self, alphabet: _Alphabet) -> Set[PLInterpretation]:
"""Find all the possible interpretations given a set of symbols"""
all_possible_interpretations = alphabet.powerset().symbols
all_models = set()
for i in all_possible_interpretations:
# compute current Inter... | python | def all_models(self, alphabet: _Alphabet) -> Set[PLInterpretation]:
"""Find all the possible interpretations given a set of symbols"""
all_possible_interpretations = alphabet.powerset().symbols
all_models = set()
for i in all_possible_interpretations:
# compute current Inter... | [
"def",
"all_models",
"(",
"self",
",",
"alphabet",
":",
"_Alphabet",
")",
"->",
"Set",
"[",
"PLInterpretation",
"]",
":",
"all_possible_interpretations",
"=",
"alphabet",
".",
"powerset",
"(",
")",
".",
"symbols",
"all_models",
"=",
"set",
"(",
")",
"for",
... | Find all the possible interpretations given a set of symbols | [
"Find",
"all",
"the",
"possible",
"interpretations",
"given",
"a",
"set",
"of",
"symbols"
] | train | https://github.com/MarcoFavorito/flloat/blob/5e6de1bea444b68d46d288834031860a8b2f8c2d/flloat/syntax/pl.py#L30-L43 |
MarcoFavorito/flloat | flloat/syntax/pl.py | PLFormula.minimal_models | def minimal_models(self, alphabet: _Alphabet) -> Set[PLInterpretation]:
"""Find models of min size (i.e. the less number of proposition to True).
Very trivial (and inefficient) algorithm: BRUTE FORCE on all the possible interpretations."""
models = self.all_models(alphabet)
minimal_mode... | python | def minimal_models(self, alphabet: _Alphabet) -> Set[PLInterpretation]:
"""Find models of min size (i.e. the less number of proposition to True).
Very trivial (and inefficient) algorithm: BRUTE FORCE on all the possible interpretations."""
models = self.all_models(alphabet)
minimal_mode... | [
"def",
"minimal_models",
"(",
"self",
",",
"alphabet",
":",
"_Alphabet",
")",
"->",
"Set",
"[",
"PLInterpretation",
"]",
":",
"models",
"=",
"self",
".",
"all_models",
"(",
"alphabet",
")",
"minimal_models",
"=",
"set",
"(",
")",
"for",
"m",
"in",
"model... | Find models of min size (i.e. the less number of proposition to True).
Very trivial (and inefficient) algorithm: BRUTE FORCE on all the possible interpretations. | [
"Find",
"models",
"of",
"min",
"size",
"(",
"i",
".",
"e",
".",
"the",
"less",
"number",
"of",
"proposition",
"to",
"True",
")",
".",
"Very",
"trivial",
"(",
"and",
"inefficient",
")",
"algorithm",
":",
"BRUTE",
"FORCE",
"on",
"all",
"the",
"possible",... | train | https://github.com/MarcoFavorito/flloat/blob/5e6de1bea444b68d46d288834031860a8b2f8c2d/flloat/syntax/pl.py#L46-L59 |
InfoAgeTech/django-core | django_core/db/models/mixins/tokens.py | AbstractTokenModel.save | def save(self, *args, **kwargs):
"""Make sure token is added."""
self.save_prep(instance_or_instances=self)
return super(AbstractTokenModel, self).save(*args, **kwargs) | python | def save(self, *args, **kwargs):
"""Make sure token is added."""
self.save_prep(instance_or_instances=self)
return super(AbstractTokenModel, self).save(*args, **kwargs) | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"save_prep",
"(",
"instance_or_instances",
"=",
"self",
")",
"return",
"super",
"(",
"AbstractTokenModel",
",",
"self",
")",
".",
"save",
"(",
"*",
"args",
... | Make sure token is added. | [
"Make",
"sure",
"token",
"is",
"added",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/db/models/mixins/tokens.py#L17-L20 |
InfoAgeTech/django-core | django_core/db/models/mixins/tokens.py | AbstractTokenModel.save_prep | def save_prep(cls, instance_or_instances):
"""Preprocess the object before the object is saved. This
automatically gets called when the save method gets called.
"""
instances = make_obj_list(instance_or_instances)
tokens = set(cls.objects.get_available_tokens(
count... | python | def save_prep(cls, instance_or_instances):
"""Preprocess the object before the object is saved. This
automatically gets called when the save method gets called.
"""
instances = make_obj_list(instance_or_instances)
tokens = set(cls.objects.get_available_tokens(
count... | [
"def",
"save_prep",
"(",
"cls",
",",
"instance_or_instances",
")",
":",
"instances",
"=",
"make_obj_list",
"(",
"instance_or_instances",
")",
"tokens",
"=",
"set",
"(",
"cls",
".",
"objects",
".",
"get_available_tokens",
"(",
"count",
"=",
"len",
"(",
"instanc... | Preprocess the object before the object is saved. This
automatically gets called when the save method gets called. | [
"Preprocess",
"the",
"object",
"before",
"the",
"object",
"is",
"saved",
".",
"This",
"automatically",
"gets",
"called",
"when",
"the",
"save",
"method",
"gets",
"called",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/db/models/mixins/tokens.py#L23-L40 |
MarcoFavorito/flloat | flloat/base/Formula.py | BinaryOperator._popup | def _popup(self):
"""recursively find commutative binary operator
among child formulas and pop up them at the same level"""
res = ()
for child in self.formulas:
if type(child) == type(self):
superchilds = child.formulas
res += superchilds
... | python | def _popup(self):
"""recursively find commutative binary operator
among child formulas and pop up them at the same level"""
res = ()
for child in self.formulas:
if type(child) == type(self):
superchilds = child.formulas
res += superchilds
... | [
"def",
"_popup",
"(",
"self",
")",
":",
"res",
"=",
"(",
")",
"for",
"child",
"in",
"self",
".",
"formulas",
":",
"if",
"type",
"(",
"child",
")",
"==",
"type",
"(",
"self",
")",
":",
"superchilds",
"=",
"child",
".",
"formulas",
"res",
"+=",
"su... | recursively find commutative binary operator
among child formulas and pop up them at the same level | [
"recursively",
"find",
"commutative",
"binary",
"operator",
"among",
"child",
"formulas",
"and",
"pop",
"up",
"them",
"at",
"the",
"same",
"level"
] | train | https://github.com/MarcoFavorito/flloat/blob/5e6de1bea444b68d46d288834031860a8b2f8c2d/flloat/base/Formula.py#L80-L90 |
InfoAgeTech/django-core | django_core/views/mixins/generic.py | GenericObjectViewMixin.get_content_object_url | def get_content_object_url(self):
"""Gets the absolute url for the content object."""
if (self.content_object and
hasattr(self.content_object, 'get_absolute_url')):
return self.content_object.get_absolute_url()
return None | python | def get_content_object_url(self):
"""Gets the absolute url for the content object."""
if (self.content_object and
hasattr(self.content_object, 'get_absolute_url')):
return self.content_object.get_absolute_url()
return None | [
"def",
"get_content_object_url",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"content_object",
"and",
"hasattr",
"(",
"self",
".",
"content_object",
",",
"'get_absolute_url'",
")",
")",
":",
"return",
"self",
".",
"content_object",
".",
"get_absolute_url",
... | Gets the absolute url for the content object. | [
"Gets",
"the",
"absolute",
"url",
"for",
"the",
"content",
"object",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/views/mixins/generic.py#L49-L55 |
MarcoFavorito/flloat | flloat/parser/ldlf.py | LDLfLexer.t_ATOM | def t_ATOM(self, t):
r'[a-zA-Z_][a-zA-Z_0-9]*'
t.type = LDLfLexer.reserved.get(t.value, 'ATOM') # Check for reserved words
return t | python | def t_ATOM(self, t):
r'[a-zA-Z_][a-zA-Z_0-9]*'
t.type = LDLfLexer.reserved.get(t.value, 'ATOM') # Check for reserved words
return t | [
"def",
"t_ATOM",
"(",
"self",
",",
"t",
")",
":",
"t",
".",
"type",
"=",
"LDLfLexer",
".",
"reserved",
".",
"get",
"(",
"t",
".",
"value",
",",
"'ATOM'",
")",
"# Check for reserved words",
"return",
"t"
] | r'[a-zA-Z_][a-zA-Z_0-9]* | [
"r",
"[",
"a",
"-",
"zA",
"-",
"Z_",
"]",
"[",
"a",
"-",
"zA",
"-",
"Z_0",
"-",
"9",
"]",
"*"
] | train | https://github.com/MarcoFavorito/flloat/blob/5e6de1bea444b68d46d288834031860a8b2f8c2d/flloat/parser/ldlf.py#L63-L66 |
MarcoFavorito/flloat | flloat/parser/ldlf.py | LDLfParser.p_temp_formula | def p_temp_formula(self, p):
"""temp_formula : temp_formula EQUIVALENCE temp_formula
| temp_formula IMPLIES temp_formula
| temp_formula OR temp_formula
| temp_formula AND temp_formula
| BOXLSEPARATOR path BOXRSEPARAT... | python | def p_temp_formula(self, p):
"""temp_formula : temp_formula EQUIVALENCE temp_formula
| temp_formula IMPLIES temp_formula
| temp_formula OR temp_formula
| temp_formula AND temp_formula
| BOXLSEPARATOR path BOXRSEPARAT... | [
"def",
"p_temp_formula",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"2",
":",
"if",
"p",
"[",
"1",
"]",
"==",
"Symbols",
".",
"LOGICAL_TRUE",
".",
"value",
":",
"p",
"[",
"0",
"]",
"=",
"LDLfLogicalTrue",
"(",
")",
"elif... | temp_formula : temp_formula EQUIVALENCE temp_formula
| temp_formula IMPLIES temp_formula
| temp_formula OR temp_formula
| temp_formula AND temp_formula
| BOXLSEPARATOR path BOXRSEPARATOR temp_formula
... | [
"temp_formula",
":",
"temp_formula",
"EQUIVALENCE",
"temp_formula",
"|",
"temp_formula",
"IMPLIES",
"temp_formula",
"|",
"temp_formula",
"OR",
"temp_formula",
"|",
"temp_formula",
"AND",
"temp_formula",
"|",
"BOXLSEPARATOR",
"path",
"BOXRSEPARATOR",
"temp_formula",
"|",
... | train | https://github.com/MarcoFavorito/flloat/blob/5e6de1bea444b68d46d288834031860a8b2f8c2d/flloat/parser/ldlf.py#L92-L137 |
MarcoFavorito/flloat | flloat/parser/ldlf.py | LDLfParser.p_path | def p_path(self, p):
"""path : path UNION path
| path SEQ path
| path STAR
| temp_formula TEST
| propositional"""
if len(p)==2:
p[0] = RegExpPropositional(p[1])
elif len(p)==3:
if p[2]==Symbols.PATH_TEST.val... | python | def p_path(self, p):
"""path : path UNION path
| path SEQ path
| path STAR
| temp_formula TEST
| propositional"""
if len(p)==2:
p[0] = RegExpPropositional(p[1])
elif len(p)==3:
if p[2]==Symbols.PATH_TEST.val... | [
"def",
"p_path",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"2",
":",
"p",
"[",
"0",
"]",
"=",
"RegExpPropositional",
"(",
"p",
"[",
"1",
"]",
")",
"elif",
"len",
"(",
"p",
")",
"==",
"3",
":",
"if",
"p",
"[",
"2",... | path : path UNION path
| path SEQ path
| path STAR
| temp_formula TEST
| propositional | [
"path",
":",
"path",
"UNION",
"path",
"|",
"path",
"SEQ",
"path",
"|",
"path",
"STAR",
"|",
"temp_formula",
"TEST",
"|",
"propositional"
] | train | https://github.com/MarcoFavorito/flloat/blob/5e6de1bea444b68d46d288834031860a8b2f8c2d/flloat/parser/ldlf.py#L143-L167 |
MarcoFavorito/flloat | flloat/parser/ldlf.py | LDLfParser.p_propositional | def p_propositional(self, p):
"""propositional : propositional EQUIVALENCE propositional
| propositional IMPLIES propositional
| propositional OR propositional
| propositional AND propositional
| NOT propositiona... | python | def p_propositional(self, p):
"""propositional : propositional EQUIVALENCE propositional
| propositional IMPLIES propositional
| propositional OR propositional
| propositional AND propositional
| NOT propositiona... | [
"def",
"p_propositional",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"4",
":",
"if",
"p",
"[",
"2",
"]",
"==",
"Symbols",
".",
"EQUIVALENCE",
".",
"value",
":",
"p",
"[",
"0",
"]",
"=",
"PLEquivalence",
"(",
"[",
"p",
... | propositional : propositional EQUIVALENCE propositional
| propositional IMPLIES propositional
| propositional OR propositional
| propositional AND propositional
| NOT propositional
| FALSE
... | [
"propositional",
":",
"propositional",
"EQUIVALENCE",
"propositional",
"|",
"propositional",
"IMPLIES",
"propositional",
"|",
"propositional",
"OR",
"propositional",
"|",
"propositional",
"AND",
"propositional",
"|",
"NOT",
"propositional",
"|",
"FALSE",
"|",
"TRUE",
... | train | https://github.com/MarcoFavorito/flloat/blob/5e6de1bea444b68d46d288834031860a8b2f8c2d/flloat/parser/ldlf.py#L170-L202 |
divio/aldryn-sites | aldryn_sites/utils.py | get_redirect_url | def get_redirect_url(current_url, config, https=None):
"""
priorities are (primary domain and aliases are treated the same):
exact redirect match > exact alias match > pattern redirect match > pattern alias match
:param current_url: the url that is being called
:param config: redirect configurat... | python | def get_redirect_url(current_url, config, https=None):
"""
priorities are (primary domain and aliases are treated the same):
exact redirect match > exact alias match > pattern redirect match > pattern alias match
:param current_url: the url that is being called
:param config: redirect configurat... | [
"def",
"get_redirect_url",
"(",
"current_url",
",",
"config",
",",
"https",
"=",
"None",
")",
":",
"primary_domain",
"=",
"config",
"[",
"'domain'",
"]",
"domains",
"=",
"set",
"(",
"config",
".",
"get",
"(",
"'aliases'",
",",
"[",
"]",
")",
")",
"|",
... | priorities are (primary domain and aliases are treated the same):
exact redirect match > exact alias match > pattern redirect match > pattern alias match
:param current_url: the url that is being called
:param config: redirect configuration for this url
:param want_https: whether redirects should go... | [
"priorities",
"are",
"(",
"primary",
"domain",
"and",
"aliases",
"are",
"treated",
"the",
"same",
")",
":",
"exact",
"redirect",
"match",
">",
"exact",
"alias",
"match",
">",
"pattern",
"redirect",
"match",
">",
"pattern",
"alias",
"match",
":",
"param",
"... | train | https://github.com/divio/aldryn-sites/blob/338ed016f5ad046201256f56dde0c19ef144faf0/aldryn_sites/utils.py#L39-L86 |
txomon/abot | abot/cli.py | AsyncCommandMixin.invoke | def invoke(self, ctx):
"""Given a context, this invokes the attached callback (if it exists)
in the right way.
"""
if self.callback is not None:
loop = asyncio.get_event_loop()
return loop.run_until_complete(self.async_invoke(ctx)) | python | def invoke(self, ctx):
"""Given a context, this invokes the attached callback (if it exists)
in the right way.
"""
if self.callback is not None:
loop = asyncio.get_event_loop()
return loop.run_until_complete(self.async_invoke(ctx)) | [
"def",
"invoke",
"(",
"self",
",",
"ctx",
")",
":",
"if",
"self",
".",
"callback",
"is",
"not",
"None",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"return",
"loop",
".",
"run_until_complete",
"(",
"self",
".",
"async_invoke",
"(",
"c... | Given a context, this invokes the attached callback (if it exists)
in the right way. | [
"Given",
"a",
"context",
"this",
"invokes",
"the",
"attached",
"callback",
"(",
"if",
"it",
"exists",
")",
"in",
"the",
"right",
"way",
"."
] | train | https://github.com/txomon/abot/blob/3ac23c6d14965d4608ed13c284ae1a886b462252/abot/cli.py#L43-L49 |
txomon/abot | abot/cli.py | AsyncCommandMixin.get_help_option | def get_help_option(self, ctx):
"""Returns the help option object."""
help_options = self.get_help_option_names(ctx)
if not help_options or not self.add_help_option:
return
def show_help(ctx, param, value):
import abot.bot
if value and not ctx.resilie... | python | def get_help_option(self, ctx):
"""Returns the help option object."""
help_options = self.get_help_option_names(ctx)
if not help_options or not self.add_help_option:
return
def show_help(ctx, param, value):
import abot.bot
if value and not ctx.resilie... | [
"def",
"get_help_option",
"(",
"self",
",",
"ctx",
")",
":",
"help_options",
"=",
"self",
".",
"get_help_option_names",
"(",
"ctx",
")",
"if",
"not",
"help_options",
"or",
"not",
"self",
".",
"add_help_option",
":",
"return",
"def",
"show_help",
"(",
"ctx",
... | Returns the help option object. | [
"Returns",
"the",
"help",
"option",
"object",
"."
] | train | https://github.com/txomon/abot/blob/3ac23c6d14965d4608ed13c284ae1a886b462252/abot/cli.py#L64-L80 |
InfoAgeTech/django-core | django_core/forms/widgets.py | MultipleDecimalInputWidget.get_widget_css_class | def get_widget_css_class(self, attrs):
"""Gets the class for the widget."""
size_class = 'size-{0}'.format(self.num_inputs)
if 'class' in attrs:
attrs['class'] += ' {0}'.format(size_class)
else:
attrs['class'] = size_class | python | def get_widget_css_class(self, attrs):
"""Gets the class for the widget."""
size_class = 'size-{0}'.format(self.num_inputs)
if 'class' in attrs:
attrs['class'] += ' {0}'.format(size_class)
else:
attrs['class'] = size_class | [
"def",
"get_widget_css_class",
"(",
"self",
",",
"attrs",
")",
":",
"size_class",
"=",
"'size-{0}'",
".",
"format",
"(",
"self",
".",
"num_inputs",
")",
"if",
"'class'",
"in",
"attrs",
":",
"attrs",
"[",
"'class'",
"]",
"+=",
"' {0}'",
".",
"format",
"("... | Gets the class for the widget. | [
"Gets",
"the",
"class",
"for",
"the",
"widget",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/forms/widgets.py#L78-L85 |
MarcoFavorito/flloat | flloat/parser/pl.py | PLLexer.t_ATOM | def t_ATOM(self, t):
r'[a-zA-Z_][a-zA-Z_0-9]*'
t.type = PLLexer.reserved.get(t.value, 'ATOM') # Check for reserved words
return t | python | def t_ATOM(self, t):
r'[a-zA-Z_][a-zA-Z_0-9]*'
t.type = PLLexer.reserved.get(t.value, 'ATOM') # Check for reserved words
return t | [
"def",
"t_ATOM",
"(",
"self",
",",
"t",
")",
":",
"t",
".",
"type",
"=",
"PLLexer",
".",
"reserved",
".",
"get",
"(",
"t",
".",
"value",
",",
"'ATOM'",
")",
"# Check for reserved words",
"return",
"t"
] | r'[a-zA-Z_][a-zA-Z_0-9]* | [
"r",
"[",
"a",
"-",
"zA",
"-",
"Z_",
"]",
"[",
"a",
"-",
"zA",
"-",
"Z_0",
"-",
"9",
"]",
"*"
] | train | https://github.com/MarcoFavorito/flloat/blob/5e6de1bea444b68d46d288834031860a8b2f8c2d/flloat/parser/pl.py#L41-L44 |
MarcoFavorito/flloat | flloat/parser/pl.py | PLParser.p_formula_atom | def p_formula_atom(self, p):
"""formula : ATOM
| TRUE
| FALSE"""
if p[1]==Symbols.TRUE.value:
p[0] = PLTrue()
elif p[1]==Symbols.FALSE.value:
p[0] = PLFalse()
else:
p[0] = PLAtomic(Symbol(p[1])) | python | def p_formula_atom(self, p):
"""formula : ATOM
| TRUE
| FALSE"""
if p[1]==Symbols.TRUE.value:
p[0] = PLTrue()
elif p[1]==Symbols.FALSE.value:
p[0] = PLFalse()
else:
p[0] = PLAtomic(Symbol(p[1])) | [
"def",
"p_formula_atom",
"(",
"self",
",",
"p",
")",
":",
"if",
"p",
"[",
"1",
"]",
"==",
"Symbols",
".",
"TRUE",
".",
"value",
":",
"p",
"[",
"0",
"]",
"=",
"PLTrue",
"(",
")",
"elif",
"p",
"[",
"1",
"]",
"==",
"Symbols",
".",
"FALSE",
".",
... | formula : ATOM
| TRUE
| FALSE | [
"formula",
":",
"ATOM",
"|",
"TRUE",
"|",
"FALSE"
] | train | https://github.com/MarcoFavorito/flloat/blob/5e6de1bea444b68d46d288834031860a8b2f8c2d/flloat/parser/pl.py#L60-L69 |
InfoAgeTech/django-core | django_core/db/models/managers.py | BaseManager.get_or_none | def get_or_none(self, prefetch_related=None, select_related=False,
**kwargs):
"""Gets a single object based on kwargs or None if one is not found.
:param prefetch_related: list or tuple of fields to prefetch for an
object. This takes precedence over select_related.
... | python | def get_or_none(self, prefetch_related=None, select_related=False,
**kwargs):
"""Gets a single object based on kwargs or None if one is not found.
:param prefetch_related: list or tuple of fields to prefetch for an
object. This takes precedence over select_related.
... | [
"def",
"get_or_none",
"(",
"self",
",",
"prefetch_related",
"=",
"None",
",",
"select_related",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"if",
"prefetch_related",
":",
"query_set",
"=",
"self",
".",
"prefetch_related",
"(",
"*",
"prefet... | Gets a single object based on kwargs or None if one is not found.
:param prefetch_related: list or tuple of fields to prefetch for an
object. This takes precedence over select_related.
Example:
>> get_or_none(prefetch_related=['some_field',
... ... | [
"Gets",
"a",
"single",
"object",
"based",
"on",
"kwargs",
"or",
"None",
"if",
"one",
"is",
"not",
"found",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/db/models/managers.py#L14-L59 |
InfoAgeTech/django-core | django_core/db/models/managers.py | CommonManager.get_by_id_or_404 | def get_by_id_or_404(self, id, **kwargs):
"""Gets by a instance instance r raises a 404 is one isn't found."""
obj = self.get_by_id(id=id, **kwargs)
if obj:
return obj
raise Http404 | python | def get_by_id_or_404(self, id, **kwargs):
"""Gets by a instance instance r raises a 404 is one isn't found."""
obj = self.get_by_id(id=id, **kwargs)
if obj:
return obj
raise Http404 | [
"def",
"get_by_id_or_404",
"(",
"self",
",",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"self",
".",
"get_by_id",
"(",
"id",
"=",
"id",
",",
"*",
"*",
"kwargs",
")",
"if",
"obj",
":",
"return",
"obj",
"raise",
"Http404"
] | Gets by a instance instance r raises a 404 is one isn't found. | [
"Gets",
"by",
"a",
"instance",
"instance",
"r",
"raises",
"a",
"404",
"is",
"one",
"isn",
"t",
"found",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/db/models/managers.py#L71-L78 |
InfoAgeTech/django-core | django_core/db/models/managers.py | CommonManager.bulk_create | def bulk_create(self, objs, *args, **kwargs):
"""Insert many object at once."""
if hasattr(self.model, 'save_prep'):
# Method from AbstractBaseModel. If the model class doesn't
# subclass AbstractBaseModel, then don't call this.
self.model.save_prep(instance_or_instan... | python | def bulk_create(self, objs, *args, **kwargs):
"""Insert many object at once."""
if hasattr(self.model, 'save_prep'):
# Method from AbstractBaseModel. If the model class doesn't
# subclass AbstractBaseModel, then don't call this.
self.model.save_prep(instance_or_instan... | [
"def",
"bulk_create",
"(",
"self",
",",
"objs",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"model",
",",
"'save_prep'",
")",
":",
"# Method from AbstractBaseModel. If the model class doesn't",
"# subclass AbstractBaseMo... | Insert many object at once. | [
"Insert",
"many",
"object",
"at",
"once",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/db/models/managers.py#L89-L98 |
InfoAgeTech/django-core | django_core/db/models/managers.py | CommonManager.delete_by_ids | def delete_by_ids(self, ids):
"""Delete objects by ids.
:param ids: list of objects ids to delete.
:return: True if objects were deleted. Otherwise, return False if no
objects were found or the delete was not successful.
"""
try:
self.filter(id__in=i... | python | def delete_by_ids(self, ids):
"""Delete objects by ids.
:param ids: list of objects ids to delete.
:return: True if objects were deleted. Otherwise, return False if no
objects were found or the delete was not successful.
"""
try:
self.filter(id__in=i... | [
"def",
"delete_by_ids",
"(",
"self",
",",
"ids",
")",
":",
"try",
":",
"self",
".",
"filter",
"(",
"id__in",
"=",
"ids",
")",
".",
"delete",
"(",
")",
"return",
"True",
"except",
"self",
".",
"model",
".",
"DoesNotExist",
":",
"return",
"False"
] | Delete objects by ids.
:param ids: list of objects ids to delete.
:return: True if objects were deleted. Otherwise, return False if no
objects were found or the delete was not successful. | [
"Delete",
"objects",
"by",
"ids",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/db/models/managers.py#L104-L115 |
InfoAgeTech/django-core | django_core/db/models/managers.py | SlugManager.is_slug_available | def is_slug_available(self, slug, **kwargs):
"""Checks to see if a slug is available. If the slug is already being used
this method returns False. Otherwise, return True.
"""
try:
self.get(slug=slug, **kwargs)
return False
except self.model.DoesNotExist:
... | python | def is_slug_available(self, slug, **kwargs):
"""Checks to see if a slug is available. If the slug is already being used
this method returns False. Otherwise, return True.
"""
try:
self.get(slug=slug, **kwargs)
return False
except self.model.DoesNotExist:
... | [
"def",
"is_slug_available",
"(",
"self",
",",
"slug",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"get",
"(",
"slug",
"=",
"slug",
",",
"*",
"*",
"kwargs",
")",
"return",
"False",
"except",
"self",
".",
"model",
".",
"DoesNotExist",
... | Checks to see if a slug is available. If the slug is already being used
this method returns False. Otherwise, return True. | [
"Checks",
"to",
"see",
"if",
"a",
"slug",
"is",
"available",
".",
"If",
"the",
"slug",
"is",
"already",
"being",
"used",
"this",
"method",
"returns",
"False",
".",
"Otherwise",
"return",
"True",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/db/models/managers.py#L135-L143 |
InfoAgeTech/django-core | django_core/db/models/managers.py | SlugManager.get_next_slug | def get_next_slug(self, slug, **kwargs):
"""Gets the next available slug.
:param slug: the slug to slugify
:param kwargs: additional filter criteria to check for when looking for
a unique slug.
Example:
if the value "my-slug" is already taken, this method will appe... | python | def get_next_slug(self, slug, **kwargs):
"""Gets the next available slug.
:param slug: the slug to slugify
:param kwargs: additional filter criteria to check for when looking for
a unique slug.
Example:
if the value "my-slug" is already taken, this method will appe... | [
"def",
"get_next_slug",
"(",
"self",
",",
"slug",
",",
"*",
"*",
"kwargs",
")",
":",
"original_slug",
"=",
"slug",
"=",
"slugify",
"(",
"slug",
")",
"count",
"=",
"0",
"while",
"not",
"self",
".",
"is_slug_available",
"(",
"slug",
"=",
"slug",
",",
"... | Gets the next available slug.
:param slug: the slug to slugify
:param kwargs: additional filter criteria to check for when looking for
a unique slug.
Example:
if the value "my-slug" is already taken, this method will append "-n"
to the end of the slug until the nex... | [
"Gets",
"the",
"next",
"available",
"slug",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/db/models/managers.py#L145-L165 |
InfoAgeTech/django-core | django_core/db/models/managers.py | TokenManager.get_next_token | def get_next_token(self, length=15, **kwargs):
"""Gets the next available token.
:param length: length of the token
:param kwargs: additional filter criteria to check for when looking for
a unique token.
"""
return self.get_available_tokens(count=1,
... | python | def get_next_token(self, length=15, **kwargs):
"""Gets the next available token.
:param length: length of the token
:param kwargs: additional filter criteria to check for when looking for
a unique token.
"""
return self.get_available_tokens(count=1,
... | [
"def",
"get_next_token",
"(",
"self",
",",
"length",
"=",
"15",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"get_available_tokens",
"(",
"count",
"=",
"1",
",",
"token_length",
"=",
"length",
",",
"*",
"*",
"kwargs",
")",
"[",
"0",
"]"
... | Gets the next available token.
:param length: length of the token
:param kwargs: additional filter criteria to check for when looking for
a unique token. | [
"Gets",
"the",
"next",
"available",
"token",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/db/models/managers.py#L183-L193 |
InfoAgeTech/django-core | django_core/db/models/managers.py | TokenManager.get_available_tokens | def get_available_tokens(self, count=10, token_length=15, **kwargs):
"""Gets a list of available tokens.
:param count: the number of tokens to return.
:param token_length: the length of the tokens. The higher the number
the easier it will be to return a list. If token_length == 1
... | python | def get_available_tokens(self, count=10, token_length=15, **kwargs):
"""Gets a list of available tokens.
:param count: the number of tokens to return.
:param token_length: the length of the tokens. The higher the number
the easier it will be to return a list. If token_length == 1
... | [
"def",
"get_available_tokens",
"(",
"self",
",",
"count",
"=",
"10",
",",
"token_length",
"=",
"15",
",",
"*",
"*",
"kwargs",
")",
":",
"# This is the number of extra tokens to try and retrieve so calls to",
"# the db can be limited",
"token_buffer",
"=",
"int",
"(",
... | Gets a list of available tokens.
:param count: the number of tokens to return.
:param token_length: the length of the tokens. The higher the number
the easier it will be to return a list. If token_length == 1
there's a strong probability that the enough tokens will exist in
... | [
"Gets",
"a",
"list",
"of",
"available",
"tokens",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/db/models/managers.py#L195-L222 |
InfoAgeTech/django-core | django_core/db/models/managers.py | GenericManager.create_generic | def create_generic(self, content_object=None, **kwargs):
"""Create a generic object.
:param content_object: the content object to create a new object for.
"""
if content_object:
kwargs['content_type'] = ContentType.objects.get_for_model(
content_object
... | python | def create_generic(self, content_object=None, **kwargs):
"""Create a generic object.
:param content_object: the content object to create a new object for.
"""
if content_object:
kwargs['content_type'] = ContentType.objects.get_for_model(
content_object
... | [
"def",
"create_generic",
"(",
"self",
",",
"content_object",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"content_object",
":",
"kwargs",
"[",
"'content_type'",
"]",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"content_object",
"... | Create a generic object.
:param content_object: the content object to create a new object for. | [
"Create",
"a",
"generic",
"object",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/db/models/managers.py#L241-L252 |
InfoAgeTech/django-core | django_core/db/models/managers.py | GenericManager.filter_generic | def filter_generic(self, content_object=None, **kwargs):
"""Filter by a generic object.
:param content_object: the content object to filter on.
"""
if content_object:
kwargs['content_type'] = ContentType.objects.get_for_model(
content_object
)
... | python | def filter_generic(self, content_object=None, **kwargs):
"""Filter by a generic object.
:param content_object: the content object to filter on.
"""
if content_object:
kwargs['content_type'] = ContentType.objects.get_for_model(
content_object
)
... | [
"def",
"filter_generic",
"(",
"self",
",",
"content_object",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"content_object",
":",
"kwargs",
"[",
"'content_type'",
"]",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"content_object",
"... | Filter by a generic object.
:param content_object: the content object to filter on. | [
"Filter",
"by",
"a",
"generic",
"object",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/db/models/managers.py#L254-L265 |
InfoAgeTech/django-core | django_core/db/models/managers.py | GenericManager.get_or_create_generic | def get_or_create_generic(self, content_object=None, **kwargs):
"""Gets or creates a generic object. This is a wrapper for
get_or_create(...) when you need to get or create a generic object.
:param obj: the object to get or create
:param kwargs: any other kwargs that the model accepts.... | python | def get_or_create_generic(self, content_object=None, **kwargs):
"""Gets or creates a generic object. This is a wrapper for
get_or_create(...) when you need to get or create a generic object.
:param obj: the object to get or create
:param kwargs: any other kwargs that the model accepts.... | [
"def",
"get_or_create_generic",
"(",
"self",
",",
"content_object",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"content_object",
":",
"kwargs",
"[",
"'content_type'",
"]",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"content_objec... | Gets or creates a generic object. This is a wrapper for
get_or_create(...) when you need to get or create a generic object.
:param obj: the object to get or create
:param kwargs: any other kwargs that the model accepts. | [
"Gets",
"or",
"creates",
"a",
"generic",
"object",
".",
"This",
"is",
"a",
"wrapper",
"for",
"get_or_create",
"(",
"...",
")",
"when",
"you",
"need",
"to",
"get",
"or",
"create",
"a",
"generic",
"object",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/db/models/managers.py#L267-L280 |
InfoAgeTech/django-core | django_core/db/models/managers.py | GenericManager.get_by_model | def get_by_model(self, model):
"""Gets all object by a specific model."""
content_type = ContentType.objects.get_for_model(model)
return self.filter(content_type=content_type) | python | def get_by_model(self, model):
"""Gets all object by a specific model."""
content_type = ContentType.objects.get_for_model(model)
return self.filter(content_type=content_type) | [
"def",
"get_by_model",
"(",
"self",
",",
"model",
")",
":",
"content_type",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"model",
")",
"return",
"self",
".",
"filter",
"(",
"content_type",
"=",
"content_type",
")"
] | Gets all object by a specific model. | [
"Gets",
"all",
"object",
"by",
"a",
"specific",
"model",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/db/models/managers.py#L286-L289 |
InfoAgeTech/django-core | django_core/templatetags/collection_tags.py | attr | def attr(obj, attr):
"""
Does the same thing as getattr.
getattr(obj, attr, '')
"""
if not obj or not hasattr(obj, attr):
return ''
return getattr(obj, attr, '') | python | def attr(obj, attr):
"""
Does the same thing as getattr.
getattr(obj, attr, '')
"""
if not obj or not hasattr(obj, attr):
return ''
return getattr(obj, attr, '') | [
"def",
"attr",
"(",
"obj",
",",
"attr",
")",
":",
"if",
"not",
"obj",
"or",
"not",
"hasattr",
"(",
"obj",
",",
"attr",
")",
":",
"return",
"''",
"return",
"getattr",
"(",
"obj",
",",
"attr",
",",
"''",
")"
] | Does the same thing as getattr.
getattr(obj, attr, '') | [
"Does",
"the",
"same",
"thing",
"as",
"getattr",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/templatetags/collection_tags.py#L29-L38 |
InfoAgeTech/django-core | django_core/templatetags/collection_tags.py | make_iterable | def make_iterable(obj):
"""Make an object iterable.
>>> make_iterable(obj='hello')
('hello',)
>>> make_iterable(obj=None)
()
"""
if not obj:
return tuple()
if isinstance(obj, (list, tuple, set)):
return obj
return (obj,) | python | def make_iterable(obj):
"""Make an object iterable.
>>> make_iterable(obj='hello')
('hello',)
>>> make_iterable(obj=None)
()
"""
if not obj:
return tuple()
if isinstance(obj, (list, tuple, set)):
return obj
return (obj,) | [
"def",
"make_iterable",
"(",
"obj",
")",
":",
"if",
"not",
"obj",
":",
"return",
"tuple",
"(",
")",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"list",
",",
"tuple",
",",
"set",
")",
")",
":",
"return",
"obj",
"return",
"(",
"obj",
",",
")"
] | Make an object iterable.
>>> make_iterable(obj='hello')
('hello',)
>>> make_iterable(obj=None)
() | [
"Make",
"an",
"object",
"iterable",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/templatetags/collection_tags.py#L48-L62 |
InfoAgeTech/django-core | django_core/views/request.py | ApiFormView.get_form_kwargs | def get_form_kwargs(self):
"""Add the 'data' to the form args so you can validate the form
data on a get request.
"""
kwargs = super(ApiFormView, self).get_form_kwargs()
kwargs['data'] = kwargs.get('initial')
return kwargs | python | def get_form_kwargs(self):
"""Add the 'data' to the form args so you can validate the form
data on a get request.
"""
kwargs = super(ApiFormView, self).get_form_kwargs()
kwargs['data'] = kwargs.get('initial')
return kwargs | [
"def",
"get_form_kwargs",
"(",
"self",
")",
":",
"kwargs",
"=",
"super",
"(",
"ApiFormView",
",",
"self",
")",
".",
"get_form_kwargs",
"(",
")",
"kwargs",
"[",
"'data'",
"]",
"=",
"kwargs",
".",
"get",
"(",
"'initial'",
")",
"return",
"kwargs"
] | Add the 'data' to the form args so you can validate the form
data on a get request. | [
"Add",
"the",
"data",
"to",
"the",
"form",
"args",
"so",
"you",
"can",
"validate",
"the",
"form",
"data",
"on",
"a",
"get",
"request",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/views/request.py#L22-L28 |
InfoAgeTech/django-core | django_core/views/request.py | ApiFormView.form_invalid | def form_invalid(self, form, context=None, **kwargs):
"""This will return the request with form errors as well as any
additional context.
"""
if not context:
context = {}
context['errors'] = form.errors
return super(ApiFormView, self).render_to_response(conte... | python | def form_invalid(self, form, context=None, **kwargs):
"""This will return the request with form errors as well as any
additional context.
"""
if not context:
context = {}
context['errors'] = form.errors
return super(ApiFormView, self).render_to_response(conte... | [
"def",
"form_invalid",
"(",
"self",
",",
"form",
",",
"context",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"context",
":",
"context",
"=",
"{",
"}",
"context",
"[",
"'errors'",
"]",
"=",
"form",
".",
"errors",
"return",
"super",
... | This will return the request with form errors as well as any
additional context. | [
"This",
"will",
"return",
"the",
"request",
"with",
"form",
"errors",
"as",
"well",
"as",
"any",
"additional",
"context",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/views/request.py#L30-L39 |
InfoAgeTech/django-core | django_core/utils/validators.py | is_valid_hex | def is_valid_hex(value):
"""Boolean indicating of the value is a valid hex value."""
if not value:
return False
regex = re.compile(HEX_COLOR_REGEX)
return bool(regex.match(value)) | python | def is_valid_hex(value):
"""Boolean indicating of the value is a valid hex value."""
if not value:
return False
regex = re.compile(HEX_COLOR_REGEX)
return bool(regex.match(value)) | [
"def",
"is_valid_hex",
"(",
"value",
")",
":",
"if",
"not",
"value",
":",
"return",
"False",
"regex",
"=",
"re",
".",
"compile",
"(",
"HEX_COLOR_REGEX",
")",
"return",
"bool",
"(",
"regex",
".",
"match",
"(",
"value",
")",
")"
] | Boolean indicating of the value is a valid hex value. | [
"Boolean",
"indicating",
"of",
"the",
"value",
"is",
"a",
"valid",
"hex",
"value",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/utils/validators.py#L34-L40 |
InfoAgeTech/django-core | django_core/utils/validators.py | is_valid_rgb_color | def is_valid_rgb_color(value):
"""Checks whether the value is a valid rgb or rgba color string.
Valid colors consist of:
- rgb(255, 255, 255)
- rgba(23, 34, 45, .5)
"""
if not value:
return False
regex = re.compile(RGB_COLOR_REGEX)
return bool(regex.match(value)) | python | def is_valid_rgb_color(value):
"""Checks whether the value is a valid rgb or rgba color string.
Valid colors consist of:
- rgb(255, 255, 255)
- rgba(23, 34, 45, .5)
"""
if not value:
return False
regex = re.compile(RGB_COLOR_REGEX)
return bool(regex.match(value)) | [
"def",
"is_valid_rgb_color",
"(",
"value",
")",
":",
"if",
"not",
"value",
":",
"return",
"False",
"regex",
"=",
"re",
".",
"compile",
"(",
"RGB_COLOR_REGEX",
")",
"return",
"bool",
"(",
"regex",
".",
"match",
"(",
"value",
")",
")"
] | Checks whether the value is a valid rgb or rgba color string.
Valid colors consist of:
- rgb(255, 255, 255)
- rgba(23, 34, 45, .5) | [
"Checks",
"whether",
"the",
"value",
"is",
"a",
"valid",
"rgb",
"or",
"rgba",
"color",
"string",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/utils/validators.py#L51-L63 |
InfoAgeTech/django-core | django_core/utils/validators.py | validate_password_strength | def validate_password_strength(value):
"""Validates that a password is as least 7 characters long and has at least
1 digit and 1 letter.
"""
min_length = 7
if len(value) < min_length:
raise ValidationError(_('Password must be at least {0} characters '
'long.'... | python | def validate_password_strength(value):
"""Validates that a password is as least 7 characters long and has at least
1 digit and 1 letter.
"""
min_length = 7
if len(value) < min_length:
raise ValidationError(_('Password must be at least {0} characters '
'long.'... | [
"def",
"validate_password_strength",
"(",
"value",
")",
":",
"min_length",
"=",
"7",
"if",
"len",
"(",
"value",
")",
"<",
"min_length",
":",
"raise",
"ValidationError",
"(",
"_",
"(",
"'Password must be at least {0} characters '",
"'long.'",
")",
".",
"format",
... | Validates that a password is as least 7 characters long and has at least
1 digit and 1 letter. | [
"Validates",
"that",
"a",
"password",
"is",
"as",
"least",
"7",
"characters",
"long",
"and",
"has",
"at",
"least",
"1",
"digit",
"and",
"1",
"letter",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/utils/validators.py#L66-L82 |
dls-controls/annotypes | annotypes/_compat.py | add_metaclass | def add_metaclass(metaclass):
"""Class decorator for creating a class with a metaclass."""
def wrapper(cls):
orig_vars = cls.__dict__.copy()
orig_vars.pop('__dict__', None)
orig_vars.pop('__weakref__', None)
return metaclass(cls.__name__, cls.__bases__, orig_vars)
return wrap... | python | def add_metaclass(metaclass):
"""Class decorator for creating a class with a metaclass."""
def wrapper(cls):
orig_vars = cls.__dict__.copy()
orig_vars.pop('__dict__', None)
orig_vars.pop('__weakref__', None)
return metaclass(cls.__name__, cls.__bases__, orig_vars)
return wrap... | [
"def",
"add_metaclass",
"(",
"metaclass",
")",
":",
"def",
"wrapper",
"(",
"cls",
")",
":",
"orig_vars",
"=",
"cls",
".",
"__dict__",
".",
"copy",
"(",
")",
"orig_vars",
".",
"pop",
"(",
"'__dict__'",
",",
"None",
")",
"orig_vars",
".",
"pop",
"(",
"... | Class decorator for creating a class with a metaclass. | [
"Class",
"decorator",
"for",
"creating",
"a",
"class",
"with",
"a",
"metaclass",
"."
] | train | https://github.com/dls-controls/annotypes/blob/31ab68a0367bb70ebd9898e8b9fa9405423465bd/annotypes/_compat.py#L6-L13 |
InfoAgeTech/django-core | django_core/forms/fields.py | MultipleDecimalField.clean | def clean(self, value):
"""Validates that the input can be converted to a list of decimals."""
if not value:
return None
# if any value exists, then add "0" as a placeholder to the remaining
# values.
if isinstance(value, list) and any(value):
for i, item... | python | def clean(self, value):
"""Validates that the input can be converted to a list of decimals."""
if not value:
return None
# if any value exists, then add "0" as a placeholder to the remaining
# values.
if isinstance(value, list) and any(value):
for i, item... | [
"def",
"clean",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"value",
":",
"return",
"None",
"# if any value exists, then add \"0\" as a placeholder to the remaining",
"# values.",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
"and",
"any",
"(",
"value"... | Validates that the input can be converted to a list of decimals. | [
"Validates",
"that",
"the",
"input",
"can",
"be",
"converted",
"to",
"a",
"list",
"of",
"decimals",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/forms/fields.py#L130-L142 |
InfoAgeTech/django-core | django_core/forms/fields.py | MultipleDecimalField.to_python | def to_python(self, value):
"""Validates that the input can be converted to a list of decimals."""
if not value:
return None
if isinstance(value, list):
for index, position_val in enumerate(value):
val = super(MultipleDecimalField, self).to_python(positio... | python | def to_python(self, value):
"""Validates that the input can be converted to a list of decimals."""
if not value:
return None
if isinstance(value, list):
for index, position_val in enumerate(value):
val = super(MultipleDecimalField, self).to_python(positio... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"value",
":",
"return",
"None",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"for",
"index",
",",
"position_val",
"in",
"enumerate",
"(",
"value",
")",
":",
"val",
"=",... | Validates that the input can be converted to a list of decimals. | [
"Validates",
"that",
"the",
"input",
"can",
"be",
"converted",
"to",
"a",
"list",
"of",
"decimals",
"."
] | train | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/forms/fields.py#L162-L172 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.