repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
gtsystem/parallelpipe | parallelpipe.py | Task.run | def run(self):
"""Execute the task on all the input and send the needed number of EXIT at the end"""
input = self._consume()
put_item = self._que_out.put
try:
if input is None: # producer
res = self._callable(*self._args, **self._kwargs)
e... | python | def run(self):
"""Execute the task on all the input and send the needed number of EXIT at the end"""
input = self._consume()
put_item = self._que_out.put
try:
if input is None: # producer
res = self._callable(*self._args, **self._kwargs)
e... | [
"def",
"run",
"(",
"self",
")",
":",
"input",
"=",
"self",
".",
"_consume",
"(",
")",
"put_item",
"=",
"self",
".",
"_que_out",
".",
"put",
"try",
":",
"if",
"input",
"is",
"None",
":",
"res",
"=",
"self",
".",
"_callable",
"(",
"*",
"self",
".",... | Execute the task on all the input and send the needed number of EXIT at the end | [
"Execute",
"the",
"task",
"on",
"all",
"the",
"input",
"and",
"send",
"the",
"needed",
"number",
"of",
"EXIT",
"at",
"the",
"end"
] | b10eba28de6019cbf34e08ac575d31a4c493b39c | https://github.com/gtsystem/parallelpipe/blob/b10eba28de6019cbf34e08ac575d31a4c493b39c/parallelpipe.py#L56-L83 | train |
gtsystem/parallelpipe | parallelpipe.py | Stage.setup | def setup(self, workers=1, qsize=0):
"""Setup the pool parameters like number of workers and output queue size"""
if workers <= 0:
raise ValueError("workers have to be greater then zero")
if qsize < 0:
raise ValueError("qsize have to be greater or equal zero")
sel... | python | def setup(self, workers=1, qsize=0):
"""Setup the pool parameters like number of workers and output queue size"""
if workers <= 0:
raise ValueError("workers have to be greater then zero")
if qsize < 0:
raise ValueError("qsize have to be greater or equal zero")
sel... | [
"def",
"setup",
"(",
"self",
",",
"workers",
"=",
"1",
",",
"qsize",
"=",
"0",
")",
":",
"if",
"workers",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"workers have to be greater then zero\"",
")",
"if",
"qsize",
"<",
"0",
":",
"raise",
"ValueError",
"(... | Setup the pool parameters like number of workers and output queue size | [
"Setup",
"the",
"pool",
"parameters",
"like",
"number",
"of",
"workers",
"and",
"output",
"queue",
"size"
] | b10eba28de6019cbf34e08ac575d31a4c493b39c | https://github.com/gtsystem/parallelpipe/blob/b10eba28de6019cbf34e08ac575d31a4c493b39c/parallelpipe.py#L104-L112 | train |
gtsystem/parallelpipe | parallelpipe.py | Stage.processes | def processes(self):
"""Initialise and return the list of processes associated with this pool"""
if self._processes is None:
self._processes = []
for p in range(self.workers):
t = Task(self._target, self._args, self._kwargs)
t.name = "%s-%d" % (sel... | python | def processes(self):
"""Initialise and return the list of processes associated with this pool"""
if self._processes is None:
self._processes = []
for p in range(self.workers):
t = Task(self._target, self._args, self._kwargs)
t.name = "%s-%d" % (sel... | [
"def",
"processes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_processes",
"is",
"None",
":",
"self",
".",
"_processes",
"=",
"[",
"]",
"for",
"p",
"in",
"range",
"(",
"self",
".",
"workers",
")",
":",
"t",
"=",
"Task",
"(",
"self",
".",
"_targe... | Initialise and return the list of processes associated with this pool | [
"Initialise",
"and",
"return",
"the",
"list",
"of",
"processes",
"associated",
"with",
"this",
"pool"
] | b10eba28de6019cbf34e08ac575d31a4c493b39c | https://github.com/gtsystem/parallelpipe/blob/b10eba28de6019cbf34e08ac575d31a4c493b39c/parallelpipe.py#L115-L124 | train |
gtsystem/parallelpipe | parallelpipe.py | Pipeline.results | def results(self):
"""Start all the tasks and return data on an iterator"""
tt = None
for i, tf in enumerate(self[:-1]):
tt = self[i+1]
q = Queue(tf.qsize)
tf.set_out(q, tt.workers)
tt.set_in(q, tf.workers)
if tt is None: # we have only on... | python | def results(self):
"""Start all the tasks and return data on an iterator"""
tt = None
for i, tf in enumerate(self[:-1]):
tt = self[i+1]
q = Queue(tf.qsize)
tf.set_out(q, tt.workers)
tt.set_in(q, tf.workers)
if tt is None: # we have only on... | [
"def",
"results",
"(",
"self",
")",
":",
"tt",
"=",
"None",
"for",
"i",
",",
"tf",
"in",
"enumerate",
"(",
"self",
"[",
":",
"-",
"1",
"]",
")",
":",
"tt",
"=",
"self",
"[",
"i",
"+",
"1",
"]",
"q",
"=",
"Queue",
"(",
"tf",
".",
"qsize",
... | Start all the tasks and return data on an iterator | [
"Start",
"all",
"the",
"tasks",
"and",
"return",
"data",
"on",
"an",
"iterator"
] | b10eba28de6019cbf34e08ac575d31a4c493b39c | https://github.com/gtsystem/parallelpipe/blob/b10eba28de6019cbf34e08ac575d31a4c493b39c/parallelpipe.py#L215-L249 | train |
The-Politico/politico-civic-election-night | electionnight/managers/page_content.py | PageContentManager.office_content | def office_content(self, election_day, office):
"""
Return serialized content for an office page.
"""
from electionnight.models import PageType
office_type = ContentType.objects.get_for_model(office)
page_type = PageType.objects.get(
model_type=office_type,
... | python | def office_content(self, election_day, office):
"""
Return serialized content for an office page.
"""
from electionnight.models import PageType
office_type = ContentType.objects.get_for_model(office)
page_type = PageType.objects.get(
model_type=office_type,
... | [
"def",
"office_content",
"(",
"self",
",",
"election_day",
",",
"office",
")",
":",
"from",
"electionnight",
".",
"models",
"import",
"PageType",
"office_type",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"office",
")",
"page_type",
"=",
"Pa... | Return serialized content for an office page. | [
"Return",
"serialized",
"content",
"for",
"an",
"office",
"page",
"."
] | a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6 | https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/managers/page_content.py#L17-L44 | train |
The-Politico/politico-civic-election-night | electionnight/managers/page_content.py | PageContentManager.body_content | def body_content(self, election_day, body, division=None):
"""
Return serialized content for a body page.
"""
from electionnight.models import PageType
body_type = ContentType.objects.get_for_model(body)
page_type = PageType.objects.get(
model_type=body_type,... | python | def body_content(self, election_day, body, division=None):
"""
Return serialized content for a body page.
"""
from electionnight.models import PageType
body_type = ContentType.objects.get_for_model(body)
page_type = PageType.objects.get(
model_type=body_type,... | [
"def",
"body_content",
"(",
"self",
",",
"election_day",
",",
"body",
",",
"division",
"=",
"None",
")",
":",
"from",
"electionnight",
".",
"models",
"import",
"PageType",
"body_type",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"body",
")... | Return serialized content for a body page. | [
"Return",
"serialized",
"content",
"for",
"a",
"body",
"page",
"."
] | a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6 | https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/managers/page_content.py#L46-L83 | train |
The-Politico/politico-civic-election-night | electionnight/managers/page_content.py | PageContentManager.division_content | def division_content(self, election_day, division, special=False):
"""
Return serialized content for a division page.
"""
from electionnight.models import PageType
division_type = ContentType.objects.get_for_model(division)
page_type = PageType.objects.get(
m... | python | def division_content(self, election_day, division, special=False):
"""
Return serialized content for a division page.
"""
from electionnight.models import PageType
division_type = ContentType.objects.get_for_model(division)
page_type = PageType.objects.get(
m... | [
"def",
"division_content",
"(",
"self",
",",
"election_day",
",",
"division",
",",
"special",
"=",
"False",
")",
":",
"from",
"electionnight",
".",
"models",
"import",
"PageType",
"division_type",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
... | Return serialized content for a division page. | [
"Return",
"serialized",
"content",
"for",
"a",
"division",
"page",
"."
] | a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6 | https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/managers/page_content.py#L85-L112 | train |
The-Politico/politico-civic-election-night | electionnight/managers/page_content.py | PageContentManager.site_content | def site_content(self, election_day):
"""
Site content represents content for the entire site on a
given election day.
"""
from electionnight.models import PageType
page_type = PageType.objects.get(
model_type=ContentType.objects.get(
app_labe... | python | def site_content(self, election_day):
"""
Site content represents content for the entire site on a
given election day.
"""
from electionnight.models import PageType
page_type = PageType.objects.get(
model_type=ContentType.objects.get(
app_labe... | [
"def",
"site_content",
"(",
"self",
",",
"election_day",
")",
":",
"from",
"electionnight",
".",
"models",
"import",
"PageType",
"page_type",
"=",
"PageType",
".",
"objects",
".",
"get",
"(",
"model_type",
"=",
"ContentType",
".",
"objects",
".",
"get",
"(",... | Site content represents content for the entire site on a
given election day. | [
"Site",
"content",
"represents",
"content",
"for",
"the",
"entire",
"site",
"on",
"a",
"given",
"election",
"day",
"."
] | a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6 | https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/managers/page_content.py#L114-L132 | train |
mardix/Juice | juice/core.py | get_interesting_members | def get_interesting_members(base_class, cls):
"""Returns a list of methods that can be routed to"""
base_members = dir(base_class)
predicate = inspect.ismethod if _py2 else inspect.isfunction
all_members = inspect.getmembers(cls, predicate=predicate)
return [member for member in all_members
... | python | def get_interesting_members(base_class, cls):
"""Returns a list of methods that can be routed to"""
base_members = dir(base_class)
predicate = inspect.ismethod if _py2 else inspect.isfunction
all_members = inspect.getmembers(cls, predicate=predicate)
return [member for member in all_members
... | [
"def",
"get_interesting_members",
"(",
"base_class",
",",
"cls",
")",
":",
"base_members",
"=",
"dir",
"(",
"base_class",
")",
"predicate",
"=",
"inspect",
".",
"ismethod",
"if",
"_py2",
"else",
"inspect",
".",
"isfunction",
"all_members",
"=",
"inspect",
".",... | Returns a list of methods that can be routed to | [
"Returns",
"a",
"list",
"of",
"methods",
"that",
"can",
"be",
"routed",
"to"
] | 7afa8d4238868235dfcdae82272bd77958dd416a | https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/core.py#L688-L699 | train |
BrianHicks/tinyobj | tinyobj/fields.py | Field.initialize | def initialize(self, value=()):
"""\
initialize returns a cleaned value or the default, raising ValueErrors
as necessary.
"""
if value == ():
try:
return self.default()
except TypeError:
return self.default
else:
... | python | def initialize(self, value=()):
"""\
initialize returns a cleaned value or the default, raising ValueErrors
as necessary.
"""
if value == ():
try:
return self.default()
except TypeError:
return self.default
else:
... | [
"def",
"initialize",
"(",
"self",
",",
"value",
"=",
"(",
")",
")",
":",
"if",
"value",
"==",
"(",
")",
":",
"try",
":",
"return",
"self",
".",
"default",
"(",
")",
"except",
"TypeError",
":",
"return",
"self",
".",
"default",
"else",
":",
"return"... | \
initialize returns a cleaned value or the default, raising ValueErrors
as necessary. | [
"\\",
"initialize",
"returns",
"a",
"cleaned",
"value",
"or",
"the",
"default",
"raising",
"ValueErrors",
"as",
"necessary",
"."
] | c1ea7a007d70c2b815b4879d383af3825c74e7e8 | https://github.com/BrianHicks/tinyobj/blob/c1ea7a007d70c2b815b4879d383af3825c74e7e8/tinyobj/fields.py#L10-L21 | train |
BrianHicks/tinyobj | tinyobj/fields.py | NumberField.clean | def clean(self, value):
"""clean a value, converting and performing bounds checking"""
if not isinstance(value, self.t):
value = self.t(value)
if not self.allow_negative and value < 0:
raise ValueError('value was negative')
if not self.allow_positive and value >... | python | def clean(self, value):
"""clean a value, converting and performing bounds checking"""
if not isinstance(value, self.t):
value = self.t(value)
if not self.allow_negative and value < 0:
raise ValueError('value was negative')
if not self.allow_positive and value >... | [
"def",
"clean",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"self",
".",
"t",
")",
":",
"value",
"=",
"self",
".",
"t",
"(",
"value",
")",
"if",
"not",
"self",
".",
"allow_negative",
"and",
"value",
"<",
"0"... | clean a value, converting and performing bounds checking | [
"clean",
"a",
"value",
"converting",
"and",
"performing",
"bounds",
"checking"
] | c1ea7a007d70c2b815b4879d383af3825c74e7e8 | https://github.com/BrianHicks/tinyobj/blob/c1ea7a007d70c2b815b4879d383af3825c74e7e8/tinyobj/fields.py#L40-L51 | train |
adamheins/r12 | r12/arm.py | r12_serial_port | def r12_serial_port(port):
''' Create a serial connect to the arm. '''
return serial.Serial(port, baudrate=BAUD_RATE, parity=PARITY,
stopbits=STOP_BITS, bytesize=BYTE_SIZE) | python | def r12_serial_port(port):
''' Create a serial connect to the arm. '''
return serial.Serial(port, baudrate=BAUD_RATE, parity=PARITY,
stopbits=STOP_BITS, bytesize=BYTE_SIZE) | [
"def",
"r12_serial_port",
"(",
"port",
")",
":",
"return",
"serial",
".",
"Serial",
"(",
"port",
",",
"baudrate",
"=",
"BAUD_RATE",
",",
"parity",
"=",
"PARITY",
",",
"stopbits",
"=",
"STOP_BITS",
",",
"bytesize",
"=",
"BYTE_SIZE",
")"
] | Create a serial connect to the arm. | [
"Create",
"a",
"serial",
"connect",
"to",
"the",
"arm",
"."
] | ff78178332140930bf46a94a0b15ee082bb92491 | https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/arm.py#L36-L39 | train |
adamheins/r12 | r12/arm.py | search_for_port | def search_for_port(port_glob, req, expected_res):
''' Find the serial port the arm is connected to. '''
# Check that the USB port actually exists, based on the known vendor and
# product ID.
if usb.core.find(idVendor=0x0403, idProduct=0x6001) is None:
return None
# Find ports matching the... | python | def search_for_port(port_glob, req, expected_res):
''' Find the serial port the arm is connected to. '''
# Check that the USB port actually exists, based on the known vendor and
# product ID.
if usb.core.find(idVendor=0x0403, idProduct=0x6001) is None:
return None
# Find ports matching the... | [
"def",
"search_for_port",
"(",
"port_glob",
",",
"req",
",",
"expected_res",
")",
":",
"if",
"usb",
".",
"core",
".",
"find",
"(",
"idVendor",
"=",
"0x0403",
",",
"idProduct",
"=",
"0x6001",
")",
"is",
"None",
":",
"return",
"None",
"ports",
"=",
"glob... | Find the serial port the arm is connected to. | [
"Find",
"the",
"serial",
"port",
"the",
"arm",
"is",
"connected",
"to",
"."
] | ff78178332140930bf46a94a0b15ee082bb92491 | https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/arm.py#L42-L76 | train |
adamheins/r12 | r12/arm.py | Arm.connect | def connect(self, port=None):
''' Open a serial connection to the arm. '''
if port is None:
self.port = search_for_port('/dev/ttyUSB*', 'ROBOFORTH\r\n',
'ROBOFORTH')
else:
self.port = port
if self.port is None:
... | python | def connect(self, port=None):
''' Open a serial connection to the arm. '''
if port is None:
self.port = search_for_port('/dev/ttyUSB*', 'ROBOFORTH\r\n',
'ROBOFORTH')
else:
self.port = port
if self.port is None:
... | [
"def",
"connect",
"(",
"self",
",",
"port",
"=",
"None",
")",
":",
"if",
"port",
"is",
"None",
":",
"self",
".",
"port",
"=",
"search_for_port",
"(",
"'/dev/ttyUSB*'",
",",
"'ROBOFORTH\\r\\n'",
",",
"'ROBOFORTH'",
")",
"else",
":",
"self",
".",
"port",
... | Open a serial connection to the arm. | [
"Open",
"a",
"serial",
"connection",
"to",
"the",
"arm",
"."
] | ff78178332140930bf46a94a0b15ee082bb92491 | https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/arm.py#L97-L116 | train |
adamheins/r12 | r12/arm.py | Arm.write | def write(self, text):
''' Write text out to the arm. '''
# Output is converted to bytes with Windows-style line endings.
if sys.version_info[0] == 2:
text_bytes = str(text.upper() + '\r\n').encode('utf-8')
else:
text_bytes = bytes(text.upper() + '\r\n', 'utf-8')
... | python | def write(self, text):
''' Write text out to the arm. '''
# Output is converted to bytes with Windows-style line endings.
if sys.version_info[0] == 2:
text_bytes = str(text.upper() + '\r\n').encode('utf-8')
else:
text_bytes = bytes(text.upper() + '\r\n', 'utf-8')
... | [
"def",
"write",
"(",
"self",
",",
"text",
")",
":",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"2",
":",
"text_bytes",
"=",
"str",
"(",
"text",
".",
"upper",
"(",
")",
"+",
"'\\r\\n'",
")",
".",
"encode",
"(",
"'utf-8'",
")",
"else",
... | Write text out to the arm. | [
"Write",
"text",
"out",
"to",
"the",
"arm",
"."
] | ff78178332140930bf46a94a0b15ee082bb92491 | https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/arm.py#L126-L133 | train |
adamheins/r12 | r12/arm.py | Arm.read | def read(self, timeout=READ_TIMEOUT, raw=False):
''' Read data from the arm. Data is returned as a latin_1 encoded
string, or raw bytes if 'raw' is True. '''
time.sleep(READ_SLEEP_TIME)
raw_out = self.ser.read(self.ser.in_waiting)
out = raw_out.decode(OUTPUT_ENCODING)
... | python | def read(self, timeout=READ_TIMEOUT, raw=False):
''' Read data from the arm. Data is returned as a latin_1 encoded
string, or raw bytes if 'raw' is True. '''
time.sleep(READ_SLEEP_TIME)
raw_out = self.ser.read(self.ser.in_waiting)
out = raw_out.decode(OUTPUT_ENCODING)
... | [
"def",
"read",
"(",
"self",
",",
"timeout",
"=",
"READ_TIMEOUT",
",",
"raw",
"=",
"False",
")",
":",
"time",
".",
"sleep",
"(",
"READ_SLEEP_TIME",
")",
"raw_out",
"=",
"self",
".",
"ser",
".",
"read",
"(",
"self",
".",
"ser",
".",
"in_waiting",
")",
... | Read data from the arm. Data is returned as a latin_1 encoded
string, or raw bytes if 'raw' is True. | [
"Read",
"data",
"from",
"the",
"arm",
".",
"Data",
"is",
"returned",
"as",
"a",
"latin_1",
"encoded",
"string",
"or",
"raw",
"bytes",
"if",
"raw",
"is",
"True",
"."
] | ff78178332140930bf46a94a0b15ee082bb92491 | https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/arm.py#L136-L157 | train |
adamheins/r12 | r12/arm.py | Arm.dump | def dump(self, raw=False):
''' Dump all output currently in the arm's output queue. '''
raw_out = self.ser.read(self.ser.in_waiting)
if raw:
return raw_out
return raw_out.decode(OUTPUT_ENCODING) | python | def dump(self, raw=False):
''' Dump all output currently in the arm's output queue. '''
raw_out = self.ser.read(self.ser.in_waiting)
if raw:
return raw_out
return raw_out.decode(OUTPUT_ENCODING) | [
"def",
"dump",
"(",
"self",
",",
"raw",
"=",
"False",
")",
":",
"raw_out",
"=",
"self",
".",
"ser",
".",
"read",
"(",
"self",
".",
"ser",
".",
"in_waiting",
")",
"if",
"raw",
":",
"return",
"raw_out",
"return",
"raw_out",
".",
"decode",
"(",
"OUTPU... | Dump all output currently in the arm's output queue. | [
"Dump",
"all",
"output",
"currently",
"in",
"the",
"arm",
"s",
"output",
"queue",
"."
] | ff78178332140930bf46a94a0b15ee082bb92491 | https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/arm.py#L160-L165 | train |
adamheins/r12 | r12/arm.py | Arm.get_info | def get_info(self):
''' Returns status of the robot arm. '''
return {
'Connected': self.is_connected(),
'Port': self.port,
'Bytes Waiting': self.ser.in_waiting if self.ser else 0
} | python | def get_info(self):
''' Returns status of the robot arm. '''
return {
'Connected': self.is_connected(),
'Port': self.port,
'Bytes Waiting': self.ser.in_waiting if self.ser else 0
} | [
"def",
"get_info",
"(",
"self",
")",
":",
"return",
"{",
"'Connected'",
":",
"self",
".",
"is_connected",
"(",
")",
",",
"'Port'",
":",
"self",
".",
"port",
",",
"'Bytes Waiting'",
":",
"self",
".",
"ser",
".",
"in_waiting",
"if",
"self",
".",
"ser",
... | Returns status of the robot arm. | [
"Returns",
"status",
"of",
"the",
"robot",
"arm",
"."
] | ff78178332140930bf46a94a0b15ee082bb92491 | https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/arm.py#L173-L179 | train |
fabaff/python-opensensemap-api | opensensemap_api/__init__.py | OpenSenseMap.get_data | async def get_data(self):
"""Get details of OpenSenseMap station."""
try:
async with async_timeout.timeout(5, loop=self._loop):
response = await self._session.get(self.base_url)
_LOGGER.info(
"Response from OpenSenseMap API: %s", response.status)
... | python | async def get_data(self):
"""Get details of OpenSenseMap station."""
try:
async with async_timeout.timeout(5, loop=self._loop):
response = await self._session.get(self.base_url)
_LOGGER.info(
"Response from OpenSenseMap API: %s", response.status)
... | [
"async",
"def",
"get_data",
"(",
"self",
")",
":",
"try",
":",
"async",
"with",
"async_timeout",
".",
"timeout",
"(",
"5",
",",
"loop",
"=",
"self",
".",
"_loop",
")",
":",
"response",
"=",
"await",
"self",
".",
"_session",
".",
"get",
"(",
"self",
... | Get details of OpenSenseMap station. | [
"Get",
"details",
"of",
"OpenSenseMap",
"station",
"."
] | 3c4f5473c514185087aae5d766ab4d5736ec1f30 | https://github.com/fabaff/python-opensensemap-api/blob/3c4f5473c514185087aae5d766ab4d5736ec1f30/opensensemap_api/__init__.py#L48-L61 | train |
fabaff/python-opensensemap-api | opensensemap_api/__init__.py | OpenSenseMap.get_value | def get_value(self, key):
"""Extract a value for a given key."""
for title in _TITLES.get(key, ()) + (key,):
try:
value = [entry['lastMeasurement']['value'] for entry in
self.data['sensors'] if entry['title'] == title][0]
return value
... | python | def get_value(self, key):
"""Extract a value for a given key."""
for title in _TITLES.get(key, ()) + (key,):
try:
value = [entry['lastMeasurement']['value'] for entry in
self.data['sensors'] if entry['title'] == title][0]
return value
... | [
"def",
"get_value",
"(",
"self",
",",
"key",
")",
":",
"for",
"title",
"in",
"_TITLES",
".",
"get",
"(",
"key",
",",
"(",
")",
")",
"+",
"(",
"key",
",",
")",
":",
"try",
":",
"value",
"=",
"[",
"entry",
"[",
"'lastMeasurement'",
"]",
"[",
"'va... | Extract a value for a given key. | [
"Extract",
"a",
"value",
"for",
"a",
"given",
"key",
"."
] | 3c4f5473c514185087aae5d766ab4d5736ec1f30 | https://github.com/fabaff/python-opensensemap-api/blob/3c4f5473c514185087aae5d766ab4d5736ec1f30/opensensemap_api/__init__.py#L123-L132 | train |
tjcsl/cslbot | cslbot/commands/note.py | cmd | def cmd(send, msg, args):
"""Leaves a note for a user or users.
Syntax: {command} <nick>[,nick2,...] <note>
"""
if not args['config']['feature'].getboolean('hooks'):
send("Hooks are disabled, and this command depends on hooks. Please contact the bot admin(s).")
return
if args['type... | python | def cmd(send, msg, args):
"""Leaves a note for a user or users.
Syntax: {command} <nick>[,nick2,...] <note>
"""
if not args['config']['feature'].getboolean('hooks'):
send("Hooks are disabled, and this command depends on hooks. Please contact the bot admin(s).")
return
if args['type... | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"args",
")",
":",
"if",
"not",
"args",
"[",
"'config'",
"]",
"[",
"'feature'",
"]",
".",
"getboolean",
"(",
"'hooks'",
")",
":",
"send",
"(",
"\"Hooks are disabled, and this command depends on hooks. Please contact the... | Leaves a note for a user or users.
Syntax: {command} <nick>[,nick2,...] <note> | [
"Leaves",
"a",
"note",
"for",
"a",
"user",
"or",
"users",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/note.py#L26-L57 | train |
ktdreyer/txkoji | txkoji/messages.py | BuildStateChange.from_frame | def from_frame(klass, frame, connection):
"""
Create a new BuildStateChange event from a Stompest Frame.
"""
event = frame.headers['new']
data = json.loads(frame.body)
info = data['info']
build = Build.fromDict(info)
build.connection = connection
r... | python | def from_frame(klass, frame, connection):
"""
Create a new BuildStateChange event from a Stompest Frame.
"""
event = frame.headers['new']
data = json.loads(frame.body)
info = data['info']
build = Build.fromDict(info)
build.connection = connection
r... | [
"def",
"from_frame",
"(",
"klass",
",",
"frame",
",",
"connection",
")",
":",
"event",
"=",
"frame",
".",
"headers",
"[",
"'new'",
"]",
"data",
"=",
"json",
".",
"loads",
"(",
"frame",
".",
"body",
")",
"info",
"=",
"data",
"[",
"'info'",
"]",
"bui... | Create a new BuildStateChange event from a Stompest Frame. | [
"Create",
"a",
"new",
"BuildStateChange",
"event",
"from",
"a",
"Stompest",
"Frame",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/messages.py#L31-L40 | train |
ktdreyer/txkoji | txkoji/messages.py | TaskStateChange.from_frame | def from_frame(klass, frame, connection):
"""
Create a new TaskStateChange event from a Stompest Frame.
"""
event = frame.headers['new']
data = json.loads(frame.body)
info = data['info']
task = Task.fromDict(info)
task.connection = connection
retur... | python | def from_frame(klass, frame, connection):
"""
Create a new TaskStateChange event from a Stompest Frame.
"""
event = frame.headers['new']
data = json.loads(frame.body)
info = data['info']
task = Task.fromDict(info)
task.connection = connection
retur... | [
"def",
"from_frame",
"(",
"klass",
",",
"frame",
",",
"connection",
")",
":",
"event",
"=",
"frame",
".",
"headers",
"[",
"'new'",
"]",
"data",
"=",
"json",
".",
"loads",
"(",
"frame",
".",
"body",
")",
"info",
"=",
"data",
"[",
"'info'",
"]",
"tas... | Create a new TaskStateChange event from a Stompest Frame. | [
"Create",
"a",
"new",
"TaskStateChange",
"event",
"from",
"a",
"Stompest",
"Frame",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/messages.py#L60-L69 | train |
tjcsl/cslbot | cslbot/commands/ping.py | cmd | def cmd(send, msg, args):
"""Ping something.
Syntax: {command} <target>
"""
if not msg:
send("Ping what?")
return
channel = args['target'] if args['target'] != 'private' else args['nick']
# CTCP PING
if "." not in msg and ":" not in msg:
targets = set(msg.split())
... | python | def cmd(send, msg, args):
"""Ping something.
Syntax: {command} <target>
"""
if not msg:
send("Ping what?")
return
channel = args['target'] if args['target'] != 'private' else args['nick']
# CTCP PING
if "." not in msg and ":" not in msg:
targets = set(msg.split())
... | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"args",
")",
":",
"if",
"not",
"msg",
":",
"send",
"(",
"\"Ping what?\"",
")",
"return",
"channel",
"=",
"args",
"[",
"'target'",
"]",
"if",
"args",
"[",
"'target'",
"]",
"!=",
"'private'",
"else",
"args",
... | Ping something.
Syntax: {command} <target> | [
"Ping",
"something",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/ping.py#L26-L58 | train |
shapiromatron/bmds | bmds/models/base.py | BMDModel.execution_duration | def execution_duration(self):
"""
Returns total BMDS execution time, in seconds.
"""
duration = None
if self.execution_start and self.execution_end:
delta = self.execution_end - self.execution_start
duration = delta.total_seconds()
return duration | python | def execution_duration(self):
"""
Returns total BMDS execution time, in seconds.
"""
duration = None
if self.execution_start and self.execution_end:
delta = self.execution_end - self.execution_start
duration = delta.total_seconds()
return duration | [
"def",
"execution_duration",
"(",
"self",
")",
":",
"duration",
"=",
"None",
"if",
"self",
".",
"execution_start",
"and",
"self",
".",
"execution_end",
":",
"delta",
"=",
"self",
".",
"execution_end",
"-",
"self",
".",
"execution_start",
"duration",
"=",
"de... | Returns total BMDS execution time, in seconds. | [
"Returns",
"total",
"BMDS",
"execution",
"time",
"in",
"seconds",
"."
] | 395c6ce84ad82876fd9fa4a89a3497fb61616de0 | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/models/base.py#L155-L163 | train |
shapiromatron/bmds | bmds/models/base.py | BMDModel.get_exe_path | def get_exe_path(cls):
"""
Return the full path to the executable.
"""
return os.path.abspath(os.path.join(ROOT, cls.bmds_version_dir, cls.exe + ".exe")) | python | def get_exe_path(cls):
"""
Return the full path to the executable.
"""
return os.path.abspath(os.path.join(ROOT, cls.bmds_version_dir, cls.exe + ".exe")) | [
"def",
"get_exe_path",
"(",
"cls",
")",
":",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"ROOT",
",",
"cls",
".",
"bmds_version_dir",
",",
"cls",
".",
"exe",
"+",
"\".exe\"",
")",
")"
] | Return the full path to the executable. | [
"Return",
"the",
"full",
"path",
"to",
"the",
"executable",
"."
] | 395c6ce84ad82876fd9fa4a89a3497fb61616de0 | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/models/base.py#L173-L177 | train |
shapiromatron/bmds | bmds/models/base.py | BMDModel.plot | def plot(self):
"""
After model execution, print the dataset, curve-fit, BMD, and BMDL.
Example
-------
>>> import os
>>> fn = os.path.expanduser('~/Desktop/image.png')
>>> fig = model.plot()
>>> fig.savefig(fn)
>>> fig.clear()
.. figure... | python | def plot(self):
"""
After model execution, print the dataset, curve-fit, BMD, and BMDL.
Example
-------
>>> import os
>>> fn = os.path.expanduser('~/Desktop/image.png')
>>> fig = model.plot()
>>> fig.savefig(fn)
>>> fig.clear()
.. figure... | [
"def",
"plot",
"(",
"self",
")",
":",
"fig",
"=",
"self",
".",
"dataset",
".",
"plot",
"(",
")",
"ax",
"=",
"fig",
".",
"gca",
"(",
")",
"ax",
".",
"set_title",
"(",
"\"{}\\n{}, {}\"",
".",
"format",
"(",
"self",
".",
"dataset",
".",
"_get_dataset_... | After model execution, print the dataset, curve-fit, BMD, and BMDL.
Example
-------
>>> import os
>>> fn = os.path.expanduser('~/Desktop/image.png')
>>> fig = model.plot()
>>> fig.savefig(fn)
>>> fig.clear()
.. figure:: ../tests/resources/test_exponenti... | [
"After",
"model",
"execution",
"print",
"the",
"dataset",
"curve",
"-",
"fit",
"BMD",
"and",
"BMDL",
"."
] | 395c6ce84ad82876fd9fa4a89a3497fb61616de0 | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/models/base.py#L215-L251 | train |
shapiromatron/bmds | bmds/models/base.py | BMDModel.write_dfile | def write_dfile(self):
"""
Write the generated d_file to a temporary file.
"""
f_in = self.tempfiles.get_tempfile(prefix="bmds-", suffix=".(d)")
with open(f_in, "w") as f:
f.write(self.as_dfile())
return f_in | python | def write_dfile(self):
"""
Write the generated d_file to a temporary file.
"""
f_in = self.tempfiles.get_tempfile(prefix="bmds-", suffix=".(d)")
with open(f_in, "w") as f:
f.write(self.as_dfile())
return f_in | [
"def",
"write_dfile",
"(",
"self",
")",
":",
"f_in",
"=",
"self",
".",
"tempfiles",
".",
"get_tempfile",
"(",
"prefix",
"=",
"\"bmds-\"",
",",
"suffix",
"=",
"\".(d)\"",
")",
"with",
"open",
"(",
"f_in",
",",
"\"w\"",
")",
"as",
"f",
":",
"f",
".",
... | Write the generated d_file to a temporary file. | [
"Write",
"the",
"generated",
"d_file",
"to",
"a",
"temporary",
"file",
"."
] | 395c6ce84ad82876fd9fa4a89a3497fb61616de0 | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/models/base.py#L316-L323 | train |
shapiromatron/bmds | bmds/models/base.py | BMDModel.to_dict | def to_dict(self, model_index):
"""
Return a summary of the model in a dictionary format for serialization.
Parameters
----------
model_index : int
The index of the model in a list of models, should be unique
Returns
-------
out : dictionary
... | python | def to_dict(self, model_index):
"""
Return a summary of the model in a dictionary format for serialization.
Parameters
----------
model_index : int
The index of the model in a list of models, should be unique
Returns
-------
out : dictionary
... | [
"def",
"to_dict",
"(",
"self",
",",
"model_index",
")",
":",
"return",
"dict",
"(",
"name",
"=",
"self",
".",
"name",
",",
"model_index",
"=",
"model_index",
",",
"model_name",
"=",
"self",
".",
"model_name",
",",
"model_version",
"=",
"self",
".",
"vers... | Return a summary of the model in a dictionary format for serialization.
Parameters
----------
model_index : int
The index of the model in a list of models, should be unique
Returns
-------
out : dictionary
A dictionary of model inputs, and raw an... | [
"Return",
"a",
"summary",
"of",
"the",
"model",
"in",
"a",
"dictionary",
"format",
"for",
"serialization",
"."
] | 395c6ce84ad82876fd9fa4a89a3497fb61616de0 | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/models/base.py#L395-L425 | train |
jlesquembre/autopilot | src/autopilot/utils.py | merge_config | def merge_config(d1, d2):
'''Merges to config dicts. Key values are case insensitive for merging,
but the value of d1 is remembered.
'''
result = deepcopy(d1)
elements = deque()
elements.append((result, d2))
while elements:
old, new = elements.popleft()
new = OrderedDict([(... | python | def merge_config(d1, d2):
'''Merges to config dicts. Key values are case insensitive for merging,
but the value of d1 is remembered.
'''
result = deepcopy(d1)
elements = deque()
elements.append((result, d2))
while elements:
old, new = elements.popleft()
new = OrderedDict([(... | [
"def",
"merge_config",
"(",
"d1",
",",
"d2",
")",
":",
"result",
"=",
"deepcopy",
"(",
"d1",
")",
"elements",
"=",
"deque",
"(",
")",
"elements",
".",
"append",
"(",
"(",
"result",
",",
"d2",
")",
")",
"while",
"elements",
":",
"old",
",",
"new",
... | Merges to config dicts. Key values are case insensitive for merging,
but the value of d1 is remembered. | [
"Merges",
"to",
"config",
"dicts",
".",
"Key",
"values",
"are",
"case",
"insensitive",
"for",
"merging",
"but",
"the",
"value",
"of",
"d1",
"is",
"remembered",
"."
] | ca5f36269ba0173bd29c39db6971dac57a58513d | https://github.com/jlesquembre/autopilot/blob/ca5f36269ba0173bd29c39db6971dac57a58513d/src/autopilot/utils.py#L74-L102 | train |
jlesquembre/autopilot | src/autopilot/utils.py | set_if_none | def set_if_none(user_config, config, key, value):
'''
If the value of the key in is None, and doesn't exist on the user config,
set it to a different value
'''
keys = key.split('.')
for k in keys[:-1]:
try:
user_config = user_config[k]
except KeyError:
us... | python | def set_if_none(user_config, config, key, value):
'''
If the value of the key in is None, and doesn't exist on the user config,
set it to a different value
'''
keys = key.split('.')
for k in keys[:-1]:
try:
user_config = user_config[k]
except KeyError:
us... | [
"def",
"set_if_none",
"(",
"user_config",
",",
"config",
",",
"key",
",",
"value",
")",
":",
"keys",
"=",
"key",
".",
"split",
"(",
"'.'",
")",
"for",
"k",
"in",
"keys",
"[",
":",
"-",
"1",
"]",
":",
"try",
":",
"user_config",
"=",
"user_config",
... | If the value of the key in is None, and doesn't exist on the user config,
set it to a different value | [
"If",
"the",
"value",
"of",
"the",
"key",
"in",
"is",
"None",
"and",
"doesn",
"t",
"exist",
"on",
"the",
"user",
"config",
"set",
"it",
"to",
"a",
"different",
"value"
] | ca5f36269ba0173bd29c39db6971dac57a58513d | https://github.com/jlesquembre/autopilot/blob/ca5f36269ba0173bd29c39db6971dac57a58513d/src/autopilot/utils.py#L116-L134 | train |
tjcsl/cslbot | cslbot/helpers/acl.py | set_admin | def set_admin(msg, handler):
"""Handle admin verification responses from NickServ.
| If NickServ tells us that the nick is authed, mark it as verified.
"""
if handler.config['feature']['servicestype'] == "ircservices":
match = re.match("STATUS (.*) ([0-3])", msg)
elif handler.config['featu... | python | def set_admin(msg, handler):
"""Handle admin verification responses from NickServ.
| If NickServ tells us that the nick is authed, mark it as verified.
"""
if handler.config['feature']['servicestype'] == "ircservices":
match = re.match("STATUS (.*) ([0-3])", msg)
elif handler.config['featu... | [
"def",
"set_admin",
"(",
"msg",
",",
"handler",
")",
":",
"if",
"handler",
".",
"config",
"[",
"'feature'",
"]",
"[",
"'servicestype'",
"]",
"==",
"\"ircservices\"",
":",
"match",
"=",
"re",
".",
"match",
"(",
"\"STATUS (.*) ([0-3])\"",
",",
"msg",
")",
... | Handle admin verification responses from NickServ.
| If NickServ tells us that the nick is authed, mark it as verified. | [
"Handle",
"admin",
"verification",
"responses",
"from",
"NickServ",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/helpers/acl.py#L24-L45 | train |
Xion/taipan | taipan/collections/tuples.py | is_tuple | def is_tuple(obj, len_=None):
"""Checks whether given object is a tuple.
:param len_: Optional expected length of the tuple
:return: ``True`` if argument is a tuple (of given length, if any),
``False`` otherwise
"""
if not isinstance(obj, tuple):
return False
if len_ is N... | python | def is_tuple(obj, len_=None):
"""Checks whether given object is a tuple.
:param len_: Optional expected length of the tuple
:return: ``True`` if argument is a tuple (of given length, if any),
``False`` otherwise
"""
if not isinstance(obj, tuple):
return False
if len_ is N... | [
"def",
"is_tuple",
"(",
"obj",
",",
"len_",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"tuple",
")",
":",
"return",
"False",
"if",
"len_",
"is",
"None",
":",
"return",
"True",
"if",
"not",
"isinstance",
"(",
"len_",
",",
"In... | Checks whether given object is a tuple.
:param len_: Optional expected length of the tuple
:return: ``True`` if argument is a tuple (of given length, if any),
``False`` otherwise | [
"Checks",
"whether",
"given",
"object",
"is",
"a",
"tuple",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/collections/tuples.py#L30-L49 | train |
Xion/taipan | taipan/collections/tuples.py | select | def select(indices, from_, strict=False):
"""Selects a subsequence of given tuple, including only specified indices.
:param indices: Iterable of indices to include
:param strict: Whether ``indices`` are required to exist in the tuple.
:return: Tuple with selected elements, in the order corresponding
... | python | def select(indices, from_, strict=False):
"""Selects a subsequence of given tuple, including only specified indices.
:param indices: Iterable of indices to include
:param strict: Whether ``indices`` are required to exist in the tuple.
:return: Tuple with selected elements, in the order corresponding
... | [
"def",
"select",
"(",
"indices",
",",
"from_",
",",
"strict",
"=",
"False",
")",
":",
"ensure_iterable",
"(",
"indices",
")",
"ensure_sequence",
"(",
"from_",
")",
"if",
"strict",
":",
"return",
"from_",
".",
"__class__",
"(",
"from_",
"[",
"index",
"]",... | Selects a subsequence of given tuple, including only specified indices.
:param indices: Iterable of indices to include
:param strict: Whether ``indices`` are required to exist in the tuple.
:return: Tuple with selected elements, in the order corresponding
to the order of ``indices``.
:ra... | [
"Selects",
"a",
"subsequence",
"of",
"given",
"tuple",
"including",
"only",
"specified",
"indices",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/collections/tuples.py#L189-L209 | train |
Xion/taipan | taipan/collections/tuples.py | omit | def omit(indices, from_, strict=False):
"""Returns a subsequence from given tuple, omitting specified indices.
:param indices: Iterable of indices to exclude
:param strict: Whether ``indices`` are required to exist in the tuple
:return: Tuple without elements of specified indices
:raise IndexErro... | python | def omit(indices, from_, strict=False):
"""Returns a subsequence from given tuple, omitting specified indices.
:param indices: Iterable of indices to exclude
:param strict: Whether ``indices`` are required to exist in the tuple
:return: Tuple without elements of specified indices
:raise IndexErro... | [
"def",
"omit",
"(",
"indices",
",",
"from_",
",",
"strict",
"=",
"False",
")",
":",
"from",
"taipan",
".",
"collections",
".",
"sets",
"import",
"remove_subset",
"ensure_iterable",
"(",
"indices",
")",
"ensure_sequence",
"(",
"from_",
")",
"if",
"strict",
... | Returns a subsequence from given tuple, omitting specified indices.
:param indices: Iterable of indices to exclude
:param strict: Whether ``indices`` are required to exist in the tuple
:return: Tuple without elements of specified indices
:raise IndexError: If ``strict`` is True and one of ``indices``... | [
"Returns",
"a",
"subsequence",
"from",
"given",
"tuple",
"omitting",
"specified",
"indices",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/collections/tuples.py#L217-L244 | train |
Xion/taipan | taipan/collections/tuples.py | _describe_type | def _describe_type(arg):
"""Describe given argument, including length if it's a tuple.
The purpose is to prevent nonsensical exception messages such as::
expected a tuple of length 2, got tuple
expected a tuple, got tuple
by turning them into::
expected a tuple of length 3, got t... | python | def _describe_type(arg):
"""Describe given argument, including length if it's a tuple.
The purpose is to prevent nonsensical exception messages such as::
expected a tuple of length 2, got tuple
expected a tuple, got tuple
by turning them into::
expected a tuple of length 3, got t... | [
"def",
"_describe_type",
"(",
"arg",
")",
":",
"if",
"isinstance",
"(",
"arg",
",",
"tuple",
")",
":",
"return",
"\"tuple of length %s\"",
"%",
"len",
"(",
"arg",
")",
"else",
":",
"return",
"type",
"(",
"arg",
")",
".",
"__name__"
] | Describe given argument, including length if it's a tuple.
The purpose is to prevent nonsensical exception messages such as::
expected a tuple of length 2, got tuple
expected a tuple, got tuple
by turning them into::
expected a tuple of length 3, got tuple of length 2 | [
"Describe",
"given",
"argument",
"including",
"length",
"if",
"it",
"s",
"a",
"tuple",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/collections/tuples.py#L249-L264 | train |
textbook/atmdb | atmdb/models.py | BaseModel._create_image_url | def _create_image_url(self, file_path, type_, target_size):
"""The the closest available size for specified image type.
Arguments:
file_path (:py:class:`str`): The image file path.
type_ (:py:class:`str`): The type of image to create a URL
for, (``'poster'`` or ``'profil... | python | def _create_image_url(self, file_path, type_, target_size):
"""The the closest available size for specified image type.
Arguments:
file_path (:py:class:`str`): The image file path.
type_ (:py:class:`str`): The type of image to create a URL
for, (``'poster'`` or ``'profil... | [
"def",
"_create_image_url",
"(",
"self",
",",
"file_path",
",",
"type_",
",",
"target_size",
")",
":",
"if",
"self",
".",
"image_config",
"is",
"None",
":",
"logger",
".",
"warning",
"(",
"'no image configuration available'",
")",
"return",
"return",
"''",
"."... | The the closest available size for specified image type.
Arguments:
file_path (:py:class:`str`): The image file path.
type_ (:py:class:`str`): The type of image to create a URL
for, (``'poster'`` or ``'profile'``).
target_size (:py:class:`int`): The size of image to ai... | [
"The",
"the",
"closest",
"available",
"size",
"for",
"specified",
"image",
"type",
"."
] | cab14547d2e777a1e26c2560266365c484855789 | https://github.com/textbook/atmdb/blob/cab14547d2e777a1e26c2560266365c484855789/atmdb/models.py#L65-L83 | train |
textbook/atmdb | atmdb/models.py | BaseModel.from_json | def from_json(cls, json, image_config=None):
"""Create a model instance
Arguments:
json (:py:class:`dict`): The parsed JSON data.
image_config (:py:class:`dict`): The API image configuration
data.
Returns:
:py:class:`BaseModel`: The model instance.
... | python | def from_json(cls, json, image_config=None):
"""Create a model instance
Arguments:
json (:py:class:`dict`): The parsed JSON data.
image_config (:py:class:`dict`): The API image configuration
data.
Returns:
:py:class:`BaseModel`: The model instance.
... | [
"def",
"from_json",
"(",
"cls",
",",
"json",
",",
"image_config",
"=",
"None",
")",
":",
"cls",
".",
"image_config",
"=",
"image_config",
"return",
"cls",
"(",
"**",
"{",
"attr",
":",
"json",
".",
"get",
"(",
"attr",
"if",
"key",
"is",
"None",
"else"... | Create a model instance
Arguments:
json (:py:class:`dict`): The parsed JSON data.
image_config (:py:class:`dict`): The API image configuration
data.
Returns:
:py:class:`BaseModel`: The model instance. | [
"Create",
"a",
"model",
"instance"
] | cab14547d2e777a1e26c2560266365c484855789 | https://github.com/textbook/atmdb/blob/cab14547d2e777a1e26c2560266365c484855789/atmdb/models.py#L86-L102 | train |
textbook/atmdb | atmdb/models.py | BaseModel._image_size | def _image_size(image_config, type_, target_size):
"""Find the closest available size for specified image type.
Arguments:
image_config (:py:class:`dict`): The image config data.
type_ (:py:class:`str`): The type of image to create a URL
for, (``'poster'`` or ``'profile'... | python | def _image_size(image_config, type_, target_size):
"""Find the closest available size for specified image type.
Arguments:
image_config (:py:class:`dict`): The image config data.
type_ (:py:class:`str`): The type of image to create a URL
for, (``'poster'`` or ``'profile'... | [
"def",
"_image_size",
"(",
"image_config",
",",
"type_",
",",
"target_size",
")",
":",
"return",
"min",
"(",
"image_config",
"[",
"'{}_sizes'",
".",
"format",
"(",
"type_",
")",
"]",
",",
"key",
"=",
"lambda",
"size",
":",
"(",
"abs",
"(",
"target_size",... | Find the closest available size for specified image type.
Arguments:
image_config (:py:class:`dict`): The image config data.
type_ (:py:class:`str`): The type of image to create a URL
for, (``'poster'`` or ``'profile'``).
target_size (:py:class:`int`): The size of imag... | [
"Find",
"the",
"closest",
"available",
"size",
"for",
"specified",
"image",
"type",
"."
] | cab14547d2e777a1e26c2560266365c484855789 | https://github.com/textbook/atmdb/blob/cab14547d2e777a1e26c2560266365c484855789/atmdb/models.py#L105-L121 | train |
rchatterjee/pwmodels | src/pwmodel/helper.py | getallgroups | def getallgroups(arr, k=-1):
"""
returns all the subset of @arr of size less than equalto @k
the return array will be of size \sum_{i=1}^k nCi, n = len(arr)
"""
if k < 0:
k = len(arr)
return itertools.chain.from_iterable(itertools.combinations(set(arr), j)
... | python | def getallgroups(arr, k=-1):
"""
returns all the subset of @arr of size less than equalto @k
the return array will be of size \sum_{i=1}^k nCi, n = len(arr)
"""
if k < 0:
k = len(arr)
return itertools.chain.from_iterable(itertools.combinations(set(arr), j)
... | [
"def",
"getallgroups",
"(",
"arr",
",",
"k",
"=",
"-",
"1",
")",
":",
"if",
"k",
"<",
"0",
":",
"k",
"=",
"len",
"(",
"arr",
")",
"return",
"itertools",
".",
"chain",
".",
"from_iterable",
"(",
"itertools",
".",
"combinations",
"(",
"set",
"(",
"... | returns all the subset of @arr of size less than equalto @k
the return array will be of size \sum_{i=1}^k nCi, n = len(arr) | [
"returns",
"all",
"the",
"subset",
"of"
] | e277411f8ebaf4ad1c208d2b035b4b68f7471517 | https://github.com/rchatterjee/pwmodels/blob/e277411f8ebaf4ad1c208d2b035b4b68f7471517/src/pwmodel/helper.py#L273-L281 | train |
rchatterjee/pwmodels | src/pwmodel/helper.py | open_get_line | def open_get_line(filename, limit=-1, **kwargs):
"""Opens the password file named @filename and reads first @limit
passwords. @kwargs are passed to get_line for further processing.
For example, pw_filter etc.
@fielname: string
@limit: integer
"""
allowed_keys_for_get_line = {'sep', 'pw_filte... | python | def open_get_line(filename, limit=-1, **kwargs):
"""Opens the password file named @filename and reads first @limit
passwords. @kwargs are passed to get_line for further processing.
For example, pw_filter etc.
@fielname: string
@limit: integer
"""
allowed_keys_for_get_line = {'sep', 'pw_filte... | [
"def",
"open_get_line",
"(",
"filename",
",",
"limit",
"=",
"-",
"1",
",",
"**",
"kwargs",
")",
":",
"allowed_keys_for_get_line",
"=",
"{",
"'sep'",
",",
"'pw_filter'",
",",
"'errors'",
"}",
"for",
"k",
"in",
"list",
"(",
"kwargs",
".",
"keys",
"(",
")... | Opens the password file named @filename and reads first @limit
passwords. @kwargs are passed to get_line for further processing.
For example, pw_filter etc.
@fielname: string
@limit: integer | [
"Opens",
"the",
"password",
"file",
"named"
] | e277411f8ebaf4ad1c208d2b035b4b68f7471517 | https://github.com/rchatterjee/pwmodels/blob/e277411f8ebaf4ad1c208d2b035b4b68f7471517/src/pwmodel/helper.py#L317-L331 | train |
tjcsl/cslbot | cslbot/helpers/workers.py | Workers.stop_workers | def stop_workers(self, clean):
"""Stop workers and deferred events."""
with executor_lock:
self.executor.shutdown(clean)
del self.executor
with self.worker_lock:
if clean:
self.pool.close()
else:
self.pool.terminate(... | python | def stop_workers(self, clean):
"""Stop workers and deferred events."""
with executor_lock:
self.executor.shutdown(clean)
del self.executor
with self.worker_lock:
if clean:
self.pool.close()
else:
self.pool.terminate(... | [
"def",
"stop_workers",
"(",
"self",
",",
"clean",
")",
":",
"with",
"executor_lock",
":",
"self",
".",
"executor",
".",
"shutdown",
"(",
"clean",
")",
"del",
"self",
".",
"executor",
"with",
"self",
".",
"worker_lock",
":",
"if",
"clean",
":",
"self",
... | Stop workers and deferred events. | [
"Stop",
"workers",
"and",
"deferred",
"events",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/helpers/workers.py#L108-L122 | train |
adamziel/python_translate | python_translate/extractors/python.py | PythonExtractor.extract_translations | def extract_translations(self, string):
"""Extract messages from Python string."""
tree = ast.parse(string)
# ast_visit(tree)
visitor = TransVisitor(
self.tranz_functions,
self.tranzchoice_functions)
visitor.visit(tree)
return visitor.translation... | python | def extract_translations(self, string):
"""Extract messages from Python string."""
tree = ast.parse(string)
# ast_visit(tree)
visitor = TransVisitor(
self.tranz_functions,
self.tranzchoice_functions)
visitor.visit(tree)
return visitor.translation... | [
"def",
"extract_translations",
"(",
"self",
",",
"string",
")",
":",
"tree",
"=",
"ast",
".",
"parse",
"(",
"string",
")",
"visitor",
"=",
"TransVisitor",
"(",
"self",
".",
"tranz_functions",
",",
"self",
".",
"tranzchoice_functions",
")",
"visitor",
".",
... | Extract messages from Python string. | [
"Extract",
"messages",
"from",
"Python",
"string",
"."
] | 0aee83f434bd2d1b95767bcd63adb7ac7036c7df | https://github.com/adamziel/python_translate/blob/0aee83f434bd2d1b95767bcd63adb7ac7036c7df/python_translate/extractors/python.py#L34-L44 | train |
tjcsl/cslbot | cslbot/commands/isup.py | cmd | def cmd(send, msg, args):
"""Checks if a website is up.
Syntax: {command} <website>
"""
if not msg:
send("What are you trying to get to?")
return
nick = args['nick']
isup = get("http://isup.me/%s" % msg).text
if "looks down from here" in isup:
send("%s: %s is down" ... | python | def cmd(send, msg, args):
"""Checks if a website is up.
Syntax: {command} <website>
"""
if not msg:
send("What are you trying to get to?")
return
nick = args['nick']
isup = get("http://isup.me/%s" % msg).text
if "looks down from here" in isup:
send("%s: %s is down" ... | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"args",
")",
":",
"if",
"not",
"msg",
":",
"send",
"(",
"\"What are you trying to get to?\"",
")",
"return",
"nick",
"=",
"args",
"[",
"'nick'",
"]",
"isup",
"=",
"get",
"(",
"\"http://isup.me/%s\"",
"%",
"msg"... | Checks if a website is up.
Syntax: {command} <website> | [
"Checks",
"if",
"a",
"website",
"is",
"up",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/isup.py#L24-L40 | train |
tylerbutler/engineer | engineer/conf.py | EngineerConfiguration.create_required_directories | def create_required_directories(self):
"""Creates any directories required for Engineer to function if they don't already exist."""
required = (self.CACHE_DIR,
self.LOG_DIR,
self.OUTPUT_DIR,
self.ENGINEER.JINJA_CACHE_DIR,)
for folder i... | python | def create_required_directories(self):
"""Creates any directories required for Engineer to function if they don't already exist."""
required = (self.CACHE_DIR,
self.LOG_DIR,
self.OUTPUT_DIR,
self.ENGINEER.JINJA_CACHE_DIR,)
for folder i... | [
"def",
"create_required_directories",
"(",
"self",
")",
":",
"required",
"=",
"(",
"self",
".",
"CACHE_DIR",
",",
"self",
".",
"LOG_DIR",
",",
"self",
".",
"OUTPUT_DIR",
",",
"self",
".",
"ENGINEER",
".",
"JINJA_CACHE_DIR",
",",
")",
"for",
"folder",
"in",... | Creates any directories required for Engineer to function if they don't already exist. | [
"Creates",
"any",
"directories",
"required",
"for",
"Engineer",
"to",
"function",
"if",
"they",
"don",
"t",
"already",
"exist",
"."
] | 8884f587297f37646c40e5553174852b444a4024 | https://github.com/tylerbutler/engineer/blob/8884f587297f37646c40e5553174852b444a4024/engineer/conf.py#L432-L440 | train |
tjcsl/cslbot | cslbot/commands/wiki.py | cmd | def cmd(send, msg, args):
"""Returns the first wikipedia result for the argument.
Syntax: {command} [term]
"""
if 'livedoc' in args['name']:
url = 'http://livedoc.tjhsst.edu/w'
name = 'livedoc'
else:
url = 'http://en.wikipedia.org/w'
name = 'wikipedia'
if not ms... | python | def cmd(send, msg, args):
"""Returns the first wikipedia result for the argument.
Syntax: {command} [term]
"""
if 'livedoc' in args['name']:
url = 'http://livedoc.tjhsst.edu/w'
name = 'livedoc'
else:
url = 'http://en.wikipedia.org/w'
name = 'wikipedia'
if not ms... | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"args",
")",
":",
"if",
"'livedoc'",
"in",
"args",
"[",
"'name'",
"]",
":",
"url",
"=",
"'http://livedoc.tjhsst.edu/w'",
"name",
"=",
"'livedoc'",
"else",
":",
"url",
"=",
"'http://en.wikipedia.org/w'",
"name",
"... | Returns the first wikipedia result for the argument.
Syntax: {command} [term] | [
"Returns",
"the",
"first",
"wikipedia",
"result",
"for",
"the",
"argument",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/wiki.py#L30-L54 | train |
jmbeach/KEP.py | src/keppy/channel.py | Channel.parse_devices | def parse_devices(self):
"""Creates an array of Device objects from the channel"""
devices = []
for device in self._channel_dict["devices"]:
devices.append(Device(device, self._is_sixteen_bit, self._ignore_list))
return devices | python | def parse_devices(self):
"""Creates an array of Device objects from the channel"""
devices = []
for device in self._channel_dict["devices"]:
devices.append(Device(device, self._is_sixteen_bit, self._ignore_list))
return devices | [
"def",
"parse_devices",
"(",
"self",
")",
":",
"devices",
"=",
"[",
"]",
"for",
"device",
"in",
"self",
".",
"_channel_dict",
"[",
"\"devices\"",
"]",
":",
"devices",
".",
"append",
"(",
"Device",
"(",
"device",
",",
"self",
".",
"_is_sixteen_bit",
",",
... | Creates an array of Device objects from the channel | [
"Creates",
"an",
"array",
"of",
"Device",
"objects",
"from",
"the",
"channel"
] | 68cda64ab649640a486534867c81274c41e39446 | https://github.com/jmbeach/KEP.py/blob/68cda64ab649640a486534867c81274c41e39446/src/keppy/channel.py#L19-L24 | train |
jmbeach/KEP.py | src/keppy/channel.py | Channel.update | def update(self):
"""Updates the dictionary of the channel"""
for device in self.devices:
device.update()
for i in range(len(self._channel_dict["devices"])):
device_dict = self._channel_dict["devices"][i]
for device in self._devices:
if device.... | python | def update(self):
"""Updates the dictionary of the channel"""
for device in self.devices:
device.update()
for i in range(len(self._channel_dict["devices"])):
device_dict = self._channel_dict["devices"][i]
for device in self._devices:
if device.... | [
"def",
"update",
"(",
"self",
")",
":",
"for",
"device",
"in",
"self",
".",
"devices",
":",
"device",
".",
"update",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"_channel_dict",
"[",
"\"devices\"",
"]",
")",
")",
":",
"device... | Updates the dictionary of the channel | [
"Updates",
"the",
"dictionary",
"of",
"the",
"channel"
] | 68cda64ab649640a486534867c81274c41e39446 | https://github.com/jmbeach/KEP.py/blob/68cda64ab649640a486534867c81274c41e39446/src/keppy/channel.py#L44-L52 | train |
JNPRAutomate/pyJunosManager | pyJunosManager/pyJunosManager.py | JunosDevice.open_config | def open_config(self,type="shared"):
"""
Opens the configuration of the currently connected device
Args:
:type: The type of configuration you want to open. Any string can be provided, however the standard supported options are: **exclusive**, **private**, and **shared**. The default... | python | def open_config(self,type="shared"):
"""
Opens the configuration of the currently connected device
Args:
:type: The type of configuration you want to open. Any string can be provided, however the standard supported options are: **exclusive**, **private**, and **shared**. The default... | [
"def",
"open_config",
"(",
"self",
",",
"type",
"=",
"\"shared\"",
")",
":",
"try",
":",
"output",
"=",
"self",
".",
"dev",
".",
"rpc",
"(",
"\"<open-configuration><{0}/></open-configuration>\"",
".",
"format",
"(",
"type",
")",
")",
"except",
"Exception",
"... | Opens the configuration of the currently connected device
Args:
:type: The type of configuration you want to open. Any string can be provided, however the standard supported options are: **exclusive**, **private**, and **shared**. The default mode is **shared**.
Examples:
.. code-... | [
"Opens",
"the",
"configuration",
"of",
"the",
"currently",
"connected",
"device"
] | cfbe87bb55488f44bad0b383771a88be7b2ccf2a | https://github.com/JNPRAutomate/pyJunosManager/blob/cfbe87bb55488f44bad0b383771a88be7b2ccf2a/pyJunosManager/pyJunosManager.py#L95-L131 | train |
JNPRAutomate/pyJunosManager | pyJunosManager/pyJunosManager.py | JunosDevice.close_config | def close_config(self):
"""
Closes the exiting opened configuration
Example:
.. code-block:: python
from pyJunosManager import JunosDevice
dev = JunosDevice(host="1.2.3.4",username="root",password="Juniper")
dev.open()
dev.open_config()... | python | def close_config(self):
"""
Closes the exiting opened configuration
Example:
.. code-block:: python
from pyJunosManager import JunosDevice
dev = JunosDevice(host="1.2.3.4",username="root",password="Juniper")
dev.open()
dev.open_config()... | [
"def",
"close_config",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"dev",
".",
"rpc",
".",
"close_configuration",
"(",
")",
"except",
"Exception",
"as",
"err",
":",
"print",
"err"
] | Closes the exiting opened configuration
Example:
.. code-block:: python
from pyJunosManager import JunosDevice
dev = JunosDevice(host="1.2.3.4",username="root",password="Juniper")
dev.open()
dev.open_config()
dev.close_config()
... | [
"Closes",
"the",
"exiting",
"opened",
"configuration"
] | cfbe87bb55488f44bad0b383771a88be7b2ccf2a | https://github.com/JNPRAutomate/pyJunosManager/blob/cfbe87bb55488f44bad0b383771a88be7b2ccf2a/pyJunosManager/pyJunosManager.py#L133-L153 | train |
JNPRAutomate/pyJunosManager | pyJunosManager/pyJunosManager.py | JunosDevice.commit_config | def commit_config(self):
"""
Commits exiting configuration
Example:
.. code-block:: python
from pyJunosManager import JunosDevice
dev = JunosDevice(host="1.2.3.4",username="root",password="Juniper")
dev.open()
dev.open_config()
... | python | def commit_config(self):
"""
Commits exiting configuration
Example:
.. code-block:: python
from pyJunosManager import JunosDevice
dev = JunosDevice(host="1.2.3.4",username="root",password="Juniper")
dev.open()
dev.open_config()
... | [
"def",
"commit_config",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"dev",
".",
"rpc",
".",
"commit_configuration",
"(",
")",
"except",
"Exception",
"as",
"err",
":",
"print",
"err"
] | Commits exiting configuration
Example:
.. code-block:: python
from pyJunosManager import JunosDevice
dev = JunosDevice(host="1.2.3.4",username="root",password="Juniper")
dev.open()
dev.open_config()
dev.commit_config()
dev.close... | [
"Commits",
"exiting",
"configuration"
] | cfbe87bb55488f44bad0b383771a88be7b2ccf2a | https://github.com/JNPRAutomate/pyJunosManager/blob/cfbe87bb55488f44bad0b383771a88be7b2ccf2a/pyJunosManager/pyJunosManager.py#L189-L209 | train |
JNPRAutomate/pyJunosManager | pyJunosManager/pyJunosManager.py | JunosDevice.commit_and_quit | def commit_and_quit(self):
"""
Commits and closes the currently open configration. Saves a step by not needing to manually close the config.
Example:
.. code-block:: python
from pyJunosManager import JunosDevice
dev = JunosDevice(host="1.2.3.4",username="root"... | python | def commit_and_quit(self):
"""
Commits and closes the currently open configration. Saves a step by not needing to manually close the config.
Example:
.. code-block:: python
from pyJunosManager import JunosDevice
dev = JunosDevice(host="1.2.3.4",username="root"... | [
"def",
"commit_and_quit",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"dev",
".",
"rpc",
".",
"commit_configuration",
"(",
")",
"self",
".",
"close_config",
"(",
")",
"except",
"Exception",
"as",
"err",
":",
"print",
"err"
] | Commits and closes the currently open configration. Saves a step by not needing to manually close the config.
Example:
.. code-block:: python
from pyJunosManager import JunosDevice
dev = JunosDevice(host="1.2.3.4",username="root",password="Juniper")
dev.open()
... | [
"Commits",
"and",
"closes",
"the",
"currently",
"open",
"configration",
".",
"Saves",
"a",
"step",
"by",
"not",
"needing",
"to",
"manually",
"close",
"the",
"config",
"."
] | cfbe87bb55488f44bad0b383771a88be7b2ccf2a | https://github.com/JNPRAutomate/pyJunosManager/blob/cfbe87bb55488f44bad0b383771a88be7b2ccf2a/pyJunosManager/pyJunosManager.py#L211-L232 | train |
Genida/archan | src/archan/config.py | Config.load_local_plugin | def load_local_plugin(name):
"""Import a local plugin accessible through Python path."""
try:
module_name = '.'.join(name.split('.')[:-1])
module_obj = importlib.import_module(name=module_name)
obj = getattr(module_obj, name.split('.')[-1])
return obj
... | python | def load_local_plugin(name):
"""Import a local plugin accessible through Python path."""
try:
module_name = '.'.join(name.split('.')[:-1])
module_obj = importlib.import_module(name=module_name)
obj = getattr(module_obj, name.split('.')[-1])
return obj
... | [
"def",
"load_local_plugin",
"(",
"name",
")",
":",
"try",
":",
"module_name",
"=",
"'.'",
".",
"join",
"(",
"name",
".",
"split",
"(",
"'.'",
")",
"[",
":",
"-",
"1",
"]",
")",
"module_obj",
"=",
"importlib",
".",
"import_module",
"(",
"name",
"=",
... | Import a local plugin accessible through Python path. | [
"Import",
"a",
"local",
"plugin",
"accessible",
"through",
"Python",
"path",
"."
] | a026d3105c7e86f30e6c9507b93ceb736684bfdc | https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/config.py#L68-L76 | train |
Genida/archan | src/archan/config.py | Config.load_installed_plugins | def load_installed_plugins():
"""Search and load every installed plugin through entry points."""
providers = {}
checkers = {}
for entry_point in pkg_resources.iter_entry_points(group='archan'):
obj = entry_point.load()
if issubclass(obj, Provider):
... | python | def load_installed_plugins():
"""Search and load every installed plugin through entry points."""
providers = {}
checkers = {}
for entry_point in pkg_resources.iter_entry_points(group='archan'):
obj = entry_point.load()
if issubclass(obj, Provider):
... | [
"def",
"load_installed_plugins",
"(",
")",
":",
"providers",
"=",
"{",
"}",
"checkers",
"=",
"{",
"}",
"for",
"entry_point",
"in",
"pkg_resources",
".",
"iter_entry_points",
"(",
"group",
"=",
"'archan'",
")",
":",
"obj",
"=",
"entry_point",
".",
"load",
"... | Search and load every installed plugin through entry points. | [
"Search",
"and",
"load",
"every",
"installed",
"plugin",
"through",
"entry",
"points",
"."
] | a026d3105c7e86f30e6c9507b93ceb736684bfdc | https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/config.py#L79-L92 | train |
Genida/archan | src/archan/config.py | Config.from_file | def from_file(path):
"""Return a ``Config`` instance by reading a configuration file."""
with open(path) as stream:
obj = yaml.safe_load(stream)
Config.lint(obj)
return Config(config_dict=obj) | python | def from_file(path):
"""Return a ``Config`` instance by reading a configuration file."""
with open(path) as stream:
obj = yaml.safe_load(stream)
Config.lint(obj)
return Config(config_dict=obj) | [
"def",
"from_file",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"stream",
":",
"obj",
"=",
"yaml",
".",
"safe_load",
"(",
"stream",
")",
"Config",
".",
"lint",
"(",
"obj",
")",
"return",
"Config",
"(",
"config_dict",
"=",
"obj",
... | Return a ``Config`` instance by reading a configuration file. | [
"Return",
"a",
"Config",
"instance",
"by",
"reading",
"a",
"configuration",
"file",
"."
] | a026d3105c7e86f30e6c9507b93ceb736684bfdc | https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/config.py#L103-L108 | train |
Genida/archan | src/archan/config.py | Config.find | def find():
"""Find the configuration file if any."""
names = ('archan.yml', 'archan.yaml', '.archan.yml', '.archan.yaml')
current_dir = os.getcwd()
configconfig_file = os.path.join(current_dir, '.configconfig')
default_config_dir = os.path.join(current_dir, 'config')
if ... | python | def find():
"""Find the configuration file if any."""
names = ('archan.yml', 'archan.yaml', '.archan.yml', '.archan.yaml')
current_dir = os.getcwd()
configconfig_file = os.path.join(current_dir, '.configconfig')
default_config_dir = os.path.join(current_dir, 'config')
if ... | [
"def",
"find",
"(",
")",
":",
"names",
"=",
"(",
"'archan.yml'",
",",
"'archan.yaml'",
",",
"'.archan.yml'",
",",
"'.archan.yaml'",
")",
"current_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"configconfig_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cu... | Find the configuration file if any. | [
"Find",
"the",
"configuration",
"file",
"if",
"any",
"."
] | a026d3105c7e86f30e6c9507b93ceb736684bfdc | https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/config.py#L111-L134 | train |
Genida/archan | src/archan/config.py | Config.inflate_nd_checker | def inflate_nd_checker(identifier, definition):
"""
Inflate a no-data checker from a basic definition.
Args:
identifier (str): the no-data checker identifier / name.
definition (bool/dict): a boolean acting as "passes" or a full
dict definition with "pass... | python | def inflate_nd_checker(identifier, definition):
"""
Inflate a no-data checker from a basic definition.
Args:
identifier (str): the no-data checker identifier / name.
definition (bool/dict): a boolean acting as "passes" or a full
dict definition with "pass... | [
"def",
"inflate_nd_checker",
"(",
"identifier",
",",
"definition",
")",
":",
"if",
"isinstance",
"(",
"definition",
",",
"bool",
")",
":",
"return",
"Checker",
"(",
"name",
"=",
"identifier",
",",
"passes",
"=",
"definition",
")",
"elif",
"isinstance",
"(",
... | Inflate a no-data checker from a basic definition.
Args:
identifier (str): the no-data checker identifier / name.
definition (bool/dict): a boolean acting as "passes" or a full
dict definition with "passes" and "allow_failure".
Returns:
Checker: a ch... | [
"Inflate",
"a",
"no",
"-",
"data",
"checker",
"from",
"a",
"basic",
"definition",
"."
] | a026d3105c7e86f30e6c9507b93ceb736684bfdc | https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/config.py#L215-L236 | train |
Genida/archan | src/archan/config.py | Config.get_plugin | def get_plugin(self, identifier, cls=None):
"""
Return the plugin corresponding to the given identifier and type.
Args:
identifier (str): identifier of the plugin.
cls (str): one of checker / provider.
Returns:
Checker/Provider: plugin class.
... | python | def get_plugin(self, identifier, cls=None):
"""
Return the plugin corresponding to the given identifier and type.
Args:
identifier (str): identifier of the plugin.
cls (str): one of checker / provider.
Returns:
Checker/Provider: plugin class.
... | [
"def",
"get_plugin",
"(",
"self",
",",
"identifier",
",",
"cls",
"=",
"None",
")",
":",
"if",
"(",
"(",
"cls",
"is",
"None",
"or",
"cls",
"==",
"'provider'",
")",
"and",
"identifier",
"in",
"self",
".",
"available_providers",
")",
":",
"return",
"self"... | Return the plugin corresponding to the given identifier and type.
Args:
identifier (str): identifier of the plugin.
cls (str): one of checker / provider.
Returns:
Checker/Provider: plugin class. | [
"Return",
"the",
"plugin",
"corresponding",
"to",
"the",
"given",
"identifier",
"and",
"type",
"."
] | a026d3105c7e86f30e6c9507b93ceb736684bfdc | https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/config.py#L255-L272 | train |
Genida/archan | src/archan/config.py | Config.provider_from_dict | def provider_from_dict(self, dct):
"""Return a provider instance from a dict object."""
provider_identifier = list(dct.keys())[0]
provider_class = self.get_provider(provider_identifier)
if provider_class:
return provider_class(**dct[provider_identifier])
return None | python | def provider_from_dict(self, dct):
"""Return a provider instance from a dict object."""
provider_identifier = list(dct.keys())[0]
provider_class = self.get_provider(provider_identifier)
if provider_class:
return provider_class(**dct[provider_identifier])
return None | [
"def",
"provider_from_dict",
"(",
"self",
",",
"dct",
")",
":",
"provider_identifier",
"=",
"list",
"(",
"dct",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"provider_class",
"=",
"self",
".",
"get_provider",
"(",
"provider_identifier",
")",
"if",
"provider_... | Return a provider instance from a dict object. | [
"Return",
"a",
"provider",
"instance",
"from",
"a",
"dict",
"object",
"."
] | a026d3105c7e86f30e6c9507b93ceb736684bfdc | https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/config.py#L282-L288 | train |
Genida/archan | src/archan/config.py | Config.checker_from_dict | def checker_from_dict(self, dct):
"""Return a checker instance from a dict object."""
checker_identifier = list(dct.keys())[0]
checker_class = self.get_checker(checker_identifier)
if checker_class:
return checker_class(**dct[checker_identifier])
return None | python | def checker_from_dict(self, dct):
"""Return a checker instance from a dict object."""
checker_identifier = list(dct.keys())[0]
checker_class = self.get_checker(checker_identifier)
if checker_class:
return checker_class(**dct[checker_identifier])
return None | [
"def",
"checker_from_dict",
"(",
"self",
",",
"dct",
")",
":",
"checker_identifier",
"=",
"list",
"(",
"dct",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"checker_class",
"=",
"self",
".",
"get_checker",
"(",
"checker_identifier",
")",
"if",
"checker_class"... | Return a checker instance from a dict object. | [
"Return",
"a",
"checker",
"instance",
"from",
"a",
"dict",
"object",
"."
] | a026d3105c7e86f30e6c9507b93ceb736684bfdc | https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/config.py#L290-L296 | train |
Genida/archan | src/archan/config.py | Config.inflate_plugin | def inflate_plugin(self, identifier, definition=None, cls=None):
"""
Inflate a plugin thanks to it's identifier, definition and class.
Args:
identifier (str): the plugin identifier.
definition (dict): the kwargs to instantiate the plugin with.
cls (str): "pro... | python | def inflate_plugin(self, identifier, definition=None, cls=None):
"""
Inflate a plugin thanks to it's identifier, definition and class.
Args:
identifier (str): the plugin identifier.
definition (dict): the kwargs to instantiate the plugin with.
cls (str): "pro... | [
"def",
"inflate_plugin",
"(",
"self",
",",
"identifier",
",",
"definition",
"=",
"None",
",",
"cls",
"=",
"None",
")",
":",
"cls",
"=",
"self",
".",
"get_plugin",
"(",
"identifier",
",",
"cls",
")",
"return",
"cls",
"(",
"**",
"definition",
"or",
"{",
... | Inflate a plugin thanks to it's identifier, definition and class.
Args:
identifier (str): the plugin identifier.
definition (dict): the kwargs to instantiate the plugin with.
cls (str): "provider", "checker", or None.
Returns:
Provider/Checker: instance ... | [
"Inflate",
"a",
"plugin",
"thanks",
"to",
"it",
"s",
"identifier",
"definition",
"and",
"class",
"."
] | a026d3105c7e86f30e6c9507b93ceb736684bfdc | https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/config.py#L298-L313 | train |
Genida/archan | src/archan/config.py | Config.inflate_analysis_group | def inflate_analysis_group(self, identifier, definition):
"""
Inflate a whole analysis group.
An analysis group is a section defined in the YAML file.
Args:
identifier (str): the group identifier.
definition (list/dict): the group definition.
Returns:
... | python | def inflate_analysis_group(self, identifier, definition):
"""
Inflate a whole analysis group.
An analysis group is a section defined in the YAML file.
Args:
identifier (str): the group identifier.
definition (list/dict): the group definition.
Returns:
... | [
"def",
"inflate_analysis_group",
"(",
"self",
",",
"identifier",
",",
"definition",
")",
":",
"providers_definition",
"=",
"definition",
".",
"pop",
"(",
"'providers'",
",",
"None",
")",
"checkers_definition",
"=",
"definition",
".",
"pop",
"(",
"'checkers'",
",... | Inflate a whole analysis group.
An analysis group is a section defined in the YAML file.
Args:
identifier (str): the group identifier.
definition (list/dict): the group definition.
Returns:
AnalysisGroup: an instance of AnalysisGroup.
Raises:
... | [
"Inflate",
"a",
"whole",
"analysis",
"group",
"."
] | a026d3105c7e86f30e6c9507b93ceb736684bfdc | https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/config.py#L353-L431 | train |
Genida/archan | src/archan/config.py | Config.print_plugins | def print_plugins(self):
"""Print the available plugins."""
width = console_width()
line = Style.BRIGHT + '=' * width + '\n'
middle = int(width / 2)
if self.available_providers:
print(line + ' ' * middle + 'PROVIDERS')
for provider in sorted(self.available... | python | def print_plugins(self):
"""Print the available plugins."""
width = console_width()
line = Style.BRIGHT + '=' * width + '\n'
middle = int(width / 2)
if self.available_providers:
print(line + ' ' * middle + 'PROVIDERS')
for provider in sorted(self.available... | [
"def",
"print_plugins",
"(",
"self",
")",
":",
"width",
"=",
"console_width",
"(",
")",
"line",
"=",
"Style",
".",
"BRIGHT",
"+",
"'='",
"*",
"width",
"+",
"'\\n'",
"middle",
"=",
"int",
"(",
"width",
"/",
"2",
")",
"if",
"self",
".",
"available_prov... | Print the available plugins. | [
"Print",
"the",
"available",
"plugins",
"."
] | a026d3105c7e86f30e6c9507b93ceb736684bfdc | https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/config.py#L433-L449 | train |
tjcsl/cslbot | cslbot/commands/random.py | cmd | def cmd(send, msg, args):
"""For when you don't have enough randomness in your life.
Syntax: {command} [--int] [len]
"""
match = re.match(r'--(.+?)\b', msg)
randtype = 'hex'
if match:
if match.group(1) == 'int':
randtype = 'int'
else:
send("Invalid Flag.... | python | def cmd(send, msg, args):
"""For when you don't have enough randomness in your life.
Syntax: {command} [--int] [len]
"""
match = re.match(r'--(.+?)\b', msg)
randtype = 'hex'
if match:
if match.group(1) == 'int':
randtype = 'int'
else:
send("Invalid Flag.... | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"args",
")",
":",
"match",
"=",
"re",
".",
"match",
"(",
"r'--(.+?)\\b'",
",",
"msg",
")",
"randtype",
"=",
"'hex'",
"if",
"match",
":",
"if",
"match",
".",
"group",
"(",
"1",
")",
"==",
"'int'",
":",
... | For when you don't have enough randomness in your life.
Syntax: {command} [--int] [len] | [
"For",
"when",
"you",
"don",
"t",
"have",
"enough",
"randomness",
"in",
"your",
"life",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/random.py#L25-L50 | train |
VIVelev/PyDojoML | dojo/tree/utils/functions.py | split | def split(X, Y, question):
"""Partitions a dataset.
For each row in the dataset, check if it matches the question. If
so, add it to 'true rows', otherwise, add it to 'false rows'.
"""
true_X, false_X = [], []
true_Y, false_Y = [], []
for x, y in zip(X, Y):
if question.match(x):
... | python | def split(X, Y, question):
"""Partitions a dataset.
For each row in the dataset, check if it matches the question. If
so, add it to 'true rows', otherwise, add it to 'false rows'.
"""
true_X, false_X = [], []
true_Y, false_Y = [], []
for x, y in zip(X, Y):
if question.match(x):
... | [
"def",
"split",
"(",
"X",
",",
"Y",
",",
"question",
")",
":",
"true_X",
",",
"false_X",
"=",
"[",
"]",
",",
"[",
"]",
"true_Y",
",",
"false_Y",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"x",
",",
"y",
"in",
"zip",
"(",
"X",
",",
"Y",
")",
":"... | Partitions a dataset.
For each row in the dataset, check if it matches the question. If
so, add it to 'true rows', otherwise, add it to 'false rows'. | [
"Partitions",
"a",
"dataset",
"."
] | 773fdce6866aa6decd306a5a85f94129fed816eb | https://github.com/VIVelev/PyDojoML/blob/773fdce6866aa6decd306a5a85f94129fed816eb/dojo/tree/utils/functions.py#L17-L37 | train |
VIVelev/PyDojoML | dojo/tree/utils/functions.py | build_tree | def build_tree(X, y, criterion, max_depth, current_depth=1):
"""Builds the decision tree.
"""
# check for max_depth accomplished
if max_depth >= 0 and current_depth >= max_depth:
return Leaf(y)
# check for 0 gain
gain, question = find_best_question(X, y, criterion)
if gain == 0:
... | python | def build_tree(X, y, criterion, max_depth, current_depth=1):
"""Builds the decision tree.
"""
# check for max_depth accomplished
if max_depth >= 0 and current_depth >= max_depth:
return Leaf(y)
# check for 0 gain
gain, question = find_best_question(X, y, criterion)
if gain == 0:
... | [
"def",
"build_tree",
"(",
"X",
",",
"y",
",",
"criterion",
",",
"max_depth",
",",
"current_depth",
"=",
"1",
")",
":",
"if",
"max_depth",
">=",
"0",
"and",
"current_depth",
">=",
"max_depth",
":",
"return",
"Leaf",
"(",
"y",
")",
"gain",
",",
"question... | Builds the decision tree. | [
"Builds",
"the",
"decision",
"tree",
"."
] | 773fdce6866aa6decd306a5a85f94129fed816eb | https://github.com/VIVelev/PyDojoML/blob/773fdce6866aa6decd306a5a85f94129fed816eb/dojo/tree/utils/functions.py#L92-L129 | train |
VIVelev/PyDojoML | dojo/tree/utils/functions.py | print_tree | def print_tree(root, space=' '):
"""Prints the Decision Tree in a pretty way.
"""
if isinstance(root, Leaf):
print(space + "Prediction: " + str(root.most_frequent))
return
print(space + str(root.question))
print(space + "--> True:")
print_tree(root.true_branch, space+' ')
... | python | def print_tree(root, space=' '):
"""Prints the Decision Tree in a pretty way.
"""
if isinstance(root, Leaf):
print(space + "Prediction: " + str(root.most_frequent))
return
print(space + str(root.question))
print(space + "--> True:")
print_tree(root.true_branch, space+' ')
... | [
"def",
"print_tree",
"(",
"root",
",",
"space",
"=",
"' '",
")",
":",
"if",
"isinstance",
"(",
"root",
",",
"Leaf",
")",
":",
"print",
"(",
"space",
"+",
"\"Prediction: \"",
"+",
"str",
"(",
"root",
".",
"most_frequent",
")",
")",
"return",
"print",
... | Prints the Decision Tree in a pretty way. | [
"Prints",
"the",
"Decision",
"Tree",
"in",
"a",
"pretty",
"way",
"."
] | 773fdce6866aa6decd306a5a85f94129fed816eb | https://github.com/VIVelev/PyDojoML/blob/773fdce6866aa6decd306a5a85f94129fed816eb/dojo/tree/utils/functions.py#L193-L207 | train |
levi-rs/explicit | explicit/waiter.py | find_element | def find_element(driver, elem_path, by=CSS, timeout=TIMEOUT, poll_frequency=0.5):
""" Find and return an element once located
find_element locates an element on the page, waiting
for up to timeout seconds. The element, when located,
is returned. If not located, a TimeoutException is raised.
Args:
... | python | def find_element(driver, elem_path, by=CSS, timeout=TIMEOUT, poll_frequency=0.5):
""" Find and return an element once located
find_element locates an element on the page, waiting
for up to timeout seconds. The element, when located,
is returned. If not located, a TimeoutException is raised.
Args:
... | [
"def",
"find_element",
"(",
"driver",
",",
"elem_path",
",",
"by",
"=",
"CSS",
",",
"timeout",
"=",
"TIMEOUT",
",",
"poll_frequency",
"=",
"0.5",
")",
":",
"wait",
"=",
"WebDriverWait",
"(",
"driver",
",",
"timeout",
",",
"poll_frequency",
")",
"return",
... | Find and return an element once located
find_element locates an element on the page, waiting
for up to timeout seconds. The element, when located,
is returned. If not located, a TimeoutException is raised.
Args:
driver (selenium webdriver or element): A driver or element
elem_path (str... | [
"Find",
"and",
"return",
"an",
"element",
"once",
"located"
] | 0ebdd4c8e74dae02fd92b914325e37e386694e4c | https://github.com/levi-rs/explicit/blob/0ebdd4c8e74dae02fd92b914325e37e386694e4c/explicit/waiter.py#L20-L41 | train |
levi-rs/explicit | explicit/waiter.py | find_elements | def find_elements(driver, elem_path, by=CSS, timeout=TIMEOUT, poll_frequency=0.5):
""" Find and return all elements once located
find_elements locates all elements on the page, waiting
for up to timeout seconds. The elements, when located,
are returned. If not located, a TimeoutException is raised.
... | python | def find_elements(driver, elem_path, by=CSS, timeout=TIMEOUT, poll_frequency=0.5):
""" Find and return all elements once located
find_elements locates all elements on the page, waiting
for up to timeout seconds. The elements, when located,
are returned. If not located, a TimeoutException is raised.
... | [
"def",
"find_elements",
"(",
"driver",
",",
"elem_path",
",",
"by",
"=",
"CSS",
",",
"timeout",
"=",
"TIMEOUT",
",",
"poll_frequency",
"=",
"0.5",
")",
":",
"wait",
"=",
"WebDriverWait",
"(",
"driver",
",",
"timeout",
",",
"poll_frequency",
")",
"return",
... | Find and return all elements once located
find_elements locates all elements on the page, waiting
for up to timeout seconds. The elements, when located,
are returned. If not located, a TimeoutException is raised.
Args:
driver (selenium webdriver or element): A driver or element
elem_pa... | [
"Find",
"and",
"return",
"all",
"elements",
"once",
"located"
] | 0ebdd4c8e74dae02fd92b914325e37e386694e4c | https://github.com/levi-rs/explicit/blob/0ebdd4c8e74dae02fd92b914325e37e386694e4c/explicit/waiter.py#L44-L65 | train |
levi-rs/explicit | explicit/waiter.py | find_write | def find_write(driver, elem_path, write_str, clear_first=True, send_enter=False,
by=CSS, timeout=TIMEOUT, poll_frequency=0.5):
""" Find a writable element and write to it
find_write locates a writable element on the page, waiting
for up to timeout seconds. Once found, it writes the string
... | python | def find_write(driver, elem_path, write_str, clear_first=True, send_enter=False,
by=CSS, timeout=TIMEOUT, poll_frequency=0.5):
""" Find a writable element and write to it
find_write locates a writable element on the page, waiting
for up to timeout seconds. Once found, it writes the string
... | [
"def",
"find_write",
"(",
"driver",
",",
"elem_path",
",",
"write_str",
",",
"clear_first",
"=",
"True",
",",
"send_enter",
"=",
"False",
",",
"by",
"=",
"CSS",
",",
"timeout",
"=",
"TIMEOUT",
",",
"poll_frequency",
"=",
"0.5",
")",
":",
"elem",
"=",
"... | Find a writable element and write to it
find_write locates a writable element on the page, waiting
for up to timeout seconds. Once found, it writes the string
to it.
Args:
driver (selenium webdriver or element): A driver or element
elem_path (str): String used to located the element
... | [
"Find",
"a",
"writable",
"element",
"and",
"write",
"to",
"it"
] | 0ebdd4c8e74dae02fd92b914325e37e386694e4c | https://github.com/levi-rs/explicit/blob/0ebdd4c8e74dae02fd92b914325e37e386694e4c/explicit/waiter.py#L110-L145 | train |
tjcsl/cslbot | cslbot/commands/intensify.py | cmd | def cmd(send, msg, args):
"""Intensifies text.
Syntax: {command} [text]
"""
if not msg:
msg = gen_word()
send(gen_intensify(msg)) | python | def cmd(send, msg, args):
"""Intensifies text.
Syntax: {command} [text]
"""
if not msg:
msg = gen_word()
send(gen_intensify(msg)) | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"args",
")",
":",
"if",
"not",
"msg",
":",
"msg",
"=",
"gen_word",
"(",
")",
"send",
"(",
"gen_intensify",
"(",
"msg",
")",
")"
] | Intensifies text.
Syntax: {command} [text] | [
"Intensifies",
"text",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/intensify.py#L23-L31 | train |
The-Politico/politico-civic-election-night | electionnight/management/commands/bake_elections.py | Command.fetch_states | def fetch_states(self, elections):
"""
Returns the unique divisions for all elections on an election day.
"""
states = []
for election in elections:
if election.division.level.name == DivisionLevel.DISTRICT:
division = election.division.parent
... | python | def fetch_states(self, elections):
"""
Returns the unique divisions for all elections on an election day.
"""
states = []
for election in elections:
if election.division.level.name == DivisionLevel.DISTRICT:
division = election.division.parent
... | [
"def",
"fetch_states",
"(",
"self",
",",
"elections",
")",
":",
"states",
"=",
"[",
"]",
"for",
"election",
"in",
"elections",
":",
"if",
"election",
".",
"division",
".",
"level",
".",
"name",
"==",
"DivisionLevel",
".",
"DISTRICT",
":",
"division",
"="... | Returns the unique divisions for all elections on an election day. | [
"Returns",
"the",
"unique",
"divisions",
"for",
"all",
"elections",
"on",
"an",
"election",
"day",
"."
] | a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6 | https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/management/commands/bake_elections.py#L25-L39 | train |
ktdreyer/txkoji | txkoji/cache.py | Cache.get_name | def get_name(self, type_, id_):
"""
Read a cached name if available.
:param type_: str, "owner" or "tag"
:param id_: int, eg. 123456
:returns: str, or None
"""
cachefile = self.filename(type_, id_)
try:
with open(cachefile, 'r') as f:
... | python | def get_name(self, type_, id_):
"""
Read a cached name if available.
:param type_: str, "owner" or "tag"
:param id_: int, eg. 123456
:returns: str, or None
"""
cachefile = self.filename(type_, id_)
try:
with open(cachefile, 'r') as f:
... | [
"def",
"get_name",
"(",
"self",
",",
"type_",
",",
"id_",
")",
":",
"cachefile",
"=",
"self",
".",
"filename",
"(",
"type_",
",",
"id_",
")",
"try",
":",
"with",
"open",
"(",
"cachefile",
",",
"'r'",
")",
"as",
"f",
":",
"return",
"f",
".",
"read... | Read a cached name if available.
:param type_: str, "owner" or "tag"
:param id_: int, eg. 123456
:returns: str, or None | [
"Read",
"a",
"cached",
"name",
"if",
"available",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/cache.py#L29-L43 | train |
ktdreyer/txkoji | txkoji/cache.py | Cache.put_name | def put_name(self, type_, id_, name):
"""
Write a cached name to disk.
:param type_: str, "user" or "tag"
:param id_: int, eg. 123456
:returns: None
"""
cachefile = self.filename(type_, id_)
dirname = os.path.dirname(cachefile)
try:
os... | python | def put_name(self, type_, id_, name):
"""
Write a cached name to disk.
:param type_: str, "user" or "tag"
:param id_: int, eg. 123456
:returns: None
"""
cachefile = self.filename(type_, id_)
dirname = os.path.dirname(cachefile)
try:
os... | [
"def",
"put_name",
"(",
"self",
",",
"type_",
",",
"id_",
",",
"name",
")",
":",
"cachefile",
"=",
"self",
".",
"filename",
"(",
"type_",
",",
"id_",
")",
"dirname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"cachefile",
")",
"try",
":",
"os",
... | Write a cached name to disk.
:param type_: str, "user" or "tag"
:param id_: int, eg. 123456
:returns: None | [
"Write",
"a",
"cached",
"name",
"to",
"disk",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/cache.py#L45-L61 | train |
ktdreyer/txkoji | txkoji/cache.py | Cache.get_or_load_name | def get_or_load_name(self, type_, id_, method):
"""
read-through cache for a type of object's name.
If we don't have a cached name for this type/id, then we will query the
live Koji server and store the value before returning.
:param type_: str, "user" or "tag"
:param i... | python | def get_or_load_name(self, type_, id_, method):
"""
read-through cache for a type of object's name.
If we don't have a cached name for this type/id, then we will query the
live Koji server and store the value before returning.
:param type_: str, "user" or "tag"
:param i... | [
"def",
"get_or_load_name",
"(",
"self",
",",
"type_",
",",
"id_",
",",
"method",
")",
":",
"name",
"=",
"self",
".",
"get_name",
"(",
"type_",
",",
"id_",
")",
"if",
"name",
"is",
"not",
"None",
":",
"defer",
".",
"returnValue",
"(",
"name",
")",
"... | read-through cache for a type of object's name.
If we don't have a cached name for this type/id, then we will query the
live Koji server and store the value before returning.
:param type_: str, "user" or "tag"
:param id_: int, eg. 123456
:param method: function to call if this ... | [
"read",
"-",
"through",
"cache",
"for",
"a",
"type",
"of",
"object",
"s",
"name",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/cache.py#L75-L96 | train |
ktdreyer/txkoji | txkoji/multicall.py | MultiCall.call | def call(self, name, *args, **kwargs):
"""
Add a new call to the list that we will submit to the server.
Similar to txkoji.Connection.call(), but this will store the call
for later instead of sending it now.
"""
# Like txkoji.Connection, we always want the full request f... | python | def call(self, name, *args, **kwargs):
"""
Add a new call to the list that we will submit to the server.
Similar to txkoji.Connection.call(), but this will store the call
for later instead of sending it now.
"""
# Like txkoji.Connection, we always want the full request f... | [
"def",
"call",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"name",
"in",
"(",
"'getTaskInfo'",
",",
"'getTaskDescendants'",
")",
":",
"kwargs",
"[",
"'request'",
"]",
"=",
"True",
"if",
"kwargs",
":",
"kwargs",
"[... | Add a new call to the list that we will submit to the server.
Similar to txkoji.Connection.call(), but this will store the call
for later instead of sending it now. | [
"Add",
"a",
"new",
"call",
"to",
"the",
"list",
"that",
"we",
"will",
"submit",
"to",
"the",
"server",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/multicall.py#L44-L58 | train |
ktdreyer/txkoji | txkoji/multicall.py | MultiCall._multicall_callback | def _multicall_callback(self, values, calls):
"""
Fires when we get information back from the XML-RPC server.
This is processes the raw results of system.multicall into a usable
iterator of values (and/or Faults).
:param values: list of data txkoji.Connection.call()
:pa... | python | def _multicall_callback(self, values, calls):
"""
Fires when we get information back from the XML-RPC server.
This is processes the raw results of system.multicall into a usable
iterator of values (and/or Faults).
:param values: list of data txkoji.Connection.call()
:pa... | [
"def",
"_multicall_callback",
"(",
"self",
",",
"values",
",",
"calls",
")",
":",
"result",
"=",
"KojiMultiCallIterator",
"(",
"values",
")",
"result",
".",
"connection",
"=",
"self",
".",
"connection",
"result",
".",
"calls",
"=",
"calls",
"return",
"result... | Fires when we get information back from the XML-RPC server.
This is processes the raw results of system.multicall into a usable
iterator of values (and/or Faults).
:param values: list of data txkoji.Connection.call()
:param calls: list of calls we sent in this multicall RPC
:re... | [
"Fires",
"when",
"we",
"get",
"information",
"back",
"from",
"the",
"XML",
"-",
"RPC",
"server",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/multicall.py#L60-L75 | train |
mardix/Juice | juice/utils.py | time_ago | def time_ago(dt):
"""
Return the current time ago
"""
now = datetime.datetime.now()
return humanize.naturaltime(now - dt) | python | def time_ago(dt):
"""
Return the current time ago
"""
now = datetime.datetime.now()
return humanize.naturaltime(now - dt) | [
"def",
"time_ago",
"(",
"dt",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"return",
"humanize",
".",
"naturaltime",
"(",
"now",
"-",
"dt",
")"
] | Return the current time ago | [
"Return",
"the",
"current",
"time",
"ago"
] | 7afa8d4238868235dfcdae82272bd77958dd416a | https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/utils.py#L228-L233 | train |
tjcsl/cslbot | cslbot/commands/insult.py | cmd | def cmd(send, msg, args):
"""Insults a user.
Syntax: {command} [nick]
"""
if not msg:
user = choice(get_users(args))
else:
user = msg
send(gen_insult(user)) | python | def cmd(send, msg, args):
"""Insults a user.
Syntax: {command} [nick]
"""
if not msg:
user = choice(get_users(args))
else:
user = msg
send(gen_insult(user)) | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"args",
")",
":",
"if",
"not",
"msg",
":",
"user",
"=",
"choice",
"(",
"get_users",
"(",
"args",
")",
")",
"else",
":",
"user",
"=",
"msg",
"send",
"(",
"gen_insult",
"(",
"user",
")",
")"
] | Insults a user.
Syntax: {command} [nick] | [
"Insults",
"a",
"user",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/insult.py#L26-L37 | train |
klahnakoski/mo-json | mo_json/stream.py | needed | def needed(name, required):
"""
RETURN SUBSET IF name IN REQUIRED
"""
return [
relative_field(r, name) if r and startswith_field(r, name) else None
for r in required
] | python | def needed(name, required):
"""
RETURN SUBSET IF name IN REQUIRED
"""
return [
relative_field(r, name) if r and startswith_field(r, name) else None
for r in required
] | [
"def",
"needed",
"(",
"name",
",",
"required",
")",
":",
"return",
"[",
"relative_field",
"(",
"r",
",",
"name",
")",
"if",
"r",
"and",
"startswith_field",
"(",
"r",
",",
"name",
")",
"else",
"None",
"for",
"r",
"in",
"required",
"]"
] | RETURN SUBSET IF name IN REQUIRED | [
"RETURN",
"SUBSET",
"IF",
"name",
"IN",
"REQUIRED"
] | 0d44d6a7e37f0ea50e583c30c2cbc42488d5de7f | https://github.com/klahnakoski/mo-json/blob/0d44d6a7e37f0ea50e583c30c2cbc42488d5de7f/mo_json/stream.py#L326-L333 | train |
toumorokoshi/swagger-schema | swagger_schema/parameter.py | _match_data_to_parameter | def _match_data_to_parameter(cls, data):
""" find the appropriate parameter for a parameter field """
in_value = data["in"]
for cls in [QueryParameter, HeaderParameter, FormDataParameter,
PathParameter, BodyParameter]:
if in_value == cls.IN:
return cls
return None | python | def _match_data_to_parameter(cls, data):
""" find the appropriate parameter for a parameter field """
in_value = data["in"]
for cls in [QueryParameter, HeaderParameter, FormDataParameter,
PathParameter, BodyParameter]:
if in_value == cls.IN:
return cls
return None | [
"def",
"_match_data_to_parameter",
"(",
"cls",
",",
"data",
")",
":",
"in_value",
"=",
"data",
"[",
"\"in\"",
"]",
"for",
"cls",
"in",
"[",
"QueryParameter",
",",
"HeaderParameter",
",",
"FormDataParameter",
",",
"PathParameter",
",",
"BodyParameter",
"]",
":"... | find the appropriate parameter for a parameter field | [
"find",
"the",
"appropriate",
"parameter",
"for",
"a",
"parameter",
"field"
] | 24aa13d1f4ac59dfd81af2f5d8d4d1e66a139c97 | https://github.com/toumorokoshi/swagger-schema/blob/24aa13d1f4ac59dfd81af2f5d8d4d1e66a139c97/swagger_schema/parameter.py#L49-L56 | train |
tjcsl/cslbot | cslbot/commands/eix.py | cmd | def cmd(send, msg, args):
"""Runs eix with the given arguments.
Syntax: {command} <package>
"""
if not msg:
result = subprocess.run(['eix', '-c'], env={'EIX_LIMIT': '0', 'HOME': os.environ['HOME']}, stdout=subprocess.PIPE, universal_newlines=True)
if result.returncode:
send... | python | def cmd(send, msg, args):
"""Runs eix with the given arguments.
Syntax: {command} <package>
"""
if not msg:
result = subprocess.run(['eix', '-c'], env={'EIX_LIMIT': '0', 'HOME': os.environ['HOME']}, stdout=subprocess.PIPE, universal_newlines=True)
if result.returncode:
send... | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"args",
")",
":",
"if",
"not",
"msg",
":",
"result",
"=",
"subprocess",
".",
"run",
"(",
"[",
"'eix'",
",",
"'-c'",
"]",
",",
"env",
"=",
"{",
"'EIX_LIMIT'",
":",
"'0'",
",",
"'HOME'",
":",
"os",
".",... | Runs eix with the given arguments.
Syntax: {command} <package> | [
"Runs",
"eix",
"with",
"the",
"given",
"arguments",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/eix.py#L26-L44 | train |
ktdreyer/txkoji | txkoji/task_states.py | to_str | def to_str(number):
"""
Convert a task state ID number to a string.
:param int number: task state ID, eg. 1
:returns: state name like eg. "OPEN", or "(unknown)" if we don't know the
name of this task state ID number.
"""
states = globals()
for name, value in states.items():
... | python | def to_str(number):
"""
Convert a task state ID number to a string.
:param int number: task state ID, eg. 1
:returns: state name like eg. "OPEN", or "(unknown)" if we don't know the
name of this task state ID number.
"""
states = globals()
for name, value in states.items():
... | [
"def",
"to_str",
"(",
"number",
")",
":",
"states",
"=",
"globals",
"(",
")",
"for",
"name",
",",
"value",
"in",
"states",
".",
"items",
"(",
")",
":",
"if",
"number",
"==",
"value",
"and",
"name",
".",
"isalpha",
"(",
")",
"and",
"name",
".",
"i... | Convert a task state ID number to a string.
:param int number: task state ID, eg. 1
:returns: state name like eg. "OPEN", or "(unknown)" if we don't know the
name of this task state ID number. | [
"Convert",
"a",
"task",
"state",
"ID",
"number",
"to",
"a",
"string",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/task_states.py#L14-L26 | train |
shapiromatron/bmds | bmds/batch.py | SessionBatch.to_json | def to_json(self, filename, indent=2):
"""
Return a JSON string of all model inputs and outputs.
Parameters
----------
filename : str or file
Either the file name (string) or an open file (file-like object)
where the data will be saved.
indent : i... | python | def to_json(self, filename, indent=2):
"""
Return a JSON string of all model inputs and outputs.
Parameters
----------
filename : str or file
Either the file name (string) or an open file (file-like object)
where the data will be saved.
indent : i... | [
"def",
"to_json",
"(",
"self",
",",
"filename",
",",
"indent",
"=",
"2",
")",
":",
"d",
"=",
"self",
".",
"to_dicts",
"(",
")",
"if",
"hasattr",
"(",
"filename",
",",
"\"write\"",
")",
":",
"json",
".",
"dump",
"(",
"d",
",",
"filename",
",",
"in... | Return a JSON string of all model inputs and outputs.
Parameters
----------
filename : str or file
Either the file name (string) or an open file (file-like object)
where the data will be saved.
indent : int, optional
Indentation level for JSON output.... | [
"Return",
"a",
"JSON",
"string",
"of",
"all",
"model",
"inputs",
"and",
"outputs",
"."
] | 395c6ce84ad82876fd9fa4a89a3497fb61616de0 | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/batch.py#L59-L84 | train |
shapiromatron/bmds | bmds/batch.py | SessionBatch.to_df | def to_df(self, recommended_only=False, include_io=True):
"""
Return a pandas DataFrame for each model and dataset.
Parameters
----------
recommended_only : bool, optional
If True, only recommended models for each session are included. If
no model is reco... | python | def to_df(self, recommended_only=False, include_io=True):
"""
Return a pandas DataFrame for each model and dataset.
Parameters
----------
recommended_only : bool, optional
If True, only recommended models for each session are included. If
no model is reco... | [
"def",
"to_df",
"(",
"self",
",",
"recommended_only",
"=",
"False",
",",
"include_io",
"=",
"True",
")",
":",
"od",
"=",
"BMDS",
".",
"_df_ordered_dict",
"(",
"include_io",
")",
"[",
"session",
".",
"_add_to_to_ordered_dict",
"(",
"od",
",",
"i",
",",
"r... | Return a pandas DataFrame for each model and dataset.
Parameters
----------
recommended_only : bool, optional
If True, only recommended models for each session are included. If
no model is recommended, then a row with it's ID will be included,
but all fields ... | [
"Return",
"a",
"pandas",
"DataFrame",
"for",
"each",
"model",
"and",
"dataset",
"."
] | 395c6ce84ad82876fd9fa4a89a3497fb61616de0 | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/batch.py#L86-L111 | train |
shapiromatron/bmds | bmds/batch.py | SessionBatch.to_csv | def to_csv(self, filename, delimiter=",", recommended_only=False, include_io=True):
"""
Return a CSV for each model and dataset.
Parameters
----------
filename : str or file
Either the file name (string) or an open file (file-like object)
where the data w... | python | def to_csv(self, filename, delimiter=",", recommended_only=False, include_io=True):
"""
Return a CSV for each model and dataset.
Parameters
----------
filename : str or file
Either the file name (string) or an open file (file-like object)
where the data w... | [
"def",
"to_csv",
"(",
"self",
",",
"filename",
",",
"delimiter",
"=",
"\",\"",
",",
"recommended_only",
"=",
"False",
",",
"include_io",
"=",
"True",
")",
":",
"df",
"=",
"self",
".",
"to_df",
"(",
"recommended_only",
",",
"include_io",
")",
"df",
".",
... | Return a CSV for each model and dataset.
Parameters
----------
filename : str or file
Either the file name (string) or an open file (file-like object)
where the data will be saved.
delimiter : str, optional
Delimiter used in CSV file between fields.
... | [
"Return",
"a",
"CSV",
"for",
"each",
"model",
"and",
"dataset",
"."
] | 395c6ce84ad82876fd9fa4a89a3497fb61616de0 | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/batch.py#L113-L138 | train |
shapiromatron/bmds | bmds/batch.py | SessionBatch.to_excel | def to_excel(self, filename, recommended_only=False, include_io=True):
"""
Return an Excel file for each model and dataset.
Parameters
----------
filename : str or ExcelWriter object
Either the file name (string) or an ExcelWriter object.
recommended_only : b... | python | def to_excel(self, filename, recommended_only=False, include_io=True):
"""
Return an Excel file for each model and dataset.
Parameters
----------
filename : str or ExcelWriter object
Either the file name (string) or an ExcelWriter object.
recommended_only : b... | [
"def",
"to_excel",
"(",
"self",
",",
"filename",
",",
"recommended_only",
"=",
"False",
",",
"include_io",
"=",
"True",
")",
":",
"df",
"=",
"self",
".",
"to_df",
"(",
"recommended_only",
",",
"include_io",
")",
"if",
"isinstance",
"(",
"filename",
",",
... | Return an Excel file for each model and dataset.
Parameters
----------
filename : str or ExcelWriter object
Either the file name (string) or an ExcelWriter object.
recommended_only : bool, optional
If True, only recommended models for each session are included. I... | [
"Return",
"an",
"Excel",
"file",
"for",
"each",
"model",
"and",
"dataset",
"."
] | 395c6ce84ad82876fd9fa4a89a3497fb61616de0 | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/batch.py#L140-L164 | train |
shapiromatron/bmds | bmds/batch.py | SessionBatch.to_docx | def to_docx(
self,
filename=None,
input_dataset=True,
summary_table=True,
recommendation_details=True,
recommended_model=True,
all_models=False,
):
"""
Write batch sessions to a Word file.
Parameters
----------
filename... | python | def to_docx(
self,
filename=None,
input_dataset=True,
summary_table=True,
recommendation_details=True,
recommended_model=True,
all_models=False,
):
"""
Write batch sessions to a Word file.
Parameters
----------
filename... | [
"def",
"to_docx",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"input_dataset",
"=",
"True",
",",
"summary_table",
"=",
"True",
",",
"recommendation_details",
"=",
"True",
",",
"recommended_model",
"=",
"True",
",",
"all_models",
"=",
"False",
",",
")",
... | Write batch sessions to a Word file.
Parameters
----------
filename : str or None
If provided, the file is saved to this location, otherwise this
method returns a docx.Document
input_dataset : bool
Include input dataset data table
summary_tabl... | [
"Write",
"batch",
"sessions",
"to",
"a",
"Word",
"file",
"."
] | 395c6ce84ad82876fd9fa4a89a3497fb61616de0 | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/batch.py#L166-L215 | train |
shapiromatron/bmds | bmds/batch.py | SessionBatch.save_plots | def save_plots(self, directory, format="png", recommended_only=False):
"""
Save images of dose-response curve-fits for each model.
Parameters
----------
directory : str
Directory where the PNG files will be saved.
format : str, optional
Image outp... | python | def save_plots(self, directory, format="png", recommended_only=False):
"""
Save images of dose-response curve-fits for each model.
Parameters
----------
directory : str
Directory where the PNG files will be saved.
format : str, optional
Image outp... | [
"def",
"save_plots",
"(",
"self",
",",
"directory",
",",
"format",
"=",
"\"png\"",
",",
"recommended_only",
"=",
"False",
")",
":",
"for",
"i",
",",
"session",
"in",
"enumerate",
"(",
"self",
")",
":",
"session",
".",
"save_plots",
"(",
"directory",
",",... | Save images of dose-response curve-fits for each model.
Parameters
----------
directory : str
Directory where the PNG files will be saved.
format : str, optional
Image output format. Valid options include: png, pdf, svg, ps, eps
recommended_only : bool, o... | [
"Save",
"images",
"of",
"dose",
"-",
"response",
"curve",
"-",
"fits",
"for",
"each",
"model",
"."
] | 395c6ce84ad82876fd9fa4a89a3497fb61616de0 | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/batch.py#L217-L240 | train |
adamziel/python_translate | python_translate/glue.py | TransationLoader.load_messages | def load_messages(self, directory, catalogue):
"""
Loads translation found in a directory.
@type directory: string
@param directory: The directory to search
@type catalogue: MessageCatalogue
@param catalogue: The message catalogue to dump
@raises: ValueError
... | python | def load_messages(self, directory, catalogue):
"""
Loads translation found in a directory.
@type directory: string
@param directory: The directory to search
@type catalogue: MessageCatalogue
@param catalogue: The message catalogue to dump
@raises: ValueError
... | [
"def",
"load_messages",
"(",
"self",
",",
"directory",
",",
"catalogue",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"directory",
")",
":",
"raise",
"ValueError",
"(",
"\"{0} is not a directory\"",
".",
"format",
"(",
"directory",
")",
")"... | Loads translation found in a directory.
@type directory: string
@param directory: The directory to search
@type catalogue: MessageCatalogue
@param catalogue: The message catalogue to dump
@raises: ValueError | [
"Loads",
"translation",
"found",
"in",
"a",
"directory",
"."
] | 0aee83f434bd2d1b95767bcd63adb7ac7036c7df | https://github.com/adamziel/python_translate/blob/0aee83f434bd2d1b95767bcd63adb7ac7036c7df/python_translate/glue.py#L37-L61 | train |
adamziel/python_translate | python_translate/glue.py | TranslationWriter.disable_backup | def disable_backup(self):
"""
Disables dumper backup.
"""
for dumper in list(self.dumpers.values()):
dumper.set_backup(False) | python | def disable_backup(self):
"""
Disables dumper backup.
"""
for dumper in list(self.dumpers.values()):
dumper.set_backup(False) | [
"def",
"disable_backup",
"(",
"self",
")",
":",
"for",
"dumper",
"in",
"list",
"(",
"self",
".",
"dumpers",
".",
"values",
"(",
")",
")",
":",
"dumper",
".",
"set_backup",
"(",
"False",
")"
] | Disables dumper backup. | [
"Disables",
"dumper",
"backup",
"."
] | 0aee83f434bd2d1b95767bcd63adb7ac7036c7df | https://github.com/adamziel/python_translate/blob/0aee83f434bd2d1b95767bcd63adb7ac7036c7df/python_translate/glue.py#L85-L90 | train |
adamziel/python_translate | python_translate/glue.py | TranslationWriter.write_translations | def write_translations(self, catalogue, format, options={}):
"""
Writes translation from the catalogue according to the selected format.
@type catalogue: MessageCatalogue
@param catalogue: The message catalogue to dump
@type format: string
@param format: The format to u... | python | def write_translations(self, catalogue, format, options={}):
"""
Writes translation from the catalogue according to the selected format.
@type catalogue: MessageCatalogue
@param catalogue: The message catalogue to dump
@type format: string
@param format: The format to u... | [
"def",
"write_translations",
"(",
"self",
",",
"catalogue",
",",
"format",
",",
"options",
"=",
"{",
"}",
")",
":",
"if",
"format",
"not",
"in",
"self",
".",
"dumpers",
":",
"raise",
"ValueError",
"(",
"'There is no dumper associated with format \"{0}\"'",
".",
... | Writes translation from the catalogue according to the selected format.
@type catalogue: MessageCatalogue
@param catalogue: The message catalogue to dump
@type format: string
@param format: The format to use to dump the messages
@type options: array
@param options: Opt... | [
"Writes",
"translation",
"from",
"the",
"catalogue",
"according",
"to",
"the",
"selected",
"format",
"."
] | 0aee83f434bd2d1b95767bcd63adb7ac7036c7df | https://github.com/adamziel/python_translate/blob/0aee83f434bd2d1b95767bcd63adb7ac7036c7df/python_translate/glue.py#L100-L123 | train |
acutesoftware/virtual-AI-simulator | scripts/recipe_finder.py | main | def main():
"""
script to find a list of recipes for a group of people
with specific likes and dislikes.
Output of script
best ingred = ['Tea', 'Tofu', 'Cheese', 'Cucumber', 'Salad', 'Chocolate']
worst ingred = ['Fish', 'Lamb', 'Pie', 'Asparagus', 'Chicken', 'Turnips']
... | python | def main():
"""
script to find a list of recipes for a group of people
with specific likes and dislikes.
Output of script
best ingred = ['Tea', 'Tofu', 'Cheese', 'Cucumber', 'Salad', 'Chocolate']
worst ingred = ['Fish', 'Lamb', 'Pie', 'Asparagus', 'Chicken', 'Turnips']
... | [
"def",
"main",
"(",
")",
":",
"s",
"=",
"rawdata",
".",
"content",
".",
"DataFiles",
"(",
")",
"all_ingredients",
"=",
"list",
"(",
"s",
".",
"get_collist_by_name",
"(",
"data_files",
"[",
"1",
"]",
"[",
"'file'",
"]",
",",
"data_files",
"[",
"1",
"]... | script to find a list of recipes for a group of people
with specific likes and dislikes.
Output of script
best ingred = ['Tea', 'Tofu', 'Cheese', 'Cucumber', 'Salad', 'Chocolate']
worst ingred = ['Fish', 'Lamb', 'Pie', 'Asparagus', 'Chicken', 'Turnips']
Use this = Tofu
... | [
"script",
"to",
"find",
"a",
"list",
"of",
"recipes",
"for",
"a",
"group",
"of",
"people",
"with",
"specific",
"likes",
"and",
"dislikes",
".",
"Output",
"of",
"script"
] | 57de679a5b1a58c38fefe6aea58af1f3a7e79c58 | https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/scripts/recipe_finder.py#L32-L55 | train |
Xion/taipan | taipan/algorithms.py | batch | def batch(iterable, n, fillvalue=None):
"""Batches the elements of given iterable.
Resulting iterable will yield tuples containing at most ``n`` elements
(might be less if ``fillvalue`` isn't specified).
:param n: Number of items in every batch
:param fillvalue: Value to fill the last batch with. ... | python | def batch(iterable, n, fillvalue=None):
"""Batches the elements of given iterable.
Resulting iterable will yield tuples containing at most ``n`` elements
(might be less if ``fillvalue`` isn't specified).
:param n: Number of items in every batch
:param fillvalue: Value to fill the last batch with. ... | [
"def",
"batch",
"(",
"iterable",
",",
"n",
",",
"fillvalue",
"=",
"None",
")",
":",
"ensure_iterable",
"(",
"iterable",
")",
"if",
"not",
"isinstance",
"(",
"n",
",",
"Integral",
")",
":",
"raise",
"TypeError",
"(",
"\"invalid number of elements in a batch\"",... | Batches the elements of given iterable.
Resulting iterable will yield tuples containing at most ``n`` elements
(might be less if ``fillvalue`` isn't specified).
:param n: Number of items in every batch
:param fillvalue: Value to fill the last batch with. If None, last batch
might... | [
"Batches",
"the",
"elements",
"of",
"given",
"iterable",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/algorithms.py#L24-L58 | train |
Xion/taipan | taipan/algorithms.py | intertwine | def intertwine(*iterables):
"""Constructs an iterable which intertwines given iterables.
The resulting iterable will return an item from first sequence,
then from second, etc. until the last one - and then another item from
first, then from second, etc. - up until all iterables are exhausted.
"""
... | python | def intertwine(*iterables):
"""Constructs an iterable which intertwines given iterables.
The resulting iterable will return an item from first sequence,
then from second, etc. until the last one - and then another item from
first, then from second, etc. - up until all iterables are exhausted.
"""
... | [
"def",
"intertwine",
"(",
"*",
"iterables",
")",
":",
"iterables",
"=",
"tuple",
"(",
"imap",
"(",
"ensure_iterable",
",",
"iterables",
")",
")",
"empty",
"=",
"object",
"(",
")",
"return",
"(",
"item",
"for",
"iterable",
"in",
"izip_longest",
"(",
"*",
... | Constructs an iterable which intertwines given iterables.
The resulting iterable will return an item from first sequence,
then from second, etc. until the last one - and then another item from
first, then from second, etc. - up until all iterables are exhausted. | [
"Constructs",
"an",
"iterable",
"which",
"intertwines",
"given",
"iterables",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/algorithms.py#L88-L100 | train |
Xion/taipan | taipan/algorithms.py | iterate | def iterate(iterator, n=None):
"""Efficiently advances the iterator N times; by default goes to its end.
The actual loop is done "in C" and hence it is faster than equivalent 'for'.
:param n: How much the iterator should be advanced.
If None, it will be advanced until the end.
"""
en... | python | def iterate(iterator, n=None):
"""Efficiently advances the iterator N times; by default goes to its end.
The actual loop is done "in C" and hence it is faster than equivalent 'for'.
:param n: How much the iterator should be advanced.
If None, it will be advanced until the end.
"""
en... | [
"def",
"iterate",
"(",
"iterator",
",",
"n",
"=",
"None",
")",
":",
"ensure_iterable",
"(",
"iterator",
")",
"if",
"n",
"is",
"None",
":",
"deque",
"(",
"iterator",
",",
"maxlen",
"=",
"0",
")",
"else",
":",
"next",
"(",
"islice",
"(",
"iterator",
... | Efficiently advances the iterator N times; by default goes to its end.
The actual loop is done "in C" and hence it is faster than equivalent 'for'.
:param n: How much the iterator should be advanced.
If None, it will be advanced until the end. | [
"Efficiently",
"advances",
"the",
"iterator",
"N",
"times",
";",
"by",
"default",
"goes",
"to",
"its",
"end",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/algorithms.py#L103-L115 | train |
Xion/taipan | taipan/algorithms.py | unique | def unique(iterable, key=None):
"""Removes duplicates from given iterable, using given key as criterion.
:param key: Key function which returns a hashable,
uniquely identifying an object.
:return: Iterable with duplicates removed
"""
ensure_iterable(iterable)
key = hash if key ... | python | def unique(iterable, key=None):
"""Removes duplicates from given iterable, using given key as criterion.
:param key: Key function which returns a hashable,
uniquely identifying an object.
:return: Iterable with duplicates removed
"""
ensure_iterable(iterable)
key = hash if key ... | [
"def",
"unique",
"(",
"iterable",
",",
"key",
"=",
"None",
")",
":",
"ensure_iterable",
"(",
"iterable",
")",
"key",
"=",
"hash",
"if",
"key",
"is",
"None",
"else",
"ensure_callable",
"(",
"key",
")",
"def",
"generator",
"(",
")",
":",
"seen",
"=",
"... | Removes duplicates from given iterable, using given key as criterion.
:param key: Key function which returns a hashable,
uniquely identifying an object.
:return: Iterable with duplicates removed | [
"Removes",
"duplicates",
"from",
"given",
"iterable",
"using",
"given",
"key",
"as",
"criterion",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/algorithms.py#L130-L149 | train |
Xion/taipan | taipan/algorithms.py | breadth_first | def breadth_first(start, expand):
"""Performs a breadth-first search of a graph-like structure.
:param start: Node to start the search from
:param expand: Function taking a node as an argument and returning iterable
of its child nodes
:return: Iterable of nodes in the BFS order
... | python | def breadth_first(start, expand):
"""Performs a breadth-first search of a graph-like structure.
:param start: Node to start the search from
:param expand: Function taking a node as an argument and returning iterable
of its child nodes
:return: Iterable of nodes in the BFS order
... | [
"def",
"breadth_first",
"(",
"start",
",",
"expand",
")",
":",
"ensure_callable",
"(",
"expand",
")",
"def",
"generator",
"(",
")",
":",
"queue",
"=",
"deque",
"(",
"[",
"start",
"]",
")",
"while",
"queue",
":",
"node",
"=",
"queue",
".",
"popleft",
... | Performs a breadth-first search of a graph-like structure.
:param start: Node to start the search from
:param expand: Function taking a node as an argument and returning iterable
of its child nodes
:return: Iterable of nodes in the BFS order
Example::
tree = json.loads(som... | [
"Performs",
"a",
"breadth",
"-",
"first",
"search",
"of",
"a",
"graph",
"-",
"like",
"structure",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/algorithms.py#L154-L178 | train |
Xion/taipan | taipan/algorithms.py | depth_first | def depth_first(start, descend):
"""Performs a depth-first search of a graph-like structure.
:param start: Node to start the search from
:param expand: Function taking a node as an argument and returning iterable
of its child nodes
:return: Iterable of nodes in the DFS order
Ex... | python | def depth_first(start, descend):
"""Performs a depth-first search of a graph-like structure.
:param start: Node to start the search from
:param expand: Function taking a node as an argument and returning iterable
of its child nodes
:return: Iterable of nodes in the DFS order
Ex... | [
"def",
"depth_first",
"(",
"start",
",",
"descend",
")",
":",
"ensure_callable",
"(",
"descend",
")",
"def",
"generator",
"(",
")",
":",
"stack",
"=",
"[",
"start",
"]",
"while",
"stack",
":",
"node",
"=",
"stack",
".",
"pop",
"(",
")",
"yield",
"nod... | Performs a depth-first search of a graph-like structure.
:param start: Node to start the search from
:param expand: Function taking a node as an argument and returning iterable
of its child nodes
:return: Iterable of nodes in the DFS order
Example::
for node in depth_first... | [
"Performs",
"a",
"depth",
"-",
"first",
"search",
"of",
"a",
"graph",
"-",
"like",
"structure",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/algorithms.py#L181-L204 | train |
maximkulkin/hypothesis-regex | hypothesis_regex.py | regex | def regex(regex):
"""Return strategy that generates strings that match given regex.
Regex can be either a string or compiled regex (through `re.compile()`).
You can use regex flags (such as `re.IGNORECASE`, `re.DOTALL` or `re.UNICODE`)
to control generation. Flags can be passed either in compiled rege... | python | def regex(regex):
"""Return strategy that generates strings that match given regex.
Regex can be either a string or compiled regex (through `re.compile()`).
You can use regex flags (such as `re.IGNORECASE`, `re.DOTALL` or `re.UNICODE`)
to control generation. Flags can be passed either in compiled rege... | [
"def",
"regex",
"(",
"regex",
")",
":",
"if",
"not",
"hasattr",
"(",
"regex",
",",
"'pattern'",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"regex",
")",
"pattern",
"=",
"regex",
".",
"pattern",
"flags",
"=",
"regex",
".",
"flags",
"codes",
... | Return strategy that generates strings that match given regex.
Regex can be either a string or compiled regex (through `re.compile()`).
You can use regex flags (such as `re.IGNORECASE`, `re.DOTALL` or `re.UNICODE`)
to control generation. Flags can be passed either in compiled regex (specify
flags in c... | [
"Return",
"strategy",
"that",
"generates",
"strings",
"that",
"match",
"given",
"regex",
"."
] | dd139e97f5ef555dc61e9636bbe96558a5c7801f | https://github.com/maximkulkin/hypothesis-regex/blob/dd139e97f5ef555dc61e9636bbe96558a5c7801f/hypothesis_regex.py#L144-L167 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.