id int32 0 252k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
38,700 | hbldh/flask-pybankid | flask_pybankid.py | FlaskPyBankIDError.create_from_pybankid_exception | def create_from_pybankid_exception(cls, exception):
"""Class method for initiating from a `PyBankID` exception.
:param bankid.exceptions.BankIDError exception:
:return: The wrapped exception.
:rtype: :py:class:`~FlaskPyBankIDError`
"""
return cls(
"{0}: {1}"... | python | def create_from_pybankid_exception(cls, exception):
"""Class method for initiating from a `PyBankID` exception.
:param bankid.exceptions.BankIDError exception:
:return: The wrapped exception.
:rtype: :py:class:`~FlaskPyBankIDError`
"""
return cls(
"{0}: {1}"... | [
"def",
"create_from_pybankid_exception",
"(",
"cls",
",",
"exception",
")",
":",
"return",
"cls",
"(",
"\"{0}: {1}\"",
".",
"format",
"(",
"exception",
".",
"__class__",
".",
"__name__",
",",
"str",
"(",
"exception",
")",
")",
",",
"_exception_class_to_status_co... | Class method for initiating from a `PyBankID` exception.
:param bankid.exceptions.BankIDError exception:
:return: The wrapped exception.
:rtype: :py:class:`~FlaskPyBankIDError` | [
"Class",
"method",
"for",
"initiating",
"from",
"a",
"PyBankID",
"exception",
"."
] | b9af666f587b027391b25d811788d934a12b57e6 | https://github.com/hbldh/flask-pybankid/blob/b9af666f587b027391b25d811788d934a12b57e6/flask_pybankid.py#L192-L203 |
38,701 | hbldh/flask-pybankid | flask_pybankid.py | FlaskPyBankIDError.to_dict | def to_dict(self):
"""Create a dict representation of this exception.
:return: The dictionary representation.
:rtype: dict
"""
rv = dict(self.payload or ())
rv["message"] = self.message
return rv | python | def to_dict(self):
"""Create a dict representation of this exception.
:return: The dictionary representation.
:rtype: dict
"""
rv = dict(self.payload or ())
rv["message"] = self.message
return rv | [
"def",
"to_dict",
"(",
"self",
")",
":",
"rv",
"=",
"dict",
"(",
"self",
".",
"payload",
"or",
"(",
")",
")",
"rv",
"[",
"\"message\"",
"]",
"=",
"self",
".",
"message",
"return",
"rv"
] | Create a dict representation of this exception.
:return: The dictionary representation.
:rtype: dict | [
"Create",
"a",
"dict",
"representation",
"of",
"this",
"exception",
"."
] | b9af666f587b027391b25d811788d934a12b57e6 | https://github.com/hbldh/flask-pybankid/blob/b9af666f587b027391b25d811788d934a12b57e6/flask_pybankid.py#L205-L214 |
38,702 | asobrien/randomOrg | randomorg/_rand_core.py | integers | def integers(num, minimum, maximum, base=10):
# TODO: Ensure numbers within bounds
"""Random integers within specified interval.
The integer generator generates truly random integers in the specified
interval.
Parameters
----------
num : int, bounds=[1, 1E4]
Total number of integ... | python | def integers(num, minimum, maximum, base=10):
# TODO: Ensure numbers within bounds
"""Random integers within specified interval.
The integer generator generates truly random integers in the specified
interval.
Parameters
----------
num : int, bounds=[1, 1E4]
Total number of integ... | [
"def",
"integers",
"(",
"num",
",",
"minimum",
",",
"maximum",
",",
"base",
"=",
"10",
")",
":",
"# TODO: Ensure numbers within bounds",
"function",
"=",
"'integers'",
"num",
",",
"minimum",
",",
"maximum",
"=",
"list",
"(",
"map",
"(",
"int",
",",
"[",
... | Random integers within specified interval.
The integer generator generates truly random integers in the specified
interval.
Parameters
----------
num : int, bounds=[1, 1E4]
Total number of integers in returned array.
minimum : int, bounds=[-1E9, 1E9]
Minimum value (incl... | [
"Random",
"integers",
"within",
"specified",
"interval",
"."
] | 76c3f167c5689992d32cd1f827816254158160f7 | https://github.com/asobrien/randomOrg/blob/76c3f167c5689992d32cd1f827816254158160f7/randomorg/_rand_core.py#L25-L95 |
38,703 | asobrien/randomOrg | randomorg/_rand_core.py | sequence | def sequence(minimum, maximum):
"""Randomize a sequence of integers."""
function = 'sequences'
opts = {'min': minimum,
'max': maximum,
'col': 1,
'format': 'plain',
'rnd': 'new'}
deal = get_http(RANDOM_URL, function, opts)
deal_arr = str_to_arr(deal)
... | python | def sequence(minimum, maximum):
"""Randomize a sequence of integers."""
function = 'sequences'
opts = {'min': minimum,
'max': maximum,
'col': 1,
'format': 'plain',
'rnd': 'new'}
deal = get_http(RANDOM_URL, function, opts)
deal_arr = str_to_arr(deal)
... | [
"def",
"sequence",
"(",
"minimum",
",",
"maximum",
")",
":",
"function",
"=",
"'sequences'",
"opts",
"=",
"{",
"'min'",
":",
"minimum",
",",
"'max'",
":",
"maximum",
",",
"'col'",
":",
"1",
",",
"'format'",
":",
"'plain'",
",",
"'rnd'",
":",
"'new'",
... | Randomize a sequence of integers. | [
"Randomize",
"a",
"sequence",
"of",
"integers",
"."
] | 76c3f167c5689992d32cd1f827816254158160f7 | https://github.com/asobrien/randomOrg/blob/76c3f167c5689992d32cd1f827816254158160f7/randomorg/_rand_core.py#L98-L108 |
38,704 | asobrien/randomOrg | randomorg/_rand_core.py | string | def string(num, length, digits=False, upper=True, lower=True, unique=False):
"""Random strings."""
function = 'strings'
# Convert arguments to random.org style
# for a discussion on the method see: http://bit.ly/TKGkOF
digits = convert(digits)
upper = convert(upper)
lower = convert(lower)
... | python | def string(num, length, digits=False, upper=True, lower=True, unique=False):
"""Random strings."""
function = 'strings'
# Convert arguments to random.org style
# for a discussion on the method see: http://bit.ly/TKGkOF
digits = convert(digits)
upper = convert(upper)
lower = convert(lower)
... | [
"def",
"string",
"(",
"num",
",",
"length",
",",
"digits",
"=",
"False",
",",
"upper",
"=",
"True",
",",
"lower",
"=",
"True",
",",
"unique",
"=",
"False",
")",
":",
"function",
"=",
"'strings'",
"# Convert arguments to random.org style",
"# for a discussion o... | Random strings. | [
"Random",
"strings",
"."
] | 76c3f167c5689992d32cd1f827816254158160f7 | https://github.com/asobrien/randomOrg/blob/76c3f167c5689992d32cd1f827816254158160f7/randomorg/_rand_core.py#L111-L131 |
38,705 | asobrien/randomOrg | randomorg/_rand_core.py | quota | def quota(ip=None):
"""Check your quota."""
# TODO: Add arbitrary user defined IP check
url = 'http://www.random.org/quota/?format=plain'
data = urlopen(url)
credit = int(data.read().strip())
if data.code == 200:
return credit
else:
return "ERROR: Server responded with code %... | python | def quota(ip=None):
"""Check your quota."""
# TODO: Add arbitrary user defined IP check
url = 'http://www.random.org/quota/?format=plain'
data = urlopen(url)
credit = int(data.read().strip())
if data.code == 200:
return credit
else:
return "ERROR: Server responded with code %... | [
"def",
"quota",
"(",
"ip",
"=",
"None",
")",
":",
"# TODO: Add arbitrary user defined IP check",
"url",
"=",
"'http://www.random.org/quota/?format=plain'",
"data",
"=",
"urlopen",
"(",
"url",
")",
"credit",
"=",
"int",
"(",
"data",
".",
"read",
"(",
")",
".",
... | Check your quota. | [
"Check",
"your",
"quota",
"."
] | 76c3f167c5689992d32cd1f827816254158160f7 | https://github.com/asobrien/randomOrg/blob/76c3f167c5689992d32cd1f827816254158160f7/randomorg/_rand_core.py#L134-L143 |
38,706 | asobrien/randomOrg | randomorg/_rand_core.py | get_http | def get_http(base_url, function, opts):
"""HTTP request generator."""
url = (os.path.join(base_url, function) + '/?' + urlencode(opts))
data = urlopen(url)
if data.code != 200:
raise ValueError("Random.rg returned server code: " + str(data.code))
return data.read() | python | def get_http(base_url, function, opts):
"""HTTP request generator."""
url = (os.path.join(base_url, function) + '/?' + urlencode(opts))
data = urlopen(url)
if data.code != 200:
raise ValueError("Random.rg returned server code: " + str(data.code))
return data.read() | [
"def",
"get_http",
"(",
"base_url",
",",
"function",
",",
"opts",
")",
":",
"url",
"=",
"(",
"os",
".",
"path",
".",
"join",
"(",
"base_url",
",",
"function",
")",
"+",
"'/?'",
"+",
"urlencode",
"(",
"opts",
")",
")",
"data",
"=",
"urlopen",
"(",
... | HTTP request generator. | [
"HTTP",
"request",
"generator",
"."
] | 76c3f167c5689992d32cd1f827816254158160f7 | https://github.com/asobrien/randomOrg/blob/76c3f167c5689992d32cd1f827816254158160f7/randomorg/_rand_core.py#L148-L155 |
38,707 | Equitable/trump | setup.py | read | def read(*p):
"""Build a file path from paths and return the contents."""
with open(os.path.join(*p), 'r') as fi:
return fi.read() | python | def read(*p):
"""Build a file path from paths and return the contents."""
with open(os.path.join(*p), 'r') as fi:
return fi.read() | [
"def",
"read",
"(",
"*",
"p",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"*",
"p",
")",
",",
"'r'",
")",
"as",
"fi",
":",
"return",
"fi",
".",
"read",
"(",
")"
] | Build a file path from paths and return the contents. | [
"Build",
"a",
"file",
"path",
"from",
"paths",
"and",
"return",
"the",
"contents",
"."
] | a2802692bc642fa32096374159eea7ceca2947b4 | https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/setup.py#L42-L45 |
38,708 | sporsh/carnifex | carnifex/inductor.py | ProcessInductor.execute | def execute(self, processProtocol, command, env={},
path=None, uid=None, gid=None, usePTY=0, childFDs=None):
"""Form a command and start a process in the desired environment.
"""
raise NotImplementedError() | python | def execute(self, processProtocol, command, env={},
path=None, uid=None, gid=None, usePTY=0, childFDs=None):
"""Form a command and start a process in the desired environment.
"""
raise NotImplementedError() | [
"def",
"execute",
"(",
"self",
",",
"processProtocol",
",",
"command",
",",
"env",
"=",
"{",
"}",
",",
"path",
"=",
"None",
",",
"uid",
"=",
"None",
",",
"gid",
"=",
"None",
",",
"usePTY",
"=",
"0",
",",
"childFDs",
"=",
"None",
")",
":",
"raise"... | Form a command and start a process in the desired environment. | [
"Form",
"a",
"command",
"and",
"start",
"a",
"process",
"in",
"the",
"desired",
"environment",
"."
] | 82dd3bd2bc134dfb69a78f43171e227f2127060b | https://github.com/sporsh/carnifex/blob/82dd3bd2bc134dfb69a78f43171e227f2127060b/carnifex/inductor.py#L15-L19 |
38,709 | sporsh/carnifex | carnifex/inductor.py | ProcessInductor.run | def run(self, command, env={}, path=None,
uid=None, gid=None, usePTY=0, childFDs=None):
"""Execute a command and return the results of the completed run.
"""
deferred = defer.Deferred()
processProtocol = _SummaryProcessProtocol(deferred)
d = defer.maybeDeferred(self.e... | python | def run(self, command, env={}, path=None,
uid=None, gid=None, usePTY=0, childFDs=None):
"""Execute a command and return the results of the completed run.
"""
deferred = defer.Deferred()
processProtocol = _SummaryProcessProtocol(deferred)
d = defer.maybeDeferred(self.e... | [
"def",
"run",
"(",
"self",
",",
"command",
",",
"env",
"=",
"{",
"}",
",",
"path",
"=",
"None",
",",
"uid",
"=",
"None",
",",
"gid",
"=",
"None",
",",
"usePTY",
"=",
"0",
",",
"childFDs",
"=",
"None",
")",
":",
"deferred",
"=",
"defer",
".",
... | Execute a command and return the results of the completed run. | [
"Execute",
"a",
"command",
"and",
"return",
"the",
"results",
"of",
"the",
"completed",
"run",
"."
] | 82dd3bd2bc134dfb69a78f43171e227f2127060b | https://github.com/sporsh/carnifex/blob/82dd3bd2bc134dfb69a78f43171e227f2127060b/carnifex/inductor.py#L21-L30 |
38,710 | sporsh/carnifex | carnifex/inductor.py | ProcessInductor.getOutput | def getOutput(self, command, env={}, path=None,
uid=None, gid=None, usePTY=0, childFDs=None):
"""Execute a command and get the output of the finished process.
"""
deferred = defer.Deferred()
processProtocol = _SummaryProcessProtocol(deferred)
self.execute(proces... | python | def getOutput(self, command, env={}, path=None,
uid=None, gid=None, usePTY=0, childFDs=None):
"""Execute a command and get the output of the finished process.
"""
deferred = defer.Deferred()
processProtocol = _SummaryProcessProtocol(deferred)
self.execute(proces... | [
"def",
"getOutput",
"(",
"self",
",",
"command",
",",
"env",
"=",
"{",
"}",
",",
"path",
"=",
"None",
",",
"uid",
"=",
"None",
",",
"gid",
"=",
"None",
",",
"usePTY",
"=",
"0",
",",
"childFDs",
"=",
"None",
")",
":",
"deferred",
"=",
"defer",
"... | Execute a command and get the output of the finished process. | [
"Execute",
"a",
"command",
"and",
"get",
"the",
"output",
"of",
"the",
"finished",
"process",
"."
] | 82dd3bd2bc134dfb69a78f43171e227f2127060b | https://github.com/sporsh/carnifex/blob/82dd3bd2bc134dfb69a78f43171e227f2127060b/carnifex/inductor.py#L32-L44 |
38,711 | sporsh/carnifex | carnifex/inductor.py | ProcessInductor.getExitCode | def getExitCode(self, command, env={}, path=None, uid=None, gid=None,
usePTY=0, childFDs=None):
"""Execute a command and get the return code of the finished process.
"""
deferred = defer.Deferred()
processProtocol = _SummaryProcessProtocol(deferred)
self.execu... | python | def getExitCode(self, command, env={}, path=None, uid=None, gid=None,
usePTY=0, childFDs=None):
"""Execute a command and get the return code of the finished process.
"""
deferred = defer.Deferred()
processProtocol = _SummaryProcessProtocol(deferred)
self.execu... | [
"def",
"getExitCode",
"(",
"self",
",",
"command",
",",
"env",
"=",
"{",
"}",
",",
"path",
"=",
"None",
",",
"uid",
"=",
"None",
",",
"gid",
"=",
"None",
",",
"usePTY",
"=",
"0",
",",
"childFDs",
"=",
"None",
")",
":",
"deferred",
"=",
"defer",
... | Execute a command and get the return code of the finished process. | [
"Execute",
"a",
"command",
"and",
"get",
"the",
"return",
"code",
"of",
"the",
"finished",
"process",
"."
] | 82dd3bd2bc134dfb69a78f43171e227f2127060b | https://github.com/sporsh/carnifex/blob/82dd3bd2bc134dfb69a78f43171e227f2127060b/carnifex/inductor.py#L46-L58 |
38,712 | thomasantony/simplepipe | simplepipe.py | validate_task | def validate_task(original_task):
"""
Validates task and adds default values for missing options using the
following steps.
1. If there is no input list specified or if it is None, the input spec is
assumed to be ['*'].
2. If there are not outputs specified, or if the output spec is None or... | python | def validate_task(original_task):
"""
Validates task and adds default values for missing options using the
following steps.
1. If there is no input list specified or if it is None, the input spec is
assumed to be ['*'].
2. If there are not outputs specified, or if the output spec is None or... | [
"def",
"validate_task",
"(",
"original_task",
")",
":",
"task",
"=",
"original_task",
".",
"_asdict",
"(",
")",
"# Default values for inputs and outputs",
"if",
"'inputs'",
"not",
"in",
"task",
"or",
"task",
"[",
"'inputs'",
"]",
"is",
"None",
":",
"task",
"["... | Validates task and adds default values for missing options using the
following steps.
1. If there is no input list specified or if it is None, the input spec is
assumed to be ['*'].
2. If there are not outputs specified, or if the output spec is None or an
empty list, the output spec is assu... | [
"Validates",
"task",
"and",
"adds",
"default",
"values",
"for",
"missing",
"options",
"using",
"the",
"following",
"steps",
"."
] | c79d5f6ab27067e16d3d5d23364be5dd12448c04 | https://github.com/thomasantony/simplepipe/blob/c79d5f6ab27067e16d3d5d23364be5dd12448c04/simplepipe.py#L13-L72 |
38,713 | thomasantony/simplepipe | simplepipe.py | run_task | def run_task(task, workspace):
"""
Runs the task and updates the workspace with results.
Parameters
----------
task - dict
Task Description
Examples:
{'task': task_func, 'inputs': ['a', 'b'], 'outputs': 'c'}
{'task': task_func, 'inputs': '*', 'outputs': '*'}
{'task': task_f... | python | def run_task(task, workspace):
"""
Runs the task and updates the workspace with results.
Parameters
----------
task - dict
Task Description
Examples:
{'task': task_func, 'inputs': ['a', 'b'], 'outputs': 'c'}
{'task': task_func, 'inputs': '*', 'outputs': '*'}
{'task': task_f... | [
"def",
"run_task",
"(",
"task",
",",
"workspace",
")",
":",
"data",
"=",
"copy",
".",
"copy",
"(",
"workspace",
")",
"task",
"=",
"validate_task",
"(",
"task",
")",
"# Prepare input to task",
"inputs",
"=",
"[",
"input_parser",
"(",
"key",
",",
"data",
"... | Runs the task and updates the workspace with results.
Parameters
----------
task - dict
Task Description
Examples:
{'task': task_func, 'inputs': ['a', 'b'], 'outputs': 'c'}
{'task': task_func, 'inputs': '*', 'outputs': '*'}
{'task': task_func, 'inputs': ['*','a'], 'outputs': 'b'}
... | [
"Runs",
"the",
"task",
"and",
"updates",
"the",
"workspace",
"with",
"results",
"."
] | c79d5f6ab27067e16d3d5d23364be5dd12448c04 | https://github.com/thomasantony/simplepipe/blob/c79d5f6ab27067e16d3d5d23364be5dd12448c04/simplepipe.py#L83-L119 |
38,714 | thomasantony/simplepipe | simplepipe.py | run_hook | def run_hook(name, workspace, hooks):
"""Runs all hooks added under the give name.
Parameters
----------
name - str
Name of the hook to invoke
workspace - dict
Workspace that the hook functions operate on
hooks - dict of lists
Mapping with hook names and callback funct... | python | def run_hook(name, workspace, hooks):
"""Runs all hooks added under the give name.
Parameters
----------
name - str
Name of the hook to invoke
workspace - dict
Workspace that the hook functions operate on
hooks - dict of lists
Mapping with hook names and callback funct... | [
"def",
"run_hook",
"(",
"name",
",",
"workspace",
",",
"hooks",
")",
":",
"data",
"=",
"copy",
".",
"copy",
"(",
"workspace",
")",
"for",
"hook_listener",
"in",
"hooks",
".",
"get",
"(",
"name",
",",
"[",
"]",
")",
":",
"# Hook functions may mutate the d... | Runs all hooks added under the give name.
Parameters
----------
name - str
Name of the hook to invoke
workspace - dict
Workspace that the hook functions operate on
hooks - dict of lists
Mapping with hook names and callback functions | [
"Runs",
"all",
"hooks",
"added",
"under",
"the",
"give",
"name",
"."
] | c79d5f6ab27067e16d3d5d23364be5dd12448c04 | https://github.com/thomasantony/simplepipe/blob/c79d5f6ab27067e16d3d5d23364be5dd12448c04/simplepipe.py#L122-L141 |
38,715 | thomasantony/simplepipe | simplepipe.py | Workflow.add_task | def add_task(self, fn, inputs=None, outputs=None):
"""
Adds a task to the workflow.
Returns self to facilitate chaining method calls
"""
# self.tasks.append({'task': task, 'inputs': inputs, 'outputs': outputs})
self.tasks.append(Task(fn, inputs, outputs))
return ... | python | def add_task(self, fn, inputs=None, outputs=None):
"""
Adds a task to the workflow.
Returns self to facilitate chaining method calls
"""
# self.tasks.append({'task': task, 'inputs': inputs, 'outputs': outputs})
self.tasks.append(Task(fn, inputs, outputs))
return ... | [
"def",
"add_task",
"(",
"self",
",",
"fn",
",",
"inputs",
"=",
"None",
",",
"outputs",
"=",
"None",
")",
":",
"# self.tasks.append({'task': task, 'inputs': inputs, 'outputs': outputs})",
"self",
".",
"tasks",
".",
"append",
"(",
"Task",
"(",
"fn",
",",
"inputs",... | Adds a task to the workflow.
Returns self to facilitate chaining method calls | [
"Adds",
"a",
"task",
"to",
"the",
"workflow",
"."
] | c79d5f6ab27067e16d3d5d23364be5dd12448c04 | https://github.com/thomasantony/simplepipe/blob/c79d5f6ab27067e16d3d5d23364be5dd12448c04/simplepipe.py#L158-L166 |
38,716 | thomasantony/simplepipe | simplepipe.py | Workflow.add_hook | def add_hook(self, name, function):
"""
Adds a function to be called for hook of a given name.
The function gets entire workspace as input and
does not return anything.
Example:
def hook_fcn(workspace):
pass
"""
if not callable(function):
... | python | def add_hook(self, name, function):
"""
Adds a function to be called for hook of a given name.
The function gets entire workspace as input and
does not return anything.
Example:
def hook_fcn(workspace):
pass
"""
if not callable(function):
... | [
"def",
"add_hook",
"(",
"self",
",",
"name",
",",
"function",
")",
":",
"if",
"not",
"callable",
"(",
"function",
")",
":",
"return",
"ValueError",
"(",
"'Hook function should be callable'",
")",
"if",
"name",
"not",
"in",
"self",
".",
"hooks",
":",
"self"... | Adds a function to be called for hook of a given name.
The function gets entire workspace as input and
does not return anything.
Example:
def hook_fcn(workspace):
pass | [
"Adds",
"a",
"function",
"to",
"be",
"called",
"for",
"hook",
"of",
"a",
"given",
"name",
"."
] | c79d5f6ab27067e16d3d5d23364be5dd12448c04 | https://github.com/thomasantony/simplepipe/blob/c79d5f6ab27067e16d3d5d23364be5dd12448c04/simplepipe.py#L179-L195 |
38,717 | foremast/gogo-utils | src/gogoutils/generator.py | Generator.dns | def dns(self):
"""DNS details."""
dns = {
'elb': self.dns_elb(),
'elb_region': self.dns_elb_region(),
'global': self.dns_global(),
'region': self.dns_region(),
'instance': self.dns_instance(),
}
return dns | python | def dns(self):
"""DNS details."""
dns = {
'elb': self.dns_elb(),
'elb_region': self.dns_elb_region(),
'global': self.dns_global(),
'region': self.dns_region(),
'instance': self.dns_instance(),
}
return dns | [
"def",
"dns",
"(",
"self",
")",
":",
"dns",
"=",
"{",
"'elb'",
":",
"self",
".",
"dns_elb",
"(",
")",
",",
"'elb_region'",
":",
"self",
".",
"dns_elb_region",
"(",
")",
",",
"'global'",
":",
"self",
".",
"dns_global",
"(",
")",
",",
"'region'",
":"... | DNS details. | [
"DNS",
"details",
"."
] | 3909c2d26e49baa8ad68e6be40977d4370d7c1ca | https://github.com/foremast/gogo-utils/blob/3909c2d26e49baa8ad68e6be40977d4370d7c1ca/src/gogoutils/generator.py#L111-L121 |
38,718 | foremast/gogo-utils | src/gogoutils/generator.py | Generator.s3_app_bucket | def s3_app_bucket(self, include_region=False):
"""Generate s3 application bucket name.
Args:
include_region (bool): Include region in the name generation.
"""
if include_region:
s3_app_bucket = self.format['s3_app_region_bucket'].format(**self.data)
else:... | python | def s3_app_bucket(self, include_region=False):
"""Generate s3 application bucket name.
Args:
include_region (bool): Include region in the name generation.
"""
if include_region:
s3_app_bucket = self.format['s3_app_region_bucket'].format(**self.data)
else:... | [
"def",
"s3_app_bucket",
"(",
"self",
",",
"include_region",
"=",
"False",
")",
":",
"if",
"include_region",
":",
"s3_app_bucket",
"=",
"self",
".",
"format",
"[",
"'s3_app_region_bucket'",
"]",
".",
"format",
"(",
"*",
"*",
"self",
".",
"data",
")",
"else"... | Generate s3 application bucket name.
Args:
include_region (bool): Include region in the name generation. | [
"Generate",
"s3",
"application",
"bucket",
"name",
"."
] | 3909c2d26e49baa8ad68e6be40977d4370d7c1ca | https://github.com/foremast/gogo-utils/blob/3909c2d26e49baa8ad68e6be40977d4370d7c1ca/src/gogoutils/generator.py#L123-L133 |
38,719 | foremast/gogo-utils | src/gogoutils/generator.py | Generator.shared_s3_app_bucket | def shared_s3_app_bucket(self, include_region=False):
"""Generate shared s3 application bucket name.
Args:
include_region (bool): Include region in the name generation.
"""
if include_region:
shared_s3_app_bucket = self.format['shared_s3_app_region_bucket'].forma... | python | def shared_s3_app_bucket(self, include_region=False):
"""Generate shared s3 application bucket name.
Args:
include_region (bool): Include region in the name generation.
"""
if include_region:
shared_s3_app_bucket = self.format['shared_s3_app_region_bucket'].forma... | [
"def",
"shared_s3_app_bucket",
"(",
"self",
",",
"include_region",
"=",
"False",
")",
":",
"if",
"include_region",
":",
"shared_s3_app_bucket",
"=",
"self",
".",
"format",
"[",
"'shared_s3_app_region_bucket'",
"]",
".",
"format",
"(",
"*",
"*",
"self",
".",
"d... | Generate shared s3 application bucket name.
Args:
include_region (bool): Include region in the name generation. | [
"Generate",
"shared",
"s3",
"application",
"bucket",
"name",
"."
] | 3909c2d26e49baa8ad68e6be40977d4370d7c1ca | https://github.com/foremast/gogo-utils/blob/3909c2d26e49baa8ad68e6be40977d4370d7c1ca/src/gogoutils/generator.py#L135-L145 |
38,720 | foremast/gogo-utils | src/gogoutils/generator.py | Generator.iam | def iam(self):
"""Generate iam details."""
iam = {
'group': self.format['iam_group'].format(**self.data),
'lambda_role': self.format['iam_lambda_role'].format(**self.data),
'policy': self.format['iam_policy'].format(**self.data),
'profile': self.format['ia... | python | def iam(self):
"""Generate iam details."""
iam = {
'group': self.format['iam_group'].format(**self.data),
'lambda_role': self.format['iam_lambda_role'].format(**self.data),
'policy': self.format['iam_policy'].format(**self.data),
'profile': self.format['ia... | [
"def",
"iam",
"(",
"self",
")",
":",
"iam",
"=",
"{",
"'group'",
":",
"self",
".",
"format",
"[",
"'iam_group'",
"]",
".",
"format",
"(",
"*",
"*",
"self",
".",
"data",
")",
",",
"'lambda_role'",
":",
"self",
".",
"format",
"[",
"'iam_lambda_role'",
... | Generate iam details. | [
"Generate",
"iam",
"details",
"."
] | 3909c2d26e49baa8ad68e6be40977d4370d7c1ca | https://github.com/foremast/gogo-utils/blob/3909c2d26e49baa8ad68e6be40977d4370d7c1ca/src/gogoutils/generator.py#L147-L159 |
38,721 | foremast/gogo-utils | src/gogoutils/generator.py | Generator.archaius | def archaius(self):
"""Generate archaius bucket path."""
bucket = self.format['s3_bucket'].format(**self.data)
path = self.format['s3_bucket_path'].format(**self.data)
archaius_name = self.format['s3_archaius_name'].format(**self.data)
archaius = {'s3': archaius_name, 'bucket': b... | python | def archaius(self):
"""Generate archaius bucket path."""
bucket = self.format['s3_bucket'].format(**self.data)
path = self.format['s3_bucket_path'].format(**self.data)
archaius_name = self.format['s3_archaius_name'].format(**self.data)
archaius = {'s3': archaius_name, 'bucket': b... | [
"def",
"archaius",
"(",
"self",
")",
":",
"bucket",
"=",
"self",
".",
"format",
"[",
"'s3_bucket'",
"]",
".",
"format",
"(",
"*",
"*",
"self",
".",
"data",
")",
"path",
"=",
"self",
".",
"format",
"[",
"'s3_bucket_path'",
"]",
".",
"format",
"(",
"... | Generate archaius bucket path. | [
"Generate",
"archaius",
"bucket",
"path",
"."
] | 3909c2d26e49baa8ad68e6be40977d4370d7c1ca | https://github.com/foremast/gogo-utils/blob/3909c2d26e49baa8ad68e6be40977d4370d7c1ca/src/gogoutils/generator.py#L161-L168 |
38,722 | foremast/gogo-utils | src/gogoutils/generator.py | Generator.jenkins | def jenkins(self):
"""Generate jenkins job details."""
job_name = self.format['jenkins_job_name'].format(**self.data)
job = {'name': job_name}
return job | python | def jenkins(self):
"""Generate jenkins job details."""
job_name = self.format['jenkins_job_name'].format(**self.data)
job = {'name': job_name}
return job | [
"def",
"jenkins",
"(",
"self",
")",
":",
"job_name",
"=",
"self",
".",
"format",
"[",
"'jenkins_job_name'",
"]",
".",
"format",
"(",
"*",
"*",
"self",
".",
"data",
")",
"job",
"=",
"{",
"'name'",
":",
"job_name",
"}",
"return",
"job"
] | Generate jenkins job details. | [
"Generate",
"jenkins",
"job",
"details",
"."
] | 3909c2d26e49baa8ad68e6be40977d4370d7c1ca | https://github.com/foremast/gogo-utils/blob/3909c2d26e49baa8ad68e6be40977d4370d7c1ca/src/gogoutils/generator.py#L170-L175 |
38,723 | foremast/gogo-utils | src/gogoutils/generator.py | Generator.gitlab | def gitlab(self):
"""Generate gitlab details."""
main_name = self.format['git_repo'].format(**self.data)
qe_name = self.format['git_repo_qe'].format(**self.data)
config_name = self.format['git_repo_configs'].format(**self.data)
git = {
'config': config_name,
... | python | def gitlab(self):
"""Generate gitlab details."""
main_name = self.format['git_repo'].format(**self.data)
qe_name = self.format['git_repo_qe'].format(**self.data)
config_name = self.format['git_repo_configs'].format(**self.data)
git = {
'config': config_name,
... | [
"def",
"gitlab",
"(",
"self",
")",
":",
"main_name",
"=",
"self",
".",
"format",
"[",
"'git_repo'",
"]",
".",
"format",
"(",
"*",
"*",
"self",
".",
"data",
")",
"qe_name",
"=",
"self",
".",
"format",
"[",
"'git_repo_qe'",
"]",
".",
"format",
"(",
"... | Generate gitlab details. | [
"Generate",
"gitlab",
"details",
"."
] | 3909c2d26e49baa8ad68e6be40977d4370d7c1ca | https://github.com/foremast/gogo-utils/blob/3909c2d26e49baa8ad68e6be40977d4370d7c1ca/src/gogoutils/generator.py#L177-L189 |
38,724 | mozilla-releng/mozilla-version | mozilla_version/parser.py | get_value_matched_by_regex | def get_value_matched_by_regex(field_name, regex_matches, string):
"""Ensure value stored in regex group exists."""
try:
value = regex_matches.group(field_name)
if value is not None:
return value
except IndexError:
pass
raise MissingFieldError(string, field_name) | python | def get_value_matched_by_regex(field_name, regex_matches, string):
"""Ensure value stored in regex group exists."""
try:
value = regex_matches.group(field_name)
if value is not None:
return value
except IndexError:
pass
raise MissingFieldError(string, field_name) | [
"def",
"get_value_matched_by_regex",
"(",
"field_name",
",",
"regex_matches",
",",
"string",
")",
":",
"try",
":",
"value",
"=",
"regex_matches",
".",
"group",
"(",
"field_name",
")",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"value",
"except",
"Ind... | Ensure value stored in regex group exists. | [
"Ensure",
"value",
"stored",
"in",
"regex",
"group",
"exists",
"."
] | e5400f31f7001bd48fb6e17626905147dd4c17d7 | https://github.com/mozilla-releng/mozilla-version/blob/e5400f31f7001bd48fb6e17626905147dd4c17d7/mozilla_version/parser.py#L6-L15 |
38,725 | mozilla-releng/mozilla-version | mozilla_version/parser.py | positive_int | def positive_int(val):
"""Parse `val` into a positive integer."""
if isinstance(val, float):
raise ValueError('"{}" must not be a float'.format(val))
val = int(val)
if val >= 0:
return val
raise ValueError('"{}" must be positive'.format(val)) | python | def positive_int(val):
"""Parse `val` into a positive integer."""
if isinstance(val, float):
raise ValueError('"{}" must not be a float'.format(val))
val = int(val)
if val >= 0:
return val
raise ValueError('"{}" must be positive'.format(val)) | [
"def",
"positive_int",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"float",
")",
":",
"raise",
"ValueError",
"(",
"'\"{}\" must not be a float'",
".",
"format",
"(",
"val",
")",
")",
"val",
"=",
"int",
"(",
"val",
")",
"if",
"val",
">=",... | Parse `val` into a positive integer. | [
"Parse",
"val",
"into",
"a",
"positive",
"integer",
"."
] | e5400f31f7001bd48fb6e17626905147dd4c17d7 | https://github.com/mozilla-releng/mozilla-version/blob/e5400f31f7001bd48fb6e17626905147dd4c17d7/mozilla_version/parser.py#L26-L33 |
38,726 | mozilla-releng/mozilla-version | mozilla_version/parser.py | strictly_positive_int_or_none | def strictly_positive_int_or_none(val):
"""Parse `val` into either `None` or a strictly positive integer."""
val = positive_int_or_none(val)
if val is None or val > 0:
return val
raise ValueError('"{}" must be strictly positive'.format(val)) | python | def strictly_positive_int_or_none(val):
"""Parse `val` into either `None` or a strictly positive integer."""
val = positive_int_or_none(val)
if val is None or val > 0:
return val
raise ValueError('"{}" must be strictly positive'.format(val)) | [
"def",
"strictly_positive_int_or_none",
"(",
"val",
")",
":",
"val",
"=",
"positive_int_or_none",
"(",
"val",
")",
"if",
"val",
"is",
"None",
"or",
"val",
">",
"0",
":",
"return",
"val",
"raise",
"ValueError",
"(",
"'\"{}\" must be strictly positive'",
".",
"f... | Parse `val` into either `None` or a strictly positive integer. | [
"Parse",
"val",
"into",
"either",
"None",
"or",
"a",
"strictly",
"positive",
"integer",
"."
] | e5400f31f7001bd48fb6e17626905147dd4c17d7 | https://github.com/mozilla-releng/mozilla-version/blob/e5400f31f7001bd48fb6e17626905147dd4c17d7/mozilla_version/parser.py#L43-L48 |
38,727 | hollenstein/maspy | maspy/ontology.py | _attributeLinesToDict | def _attributeLinesToDict(attributeLines):
"""Converts a list of obo 'Term' lines to a dictionary.
:param attributeLines: a list of obo 'Term' lines. Each line contains a key
and a value part which are separated by a ':'.
:return: a dictionary containing the attributes of an obo 'Term' entry.
... | python | def _attributeLinesToDict(attributeLines):
"""Converts a list of obo 'Term' lines to a dictionary.
:param attributeLines: a list of obo 'Term' lines. Each line contains a key
and a value part which are separated by a ':'.
:return: a dictionary containing the attributes of an obo 'Term' entry.
... | [
"def",
"_attributeLinesToDict",
"(",
"attributeLines",
")",
":",
"attributes",
"=",
"dict",
"(",
")",
"for",
"line",
"in",
"attributeLines",
":",
"attributeId",
",",
"attributeValue",
"=",
"line",
".",
"split",
"(",
"':'",
",",
"1",
")",
"attributes",
"[",
... | Converts a list of obo 'Term' lines to a dictionary.
:param attributeLines: a list of obo 'Term' lines. Each line contains a key
and a value part which are separated by a ':'.
:return: a dictionary containing the attributes of an obo 'Term' entry.
NOTE: Some attributes can occur multiple times in... | [
"Converts",
"a",
"list",
"of",
"obo",
"Term",
"lines",
"to",
"a",
"dictionary",
"."
] | f15fcfd24df306d8420540460d902aa3073ec133 | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/ontology.py#L82-L98 |
38,728 | hollenstein/maspy | maspy/ontology.py | _termIsObsolete | def _termIsObsolete(oboTerm):
"""Determine wheter an obo 'Term' entry is marked as obsolete.
:param oboTerm: a dictionary as return by
:func:`maspy.ontology._attributeLinesToDict()`
:return: bool
"""
isObsolete = False
if u'is_obsolete' in oboTerm:
if oboTerm[u'is_obsolete'].lo... | python | def _termIsObsolete(oboTerm):
"""Determine wheter an obo 'Term' entry is marked as obsolete.
:param oboTerm: a dictionary as return by
:func:`maspy.ontology._attributeLinesToDict()`
:return: bool
"""
isObsolete = False
if u'is_obsolete' in oboTerm:
if oboTerm[u'is_obsolete'].lo... | [
"def",
"_termIsObsolete",
"(",
"oboTerm",
")",
":",
"isObsolete",
"=",
"False",
"if",
"u'is_obsolete'",
"in",
"oboTerm",
":",
"if",
"oboTerm",
"[",
"u'is_obsolete'",
"]",
".",
"lower",
"(",
")",
"==",
"u'true'",
":",
"isObsolete",
"=",
"True",
"return",
"i... | Determine wheter an obo 'Term' entry is marked as obsolete.
:param oboTerm: a dictionary as return by
:func:`maspy.ontology._attributeLinesToDict()`
:return: bool | [
"Determine",
"wheter",
"an",
"obo",
"Term",
"entry",
"is",
"marked",
"as",
"obsolete",
"."
] | f15fcfd24df306d8420540460d902aa3073ec133 | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/ontology.py#L101-L113 |
38,729 | invinst/ResponseBot | responsebot/utils/handler_utils.py | discover_handler_classes | def discover_handler_classes(handlers_package):
"""
Looks for handler classes within handler path module.
Currently it's not looking deep into nested module.
:param handlers_package: module path to handlers
:type handlers_package: string
:return: list of handler classes
"""
if handlers... | python | def discover_handler_classes(handlers_package):
"""
Looks for handler classes within handler path module.
Currently it's not looking deep into nested module.
:param handlers_package: module path to handlers
:type handlers_package: string
:return: list of handler classes
"""
if handlers... | [
"def",
"discover_handler_classes",
"(",
"handlers_package",
")",
":",
"if",
"handlers_package",
"is",
"None",
":",
"return",
"# Add working directory into PYTHONPATH to import developer packages",
"sys",
".",
"path",
".",
"insert",
"(",
"0",
",",
"os",
".",
"getcwd",
... | Looks for handler classes within handler path module.
Currently it's not looking deep into nested module.
:param handlers_package: module path to handlers
:type handlers_package: string
:return: list of handler classes | [
"Looks",
"for",
"handler",
"classes",
"within",
"handler",
"path",
"module",
"."
] | a6b1a431a343007f7ae55a193e432a61af22253f | https://github.com/invinst/ResponseBot/blob/a6b1a431a343007f7ae55a193e432a61af22253f/responsebot/utils/handler_utils.py#L14-L37 |
38,730 | derpferd/little-python | littlepython/tokenizer.py | Tokens.get_multi_word_keywords | def get_multi_word_keywords(features):
"""This returns an OrderedDict containing the multi word keywords in order of length.
This is so the tokenizer will match the longer matches before the shorter matches
"""
keys = {
'is not': Token(TokenTypes.NOT_EQUAL, 'is not'),
... | python | def get_multi_word_keywords(features):
"""This returns an OrderedDict containing the multi word keywords in order of length.
This is so the tokenizer will match the longer matches before the shorter matches
"""
keys = {
'is not': Token(TokenTypes.NOT_EQUAL, 'is not'),
... | [
"def",
"get_multi_word_keywords",
"(",
"features",
")",
":",
"keys",
"=",
"{",
"'is not'",
":",
"Token",
"(",
"TokenTypes",
".",
"NOT_EQUAL",
",",
"'is not'",
")",
",",
"}",
"return",
"OrderedDict",
"(",
"sorted",
"(",
"list",
"(",
"keys",
".",
"items",
... | This returns an OrderedDict containing the multi word keywords in order of length.
This is so the tokenizer will match the longer matches before the shorter matches | [
"This",
"returns",
"an",
"OrderedDict",
"containing",
"the",
"multi",
"word",
"keywords",
"in",
"order",
"of",
"length",
".",
"This",
"is",
"so",
"the",
"tokenizer",
"will",
"match",
"the",
"longer",
"matches",
"before",
"the",
"shorter",
"matches"
] | 3f89c74cffb6532c12c5b40843bd8ff8605638ba | https://github.com/derpferd/little-python/blob/3f89c74cffb6532c12c5b40843bd8ff8605638ba/littlepython/tokenizer.py#L204-L211 |
38,731 | e7dal/bubble3 | bubble3/util/inside_try.py | inside_try | def inside_try(func, options={}):
""" decorator to silence exceptions, for logging
we want a "safe" fail of the functions """
if six.PY2:
name = func.func_name
else:
name = func.__name__
@wraps(func)
def silenceit(*args, **kwargs):
""" the function func to be silence... | python | def inside_try(func, options={}):
""" decorator to silence exceptions, for logging
we want a "safe" fail of the functions """
if six.PY2:
name = func.func_name
else:
name = func.__name__
@wraps(func)
def silenceit(*args, **kwargs):
""" the function func to be silence... | [
"def",
"inside_try",
"(",
"func",
",",
"options",
"=",
"{",
"}",
")",
":",
"if",
"six",
".",
"PY2",
":",
"name",
"=",
"func",
".",
"func_name",
"else",
":",
"name",
"=",
"func",
".",
"__name__",
"@",
"wraps",
"(",
"func",
")",
"def",
"silenceit",
... | decorator to silence exceptions, for logging
we want a "safe" fail of the functions | [
"decorator",
"to",
"silence",
"exceptions",
"for",
"logging",
"we",
"want",
"a",
"safe",
"fail",
"of",
"the",
"functions"
] | 59c735281a95b44f6263a25f4d6ce24fca520082 | https://github.com/e7dal/bubble3/blob/59c735281a95b44f6263a25f4d6ce24fca520082/bubble3/util/inside_try.py#L65-L125 |
38,732 | dturanski/springcloudstream | springcloudstream/grpc/stream.py | BaseStreamComponent.start | def start(self):
"""
Start the server and run forever.
"""
Server().start(self.options,self.handler_function, self.__class__.component_type) | python | def start(self):
"""
Start the server and run forever.
"""
Server().start(self.options,self.handler_function, self.__class__.component_type) | [
"def",
"start",
"(",
"self",
")",
":",
"Server",
"(",
")",
".",
"start",
"(",
"self",
".",
"options",
",",
"self",
".",
"handler_function",
",",
"self",
".",
"__class__",
".",
"component_type",
")"
] | Start the server and run forever. | [
"Start",
"the",
"server",
"and",
"run",
"forever",
"."
] | 208b542f9eba82e97882d52703af8e965a62a980 | https://github.com/dturanski/springcloudstream/blob/208b542f9eba82e97882d52703af8e965a62a980/springcloudstream/grpc/stream.py#L108-L112 |
38,733 | sharibarboza/py_zap | py_zap/sorter.py | Sorter.sort_entries | def sort_entries(self):
"""Get whether reverse is True or False. Return the sorted data."""
return sorted(self.data, key=self.sort_func, reverse=self.get_reverse()) | python | def sort_entries(self):
"""Get whether reverse is True or False. Return the sorted data."""
return sorted(self.data, key=self.sort_func, reverse=self.get_reverse()) | [
"def",
"sort_entries",
"(",
"self",
")",
":",
"return",
"sorted",
"(",
"self",
".",
"data",
",",
"key",
"=",
"self",
".",
"sort_func",
",",
"reverse",
"=",
"self",
".",
"get_reverse",
"(",
")",
")"
] | Get whether reverse is True or False. Return the sorted data. | [
"Get",
"whether",
"reverse",
"is",
"True",
"or",
"False",
".",
"Return",
"the",
"sorted",
"data",
"."
] | ce90853efcad66d3e28b8f1ac910f275349d016c | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/sorter.py#L61-L63 |
38,734 | stephrdev/django-tapeforms | tapeforms/fieldsets.py | TapeformFieldset.visible_fields | def visible_fields(self):
"""
Returns the reduced set of visible fields to output from the form.
This method respects the provided ``fields`` configuration _and_ exlcudes
all fields from the ``exclude`` configuration.
If no ``fields`` where provided when configuring this fields... | python | def visible_fields(self):
"""
Returns the reduced set of visible fields to output from the form.
This method respects the provided ``fields`` configuration _and_ exlcudes
all fields from the ``exclude`` configuration.
If no ``fields`` where provided when configuring this fields... | [
"def",
"visible_fields",
"(",
"self",
")",
":",
"form_visible_fields",
"=",
"self",
".",
"form",
".",
"visible_fields",
"(",
")",
"if",
"self",
".",
"render_fields",
":",
"fields",
"=",
"self",
".",
"render_fields",
"else",
":",
"fields",
"=",
"[",
"field"... | Returns the reduced set of visible fields to output from the form.
This method respects the provided ``fields`` configuration _and_ exlcudes
all fields from the ``exclude`` configuration.
If no ``fields`` where provided when configuring this fieldset, all visible
fields minus the exclu... | [
"Returns",
"the",
"reduced",
"set",
"of",
"visible",
"fields",
"to",
"output",
"from",
"the",
"form",
"."
] | 255602de43777141f18afaf30669d7bdd4f7c323 | https://github.com/stephrdev/django-tapeforms/blob/255602de43777141f18afaf30669d7bdd4f7c323/tapeforms/fieldsets.py#L76-L97 |
38,735 | stephrdev/django-tapeforms | tapeforms/fieldsets.py | TapeformFieldsetsMixin.get_fieldsets | def get_fieldsets(self, fieldsets=None):
"""
This method returns a generator which yields fieldset instances.
The method uses the optional fieldsets argument to generate fieldsets for.
If no fieldsets argument is passed, the class property ``fieldsets`` is used.
When generating... | python | def get_fieldsets(self, fieldsets=None):
"""
This method returns a generator which yields fieldset instances.
The method uses the optional fieldsets argument to generate fieldsets for.
If no fieldsets argument is passed, the class property ``fieldsets`` is used.
When generating... | [
"def",
"get_fieldsets",
"(",
"self",
",",
"fieldsets",
"=",
"None",
")",
":",
"fieldsets",
"=",
"fieldsets",
"or",
"self",
".",
"fieldsets",
"if",
"not",
"fieldsets",
":",
"raise",
"StopIteration",
"# Search for primary marker in at least one of the fieldset kwargs.",
... | This method returns a generator which yields fieldset instances.
The method uses the optional fieldsets argument to generate fieldsets for.
If no fieldsets argument is passed, the class property ``fieldsets`` is used.
When generating the fieldsets, the method ensures that at least one fielset
... | [
"This",
"method",
"returns",
"a",
"generator",
"which",
"yields",
"fieldset",
"instances",
"."
] | 255602de43777141f18afaf30669d7bdd4f7c323 | https://github.com/stephrdev/django-tapeforms/blob/255602de43777141f18afaf30669d7bdd4f7c323/tapeforms/fieldsets.py#L132-L163 |
38,736 | AshleySetter/optoanalysis | optoanalysis/optoanalysis/Saleae/Saleae.py | get_chunks | def get_chunks(Array, Chunksize):
"""Generator that yields chunks of size ChunkSize"""
for i in range(0, len(Array), Chunksize):
yield Array[i:i + Chunksize] | python | def get_chunks(Array, Chunksize):
"""Generator that yields chunks of size ChunkSize"""
for i in range(0, len(Array), Chunksize):
yield Array[i:i + Chunksize] | [
"def",
"get_chunks",
"(",
"Array",
",",
"Chunksize",
")",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"Array",
")",
",",
"Chunksize",
")",
":",
"yield",
"Array",
"[",
"i",
":",
"i",
"+",
"Chunksize",
"]"
] | Generator that yields chunks of size ChunkSize | [
"Generator",
"that",
"yields",
"chunks",
"of",
"size",
"ChunkSize"
] | 9d390acc834d70024d47b574aea14189a5a5714e | https://github.com/AshleySetter/optoanalysis/blob/9d390acc834d70024d47b574aea14189a5a5714e/optoanalysis/optoanalysis/Saleae/Saleae.py#L4-L7 |
38,737 | AshleySetter/optoanalysis | optoanalysis/optoanalysis/Saleae/Saleae.py | read_data_from_bin_file | def read_data_from_bin_file(fileName):
"""
Loads the binary data stored in the a binary file and extracts the
data for each channel that was saved, along with the sample rate and length
of the data array.
Parameters
----------
fileContent : bytes
bytes object containing the data f... | python | def read_data_from_bin_file(fileName):
"""
Loads the binary data stored in the a binary file and extracts the
data for each channel that was saved, along with the sample rate and length
of the data array.
Parameters
----------
fileContent : bytes
bytes object containing the data f... | [
"def",
"read_data_from_bin_file",
"(",
"fileName",
")",
":",
"with",
"open",
"(",
"fileName",
",",
"mode",
"=",
"'rb'",
")",
"as",
"file",
":",
"# b is important -> binary",
"fileContent",
"=",
"file",
".",
"read",
"(",
")",
"(",
"ChannelData",
",",
"LenOf1C... | Loads the binary data stored in the a binary file and extracts the
data for each channel that was saved, along with the sample rate and length
of the data array.
Parameters
----------
fileContent : bytes
bytes object containing the data from a .bin file exported from
the saleae da... | [
"Loads",
"the",
"binary",
"data",
"stored",
"in",
"the",
"a",
"binary",
"file",
"and",
"extracts",
"the",
"data",
"for",
"each",
"channel",
"that",
"was",
"saved",
"along",
"with",
"the",
"sample",
"rate",
"and",
"length",
"of",
"the",
"data",
"array",
"... | 9d390acc834d70024d47b574aea14189a5a5714e | https://github.com/AshleySetter/optoanalysis/blob/9d390acc834d70024d47b574aea14189a5a5714e/optoanalysis/optoanalysis/Saleae/Saleae.py#L9-L40 |
38,738 | AshleySetter/optoanalysis | optoanalysis/optoanalysis/Saleae/Saleae.py | read_data_from_bytes | def read_data_from_bytes(fileContent):
"""
Takes the binary data stored in the binary string provided and extracts the
data for each channel that was saved, along with the sample rate and length
of the data array.
Parameters
----------
fileContent : bytes
bytes object containing t... | python | def read_data_from_bytes(fileContent):
"""
Takes the binary data stored in the binary string provided and extracts the
data for each channel that was saved, along with the sample rate and length
of the data array.
Parameters
----------
fileContent : bytes
bytes object containing t... | [
"def",
"read_data_from_bytes",
"(",
"fileContent",
")",
":",
"TotalDataLen",
"=",
"struct",
".",
"unpack",
"(",
"'Q'",
",",
"fileContent",
"[",
":",
"8",
"]",
")",
"[",
"0",
"]",
"# Unsigned long long ",
"NumOfChannels",
"=",
"struct",
".",
"unpack",
"(",
... | Takes the binary data stored in the binary string provided and extracts the
data for each channel that was saved, along with the sample rate and length
of the data array.
Parameters
----------
fileContent : bytes
bytes object containing the data from a .bin file exported from
the ... | [
"Takes",
"the",
"binary",
"data",
"stored",
"in",
"the",
"binary",
"string",
"provided",
"and",
"extracts",
"the",
"data",
"for",
"each",
"channel",
"that",
"was",
"saved",
"along",
"with",
"the",
"sample",
"rate",
"and",
"length",
"of",
"the",
"data",
"ar... | 9d390acc834d70024d47b574aea14189a5a5714e | https://github.com/AshleySetter/optoanalysis/blob/9d390acc834d70024d47b574aea14189a5a5714e/optoanalysis/optoanalysis/Saleae/Saleae.py#L42-L79 |
38,739 | Hypex/hyppy | hyppy/func.py | get_coord_box | def get_coord_box(centre_x, centre_y, distance):
"""Get the square boundary coordinates for a given centre and distance"""
"""Todo: return coordinates inside a circle, rather than a square"""
return {
'top_left': (centre_x - distance, centre_y + distance),
'top_right': (centre_x + distance, ... | python | def get_coord_box(centre_x, centre_y, distance):
"""Get the square boundary coordinates for a given centre and distance"""
"""Todo: return coordinates inside a circle, rather than a square"""
return {
'top_left': (centre_x - distance, centre_y + distance),
'top_right': (centre_x + distance, ... | [
"def",
"get_coord_box",
"(",
"centre_x",
",",
"centre_y",
",",
"distance",
")",
":",
"\"\"\"Todo: return coordinates inside a circle, rather than a square\"\"\"",
"return",
"{",
"'top_left'",
":",
"(",
"centre_x",
"-",
"distance",
",",
"centre_y",
"+",
"distance",
")",
... | Get the square boundary coordinates for a given centre and distance | [
"Get",
"the",
"square",
"boundary",
"coordinates",
"for",
"a",
"given",
"centre",
"and",
"distance"
] | a425619c2a102b0e598fd6cac8aa0f6b766f542d | https://github.com/Hypex/hyppy/blob/a425619c2a102b0e598fd6cac8aa0f6b766f542d/hyppy/func.py#L1-L9 |
38,740 | Hypex/hyppy | hyppy/func.py | fleet_ttb | def fleet_ttb(unit_type, quantity, factories, is_techno=False, is_dict=False, stasis_enabled=False):
"""
Calculate the time taken to construct a given fleet
"""
unit_weights = {
UNIT_SCOUT: 1,
UNIT_DESTROYER: 13,
UNIT_BOMBER: 10,
UNIT_CRUISER: 85,
UNIT_STARBASE:... | python | def fleet_ttb(unit_type, quantity, factories, is_techno=False, is_dict=False, stasis_enabled=False):
"""
Calculate the time taken to construct a given fleet
"""
unit_weights = {
UNIT_SCOUT: 1,
UNIT_DESTROYER: 13,
UNIT_BOMBER: 10,
UNIT_CRUISER: 85,
UNIT_STARBASE:... | [
"def",
"fleet_ttb",
"(",
"unit_type",
",",
"quantity",
",",
"factories",
",",
"is_techno",
"=",
"False",
",",
"is_dict",
"=",
"False",
",",
"stasis_enabled",
"=",
"False",
")",
":",
"unit_weights",
"=",
"{",
"UNIT_SCOUT",
":",
"1",
",",
"UNIT_DESTROYER",
"... | Calculate the time taken to construct a given fleet | [
"Calculate",
"the",
"time",
"taken",
"to",
"construct",
"a",
"given",
"fleet"
] | a425619c2a102b0e598fd6cac8aa0f6b766f542d | https://github.com/Hypex/hyppy/blob/a425619c2a102b0e598fd6cac8aa0f6b766f542d/hyppy/func.py#L19-L40 |
38,741 | standage/tag | tag/reader.py | parse_fasta | def parse_fasta(data): # pragma: no cover
"""
Load sequences in Fasta format.
This generator function yields a Sequence object for each sequence record
in a GFF3 file. Implementation stolen shamelessly from
http://stackoverflow.com/a/7655072/459780.
"""
name, seq = None, []
for line in... | python | def parse_fasta(data): # pragma: no cover
"""
Load sequences in Fasta format.
This generator function yields a Sequence object for each sequence record
in a GFF3 file. Implementation stolen shamelessly from
http://stackoverflow.com/a/7655072/459780.
"""
name, seq = None, []
for line in... | [
"def",
"parse_fasta",
"(",
"data",
")",
":",
"# pragma: no cover",
"name",
",",
"seq",
"=",
"None",
",",
"[",
"]",
"for",
"line",
"in",
"data",
":",
"line",
"=",
"line",
".",
"rstrip",
"(",
")",
"if",
"line",
".",
"startswith",
"(",
"'>'",
")",
":"... | Load sequences in Fasta format.
This generator function yields a Sequence object for each sequence record
in a GFF3 file. Implementation stolen shamelessly from
http://stackoverflow.com/a/7655072/459780. | [
"Load",
"sequences",
"in",
"Fasta",
"format",
"."
] | 94686adf57115cea1c5235e99299e691f80ba10b | https://github.com/standage/tag/blob/94686adf57115cea1c5235e99299e691f80ba10b/tag/reader.py#L19-L37 |
38,742 | standage/tag | tag/reader.py | GFF3Reader._reset | def _reset(self):
"""Clear internal data structure."""
self.records = list()
self.featsbyid = dict()
self.featsbyparent = dict()
self.countsbytype = dict() | python | def _reset(self):
"""Clear internal data structure."""
self.records = list()
self.featsbyid = dict()
self.featsbyparent = dict()
self.countsbytype = dict() | [
"def",
"_reset",
"(",
"self",
")",
":",
"self",
".",
"records",
"=",
"list",
"(",
")",
"self",
".",
"featsbyid",
"=",
"dict",
"(",
")",
"self",
".",
"featsbyparent",
"=",
"dict",
"(",
")",
"self",
".",
"countsbytype",
"=",
"dict",
"(",
")"
] | Clear internal data structure. | [
"Clear",
"internal",
"data",
"structure",
"."
] | 94686adf57115cea1c5235e99299e691f80ba10b | https://github.com/standage/tag/blob/94686adf57115cea1c5235e99299e691f80ba10b/tag/reader.py#L222-L227 |
38,743 | jplusplus/statscraper | statscraper/BaseScraperList.py | BaseScraperList.get_by_label | def get_by_label(self, label):
""" Return the first item with a specific label,
or None.
"""
return next((x for x in self if x.label == label), None) | python | def get_by_label(self, label):
""" Return the first item with a specific label,
or None.
"""
return next((x for x in self if x.label == label), None) | [
"def",
"get_by_label",
"(",
"self",
",",
"label",
")",
":",
"return",
"next",
"(",
"(",
"x",
"for",
"x",
"in",
"self",
"if",
"x",
".",
"label",
"==",
"label",
")",
",",
"None",
")"
] | Return the first item with a specific label,
or None. | [
"Return",
"the",
"first",
"item",
"with",
"a",
"specific",
"label",
"or",
"None",
"."
] | 932ec048b23d15b3dbdaf829facc55fd78ec0109 | https://github.com/jplusplus/statscraper/blob/932ec048b23d15b3dbdaf829facc55fd78ec0109/statscraper/BaseScraperList.py#L17-L21 |
38,744 | sporsh/carnifex | carnifex/ssh/userauth.py | AutomaticUserAuthClient.getGenericAnswers | def getGenericAnswers(self, name, instruction, prompts):
"""Called when the server requests keyboard interactive authentication
"""
responses = []
for prompt, _echo in prompts:
password = self.getPassword(prompt)
responses.append(password)
return defer.su... | python | def getGenericAnswers(self, name, instruction, prompts):
"""Called when the server requests keyboard interactive authentication
"""
responses = []
for prompt, _echo in prompts:
password = self.getPassword(prompt)
responses.append(password)
return defer.su... | [
"def",
"getGenericAnswers",
"(",
"self",
",",
"name",
",",
"instruction",
",",
"prompts",
")",
":",
"responses",
"=",
"[",
"]",
"for",
"prompt",
",",
"_echo",
"in",
"prompts",
":",
"password",
"=",
"self",
".",
"getPassword",
"(",
"prompt",
")",
"respons... | Called when the server requests keyboard interactive authentication | [
"Called",
"when",
"the",
"server",
"requests",
"keyboard",
"interactive",
"authentication"
] | 82dd3bd2bc134dfb69a78f43171e227f2127060b | https://github.com/sporsh/carnifex/blob/82dd3bd2bc134dfb69a78f43171e227f2127060b/carnifex/ssh/userauth.py#L20-L28 |
38,745 | LeastAuthority/txkube | src/txkube/_authentication.py | pairwise | def pairwise(iterable):
"""
Generate consecutive pairs of elements from the given iterable.
"""
iterator = iter(iterable)
try:
first = next(iterator)
except StopIteration:
return
for element in iterator:
yield first, element
first = element | python | def pairwise(iterable):
"""
Generate consecutive pairs of elements from the given iterable.
"""
iterator = iter(iterable)
try:
first = next(iterator)
except StopIteration:
return
for element in iterator:
yield first, element
first = element | [
"def",
"pairwise",
"(",
"iterable",
")",
":",
"iterator",
"=",
"iter",
"(",
"iterable",
")",
"try",
":",
"first",
"=",
"next",
"(",
"iterator",
")",
"except",
"StopIteration",
":",
"return",
"for",
"element",
"in",
"iterator",
":",
"yield",
"first",
",",... | Generate consecutive pairs of elements from the given iterable. | [
"Generate",
"consecutive",
"pairs",
"of",
"elements",
"from",
"the",
"given",
"iterable",
"."
] | a7e555d00535ff787d4b1204c264780da40cf736 | https://github.com/LeastAuthority/txkube/blob/a7e555d00535ff787d4b1204c264780da40cf736/src/txkube/_authentication.py#L66-L77 |
38,746 | LeastAuthority/txkube | src/txkube/_authentication.py | https_policy_from_config | def https_policy_from_config(config):
"""
Create an ``IPolicyForHTTPS`` which can authenticate a Kubernetes API
server.
:param KubeConfig config: A Kubernetes configuration containing an active
context identifying a cluster. The resulting ``IPolicyForHTTPS`` will
authenticate the API s... | python | def https_policy_from_config(config):
"""
Create an ``IPolicyForHTTPS`` which can authenticate a Kubernetes API
server.
:param KubeConfig config: A Kubernetes configuration containing an active
context identifying a cluster. The resulting ``IPolicyForHTTPS`` will
authenticate the API s... | [
"def",
"https_policy_from_config",
"(",
"config",
")",
":",
"server",
"=",
"config",
".",
"cluster",
"[",
"\"server\"",
"]",
"base_url",
"=",
"URL",
".",
"fromText",
"(",
"native_string_to_unicode",
"(",
"server",
")",
")",
"ca_certs",
"=",
"pem",
".",
"pars... | Create an ``IPolicyForHTTPS`` which can authenticate a Kubernetes API
server.
:param KubeConfig config: A Kubernetes configuration containing an active
context identifying a cluster. The resulting ``IPolicyForHTTPS`` will
authenticate the API server for that cluster.
:return IPolicyForHTT... | [
"Create",
"an",
"IPolicyForHTTPS",
"which",
"can",
"authenticate",
"a",
"Kubernetes",
"API",
"server",
"."
] | a7e555d00535ff787d4b1204c264780da40cf736 | https://github.com/LeastAuthority/txkube/blob/a7e555d00535ff787d4b1204c264780da40cf736/src/txkube/_authentication.py#L235-L272 |
38,747 | LeastAuthority/txkube | src/txkube/_authentication.py | authenticate_with_certificate_chain | def authenticate_with_certificate_chain(reactor, base_url, client_chain, client_key, ca_cert):
"""
Create an ``IAgent`` which can issue authenticated requests to a
particular Kubernetes server using a client certificate.
:param reactor: The reactor with which to configure the resulting agent.
:par... | python | def authenticate_with_certificate_chain(reactor, base_url, client_chain, client_key, ca_cert):
"""
Create an ``IAgent`` which can issue authenticated requests to a
particular Kubernetes server using a client certificate.
:param reactor: The reactor with which to configure the resulting agent.
:par... | [
"def",
"authenticate_with_certificate_chain",
"(",
"reactor",
",",
"base_url",
",",
"client_chain",
",",
"client_key",
",",
"ca_cert",
")",
":",
"if",
"base_url",
".",
"scheme",
"!=",
"u\"https\"",
":",
"raise",
"ValueError",
"(",
"\"authenticate_with_certificate() ma... | Create an ``IAgent`` which can issue authenticated requests to a
particular Kubernetes server using a client certificate.
:param reactor: The reactor with which to configure the resulting agent.
:param twisted.python.url.URL base_url: The base location of the
Kubernetes API.
:param list[pem.C... | [
"Create",
"an",
"IAgent",
"which",
"can",
"issue",
"authenticated",
"requests",
"to",
"a",
"particular",
"Kubernetes",
"server",
"using",
"a",
"client",
"certificate",
"."
] | a7e555d00535ff787d4b1204c264780da40cf736 | https://github.com/LeastAuthority/txkube/blob/a7e555d00535ff787d4b1204c264780da40cf736/src/txkube/_authentication.py#L276-L318 |
38,748 | LeastAuthority/txkube | src/txkube/_authentication.py | authenticate_with_certificate | def authenticate_with_certificate(reactor, base_url, client_cert, client_key, ca_cert):
"""
See ``authenticate_with_certificate_chain``.
:param pem.Certificate client_cert: The client certificate to use.
"""
return authenticate_with_certificate_chain(
reactor, base_url, [client_cert], clien... | python | def authenticate_with_certificate(reactor, base_url, client_cert, client_key, ca_cert):
"""
See ``authenticate_with_certificate_chain``.
:param pem.Certificate client_cert: The client certificate to use.
"""
return authenticate_with_certificate_chain(
reactor, base_url, [client_cert], clien... | [
"def",
"authenticate_with_certificate",
"(",
"reactor",
",",
"base_url",
",",
"client_cert",
",",
"client_key",
",",
"ca_cert",
")",
":",
"return",
"authenticate_with_certificate_chain",
"(",
"reactor",
",",
"base_url",
",",
"[",
"client_cert",
"]",
",",
"client_key... | See ``authenticate_with_certificate_chain``.
:param pem.Certificate client_cert: The client certificate to use. | [
"See",
"authenticate_with_certificate_chain",
"."
] | a7e555d00535ff787d4b1204c264780da40cf736 | https://github.com/LeastAuthority/txkube/blob/a7e555d00535ff787d4b1204c264780da40cf736/src/txkube/_authentication.py#L322-L330 |
38,749 | LeastAuthority/txkube | src/txkube/_authentication.py | authenticate_with_serviceaccount | def authenticate_with_serviceaccount(reactor, **kw):
"""
Create an ``IAgent`` which can issue authenticated requests to a
particular Kubernetes server using a service account token.
:param reactor: The reactor with which to configure the resulting agent.
:param bytes path: The location of the serv... | python | def authenticate_with_serviceaccount(reactor, **kw):
"""
Create an ``IAgent`` which can issue authenticated requests to a
particular Kubernetes server using a service account token.
:param reactor: The reactor with which to configure the resulting agent.
:param bytes path: The location of the serv... | [
"def",
"authenticate_with_serviceaccount",
"(",
"reactor",
",",
"*",
"*",
"kw",
")",
":",
"config",
"=",
"KubeConfig",
".",
"from_service_account",
"(",
"*",
"*",
"kw",
")",
"policy",
"=",
"https_policy_from_config",
"(",
"config",
")",
"token",
"=",
"config",... | Create an ``IAgent`` which can issue authenticated requests to a
particular Kubernetes server using a service account token.
:param reactor: The reactor with which to configure the resulting agent.
:param bytes path: The location of the service account directory. The
default should work fine for ... | [
"Create",
"an",
"IAgent",
"which",
"can",
"issue",
"authenticated",
"requests",
"to",
"a",
"particular",
"Kubernetes",
"server",
"using",
"a",
"service",
"account",
"token",
"."
] | a7e555d00535ff787d4b1204c264780da40cf736 | https://github.com/LeastAuthority/txkube/blob/a7e555d00535ff787d4b1204c264780da40cf736/src/txkube/_authentication.py#L361-L382 |
38,750 | binbrain/OpenSesame | OpenSesame/keyring.py | OpenKeyring.first_time_setup | def first_time_setup(self):
"""First time running Open Sesame?
Create keyring and an auto-unlock key in default keyring. Make sure
these things don't already exist.
"""
if not self._auto_unlock_key_position():
pw = password.create_passwords()[0]
... | python | def first_time_setup(self):
"""First time running Open Sesame?
Create keyring and an auto-unlock key in default keyring. Make sure
these things don't already exist.
"""
if not self._auto_unlock_key_position():
pw = password.create_passwords()[0]
... | [
"def",
"first_time_setup",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_auto_unlock_key_position",
"(",
")",
":",
"pw",
"=",
"password",
".",
"create_passwords",
"(",
")",
"[",
"0",
"]",
"attrs",
"=",
"{",
"'application'",
":",
"self",
".",
"keyrin... | First time running Open Sesame?
Create keyring and an auto-unlock key in default keyring. Make sure
these things don't already exist. | [
"First",
"time",
"running",
"Open",
"Sesame?",
"Create",
"keyring",
"and",
"an",
"auto",
"-",
"unlock",
"key",
"in",
"default",
"keyring",
".",
"Make",
"sure",
"these",
"things",
"don",
"t",
"already",
"exist",
"."
] | e32c306385012646400ecb49fc65c64b14ce3a93 | https://github.com/binbrain/OpenSesame/blob/e32c306385012646400ecb49fc65c64b14ce3a93/OpenSesame/keyring.py#L31-L48 |
38,751 | binbrain/OpenSesame | OpenSesame/keyring.py | OpenKeyring._auto_unlock_key_position | def _auto_unlock_key_position(self):
"""Find the open sesame password in the default keyring
"""
found_pos = None
default_keyring_ids = gkr.list_item_ids_sync(self.default_keyring)
for pos in default_keyring_ids:
item_attrs = gkr.item_get_attributes_sync(self.default_... | python | def _auto_unlock_key_position(self):
"""Find the open sesame password in the default keyring
"""
found_pos = None
default_keyring_ids = gkr.list_item_ids_sync(self.default_keyring)
for pos in default_keyring_ids:
item_attrs = gkr.item_get_attributes_sync(self.default_... | [
"def",
"_auto_unlock_key_position",
"(",
"self",
")",
":",
"found_pos",
"=",
"None",
"default_keyring_ids",
"=",
"gkr",
".",
"list_item_ids_sync",
"(",
"self",
".",
"default_keyring",
")",
"for",
"pos",
"in",
"default_keyring_ids",
":",
"item_attrs",
"=",
"gkr",
... | Find the open sesame password in the default keyring | [
"Find",
"the",
"open",
"sesame",
"password",
"in",
"the",
"default",
"keyring"
] | e32c306385012646400ecb49fc65c64b14ce3a93 | https://github.com/binbrain/OpenSesame/blob/e32c306385012646400ecb49fc65c64b14ce3a93/OpenSesame/keyring.py#L50-L61 |
38,752 | binbrain/OpenSesame | OpenSesame/keyring.py | OpenKeyring.get_position_searchable | def get_position_searchable(self):
"""Return dict of the position and corrasponding searchable str
"""
ids = gkr.list_item_ids_sync(self.keyring)
position_searchable = {}
for i in ids:
item_attrs = gkr.item_get_attributes_sync(self.keyring, i)
position_sea... | python | def get_position_searchable(self):
"""Return dict of the position and corrasponding searchable str
"""
ids = gkr.list_item_ids_sync(self.keyring)
position_searchable = {}
for i in ids:
item_attrs = gkr.item_get_attributes_sync(self.keyring, i)
position_sea... | [
"def",
"get_position_searchable",
"(",
"self",
")",
":",
"ids",
"=",
"gkr",
".",
"list_item_ids_sync",
"(",
"self",
".",
"keyring",
")",
"position_searchable",
"=",
"{",
"}",
"for",
"i",
"in",
"ids",
":",
"item_attrs",
"=",
"gkr",
".",
"item_get_attributes_s... | Return dict of the position and corrasponding searchable str | [
"Return",
"dict",
"of",
"the",
"position",
"and",
"corrasponding",
"searchable",
"str"
] | e32c306385012646400ecb49fc65c64b14ce3a93 | https://github.com/binbrain/OpenSesame/blob/e32c306385012646400ecb49fc65c64b14ce3a93/OpenSesame/keyring.py#L69-L77 |
38,753 | binbrain/OpenSesame | OpenSesame/keyring.py | OpenKeyring._match_exists | def _match_exists(self, searchable):
"""Make sure the searchable description doesn't already exist
"""
position_searchable = self.get_position_searchable()
for pos,val in position_searchable.iteritems():
if val == searchable:
return pos
return False | python | def _match_exists(self, searchable):
"""Make sure the searchable description doesn't already exist
"""
position_searchable = self.get_position_searchable()
for pos,val in position_searchable.iteritems():
if val == searchable:
return pos
return False | [
"def",
"_match_exists",
"(",
"self",
",",
"searchable",
")",
":",
"position_searchable",
"=",
"self",
".",
"get_position_searchable",
"(",
")",
"for",
"pos",
",",
"val",
"in",
"position_searchable",
".",
"iteritems",
"(",
")",
":",
"if",
"val",
"==",
"search... | Make sure the searchable description doesn't already exist | [
"Make",
"sure",
"the",
"searchable",
"description",
"doesn",
"t",
"already",
"exist"
] | e32c306385012646400ecb49fc65c64b14ce3a93 | https://github.com/binbrain/OpenSesame/blob/e32c306385012646400ecb49fc65c64b14ce3a93/OpenSesame/keyring.py#L79-L86 |
38,754 | binbrain/OpenSesame | OpenSesame/keyring.py | OpenKeyring.save_password | def save_password(self, password, **attrs):
"""Save the new password, save the old password with the date prepended
"""
pos_of_match = self._match_exists(attrs['searchable'])
if pos_of_match:
old_password = self.get_password(pos_of_match).get_secret()
gkr.item_del... | python | def save_password(self, password, **attrs):
"""Save the new password, save the old password with the date prepended
"""
pos_of_match = self._match_exists(attrs['searchable'])
if pos_of_match:
old_password = self.get_password(pos_of_match).get_secret()
gkr.item_del... | [
"def",
"save_password",
"(",
"self",
",",
"password",
",",
"*",
"*",
"attrs",
")",
":",
"pos_of_match",
"=",
"self",
".",
"_match_exists",
"(",
"attrs",
"[",
"'searchable'",
"]",
")",
"if",
"pos_of_match",
":",
"old_password",
"=",
"self",
".",
"get_passwo... | Save the new password, save the old password with the date prepended | [
"Save",
"the",
"new",
"password",
"save",
"the",
"old",
"password",
"with",
"the",
"date",
"prepended"
] | e32c306385012646400ecb49fc65c64b14ce3a93 | https://github.com/binbrain/OpenSesame/blob/e32c306385012646400ecb49fc65c64b14ce3a93/OpenSesame/keyring.py#L88-L109 |
38,755 | diamondman/proteusisc | proteusisc/jtagDeviceDescription.py | get_descriptor_for_idcode | def get_descriptor_for_idcode(idcode):
"""Use this method to find bsdl descriptions for devices.
The caching on this method drastically lower the execution
time when there are a lot of bsdl files and more than one
device. May move it into a metaclass to make it more
transparent."""
idcode = idco... | python | def get_descriptor_for_idcode(idcode):
"""Use this method to find bsdl descriptions for devices.
The caching on this method drastically lower the execution
time when there are a lot of bsdl files and more than one
device. May move it into a metaclass to make it more
transparent."""
idcode = idco... | [
"def",
"get_descriptor_for_idcode",
"(",
"idcode",
")",
":",
"idcode",
"=",
"idcode",
"&",
"0x0fffffff",
"id_str",
"=",
"\"XXXX\"",
"+",
"bin",
"(",
"idcode",
")",
"[",
"2",
":",
"]",
".",
"zfill",
"(",
"28",
")",
"descr_file_path",
"=",
"_check_cache_for_... | Use this method to find bsdl descriptions for devices.
The caching on this method drastically lower the execution
time when there are a lot of bsdl files and more than one
device. May move it into a metaclass to make it more
transparent. | [
"Use",
"this",
"method",
"to",
"find",
"bsdl",
"descriptions",
"for",
"devices",
".",
"The",
"caching",
"on",
"this",
"method",
"drastically",
"lower",
"the",
"execution",
"time",
"when",
"there",
"are",
"a",
"lot",
"of",
"bsdl",
"files",
"and",
"more",
"t... | 7622b7b04e63f9dc0f5a04429ff78d9a490c9c5c | https://github.com/diamondman/proteusisc/blob/7622b7b04e63f9dc0f5a04429ff78d9a490c9c5c/proteusisc/jtagDeviceDescription.py#L30-L90 |
38,756 | jplusplus/statscraper | statscraper/scrapers/uka_scraper.py | UKA._fetch_dimensions | def _fetch_dimensions(self, dataset):
""" Iterate through semesters, counties and municipalities.
"""
yield Dimension(u"school")
yield Dimension(u"year",
datatype="year")
yield Dimension(u"semester",
datatype="academic_term",
... | python | def _fetch_dimensions(self, dataset):
""" Iterate through semesters, counties and municipalities.
"""
yield Dimension(u"school")
yield Dimension(u"year",
datatype="year")
yield Dimension(u"semester",
datatype="academic_term",
... | [
"def",
"_fetch_dimensions",
"(",
"self",
",",
"dataset",
")",
":",
"yield",
"Dimension",
"(",
"u\"school\"",
")",
"yield",
"Dimension",
"(",
"u\"year\"",
",",
"datatype",
"=",
"\"year\"",
")",
"yield",
"Dimension",
"(",
"u\"semester\"",
",",
"datatype",
"=",
... | Iterate through semesters, counties and municipalities. | [
"Iterate",
"through",
"semesters",
"counties",
"and",
"municipalities",
"."
] | 932ec048b23d15b3dbdaf829facc55fd78ec0109 | https://github.com/jplusplus/statscraper/blob/932ec048b23d15b3dbdaf829facc55fd78ec0109/statscraper/scrapers/uka_scraper.py#L24-L35 |
38,757 | LeastAuthority/txkube | src/txkube/_network.py | _merge_configs | def _merge_configs(configs):
"""
Merge one or more ``KubeConfig`` objects.
:param list[KubeConfig] configs: The configurations to merge.
:return KubeConfig: A single configuration object with the merged
configuration.
"""
result = {
u"contexts": [],
u"users": [],
... | python | def _merge_configs(configs):
"""
Merge one or more ``KubeConfig`` objects.
:param list[KubeConfig] configs: The configurations to merge.
:return KubeConfig: A single configuration object with the merged
configuration.
"""
result = {
u"contexts": [],
u"users": [],
... | [
"def",
"_merge_configs",
"(",
"configs",
")",
":",
"result",
"=",
"{",
"u\"contexts\"",
":",
"[",
"]",
",",
"u\"users\"",
":",
"[",
"]",
",",
"u\"clusters\"",
":",
"[",
"]",
",",
"u\"current-context\"",
":",
"None",
",",
"}",
"for",
"config",
"in",
"co... | Merge one or more ``KubeConfig`` objects.
:param list[KubeConfig] configs: The configurations to merge.
:return KubeConfig: A single configuration object with the merged
configuration. | [
"Merge",
"one",
"or",
"more",
"KubeConfig",
"objects",
"."
] | a7e555d00535ff787d4b1204c264780da40cf736 | https://github.com/LeastAuthority/txkube/blob/a7e555d00535ff787d4b1204c264780da40cf736/src/txkube/_network.py#L61-L91 |
38,758 | LeastAuthority/txkube | src/txkube/_network.py | _merge_configs_from_env | def _merge_configs_from_env(kubeconfigs):
"""
Merge configuration files from a ``KUBECONFIG`` environment variable.
:param bytes kubeconfigs: A value like the one given to ``KUBECONFIG`` to
specify multiple configuration files.
:return KubeConfig: A configuration object which has merged all of... | python | def _merge_configs_from_env(kubeconfigs):
"""
Merge configuration files from a ``KUBECONFIG`` environment variable.
:param bytes kubeconfigs: A value like the one given to ``KUBECONFIG`` to
specify multiple configuration files.
:return KubeConfig: A configuration object which has merged all of... | [
"def",
"_merge_configs_from_env",
"(",
"kubeconfigs",
")",
":",
"paths",
"=",
"list",
"(",
"FilePath",
"(",
"p",
")",
"for",
"p",
"in",
"kubeconfigs",
".",
"split",
"(",
"pathsep",
")",
"if",
"p",
")",
"config",
"=",
"_merge_configs",
"(",
"list",
"(",
... | Merge configuration files from a ``KUBECONFIG`` environment variable.
:param bytes kubeconfigs: A value like the one given to ``KUBECONFIG`` to
specify multiple configuration files.
:return KubeConfig: A configuration object which has merged all of the
configuration from the specified configur... | [
"Merge",
"configuration",
"files",
"from",
"a",
"KUBECONFIG",
"environment",
"variable",
"."
] | a7e555d00535ff787d4b1204c264780da40cf736 | https://github.com/LeastAuthority/txkube/blob/a7e555d00535ff787d4b1204c264780da40cf736/src/txkube/_network.py#L94-L117 |
38,759 | LeastAuthority/txkube | src/txkube/_network.py | network_kubernetes_from_context | def network_kubernetes_from_context(
reactor, context=None, path=None, environ=None,
default_config_path=FilePath(expanduser(u"~/.kube/config")),
):
"""
Create a new ``IKubernetes`` provider based on a kube config file.
:param reactor: A Twisted reactor which will be used for I/O and
... | python | def network_kubernetes_from_context(
reactor, context=None, path=None, environ=None,
default_config_path=FilePath(expanduser(u"~/.kube/config")),
):
"""
Create a new ``IKubernetes`` provider based on a kube config file.
:param reactor: A Twisted reactor which will be used for I/O and
... | [
"def",
"network_kubernetes_from_context",
"(",
"reactor",
",",
"context",
"=",
"None",
",",
"path",
"=",
"None",
",",
"environ",
"=",
"None",
",",
"default_config_path",
"=",
"FilePath",
"(",
"expanduser",
"(",
"u\"~/.kube/config\"",
")",
")",
",",
")",
":",
... | Create a new ``IKubernetes`` provider based on a kube config file.
:param reactor: A Twisted reactor which will be used for I/O and
scheduling.
:param unicode context: The name of the kube config context from which to
load configuration details. Or, ``None`` to respect the current
con... | [
"Create",
"a",
"new",
"IKubernetes",
"provider",
"based",
"on",
"a",
"kube",
"config",
"file",
"."
] | a7e555d00535ff787d4b1204c264780da40cf736 | https://github.com/LeastAuthority/txkube/blob/a7e555d00535ff787d4b1204c264780da40cf736/src/txkube/_network.py#L120-L178 |
38,760 | LeastAuthority/txkube | src/txkube/_network.py | collection_location | def collection_location(obj):
"""
Get the URL for the collection of objects like ``obj``.
:param obj: Either a type representing a Kubernetes object kind or an
instance of such a type.
:return tuple[unicode]: Some path segments to stick on to a base URL to
construct the location of the... | python | def collection_location(obj):
"""
Get the URL for the collection of objects like ``obj``.
:param obj: Either a type representing a Kubernetes object kind or an
instance of such a type.
:return tuple[unicode]: Some path segments to stick on to a base URL to
construct the location of the... | [
"def",
"collection_location",
"(",
"obj",
")",
":",
"# TODO kind is not part of IObjectLoader and we should really be loading",
"# apiVersion off of this object too.",
"kind",
"=",
"obj",
".",
"kind",
"apiVersion",
"=",
"obj",
".",
"apiVersion",
"prefix",
"=",
"version_to_seg... | Get the URL for the collection of objects like ``obj``.
:param obj: Either a type representing a Kubernetes object kind or an
instance of such a type.
:return tuple[unicode]: Some path segments to stick on to a base URL to
construct the location of the collection of objects like the one
... | [
"Get",
"the",
"URL",
"for",
"the",
"collection",
"of",
"objects",
"like",
"obj",
"."
] | a7e555d00535ff787d4b1204c264780da40cf736 | https://github.com/LeastAuthority/txkube/blob/a7e555d00535ff787d4b1204c264780da40cf736/src/txkube/_network.py#L424-L456 |
38,761 | botstory/botstory | botstory/ast/story_context/reducers.py | execute | async def execute(ctx):
"""
execute story part at the current context
and make one step further
:param ctx:
:return:
"""
tail_depth = len(ctx.stack()) - 1
story_part = ctx.get_current_story_part()
logger.debug('# going to call: {}'.format(story_part.__name__))
waiting_for = sto... | python | async def execute(ctx):
"""
execute story part at the current context
and make one step further
:param ctx:
:return:
"""
tail_depth = len(ctx.stack()) - 1
story_part = ctx.get_current_story_part()
logger.debug('# going to call: {}'.format(story_part.__name__))
waiting_for = sto... | [
"async",
"def",
"execute",
"(",
"ctx",
")",
":",
"tail_depth",
"=",
"len",
"(",
"ctx",
".",
"stack",
"(",
")",
")",
"-",
"1",
"story_part",
"=",
"ctx",
".",
"get_current_story_part",
"(",
")",
"logger",
".",
"debug",
"(",
"'# going to call: {}'",
".",
... | execute story part at the current context
and make one step further
:param ctx:
:return: | [
"execute",
"story",
"part",
"at",
"the",
"current",
"context",
"and",
"make",
"one",
"step",
"further"
] | 9c5b2fc7f7a14dbd467d70f60d5ba855ef89dac3 | https://github.com/botstory/botstory/blob/9c5b2fc7f7a14dbd467d70f60d5ba855ef89dac3/botstory/ast/story_context/reducers.py#L20-L85 |
38,762 | botstory/botstory | botstory/ast/story_context/reducers.py | iterate_storyline | def iterate_storyline(ctx):
"""
iterate the last storyline from the last visited story part
:param ctx:
:return:
"""
logger.debug('# start iterate')
compiled_story = ctx.compiled_story()
if not compiled_story:
return
for step in range(ctx.current_step(),
... | python | def iterate_storyline(ctx):
"""
iterate the last storyline from the last visited story part
:param ctx:
:return:
"""
logger.debug('# start iterate')
compiled_story = ctx.compiled_story()
if not compiled_story:
return
for step in range(ctx.current_step(),
... | [
"def",
"iterate_storyline",
"(",
"ctx",
")",
":",
"logger",
".",
"debug",
"(",
"'# start iterate'",
")",
"compiled_story",
"=",
"ctx",
".",
"compiled_story",
"(",
")",
"if",
"not",
"compiled_story",
":",
"return",
"for",
"step",
"in",
"range",
"(",
"ctx",
... | iterate the last storyline from the last visited story part
:param ctx:
:return: | [
"iterate",
"the",
"last",
"storyline",
"from",
"the",
"last",
"visited",
"story",
"part"
] | 9c5b2fc7f7a14dbd467d70f60d5ba855ef89dac3 | https://github.com/botstory/botstory/blob/9c5b2fc7f7a14dbd467d70f60d5ba855ef89dac3/botstory/ast/story_context/reducers.py#L88-L114 |
38,763 | botstory/botstory | botstory/ast/story_context/reducers.py | scope_in | def scope_in(ctx):
"""
- build new scope on the top of stack
- and current scope will wait for it result
:param ctx:
:return:
"""
logger.debug('# scope_in')
logger.debug(ctx)
ctx = ctx.clone()
compiled_story = None
if not ctx.is_empty_stack():
compiled_story = ctx.g... | python | def scope_in(ctx):
"""
- build new scope on the top of stack
- and current scope will wait for it result
:param ctx:
:return:
"""
logger.debug('# scope_in')
logger.debug(ctx)
ctx = ctx.clone()
compiled_story = None
if not ctx.is_empty_stack():
compiled_story = ctx.g... | [
"def",
"scope_in",
"(",
"ctx",
")",
":",
"logger",
".",
"debug",
"(",
"'# scope_in'",
")",
"logger",
".",
"debug",
"(",
"ctx",
")",
"ctx",
"=",
"ctx",
".",
"clone",
"(",
")",
"compiled_story",
"=",
"None",
"if",
"not",
"ctx",
".",
"is_empty_stack",
"... | - build new scope on the top of stack
- and current scope will wait for it result
:param ctx:
:return: | [
"-",
"build",
"new",
"scope",
"on",
"the",
"top",
"of",
"stack",
"-",
"and",
"current",
"scope",
"will",
"wait",
"for",
"it",
"result"
] | 9c5b2fc7f7a14dbd467d70f60d5ba855ef89dac3 | https://github.com/botstory/botstory/blob/9c5b2fc7f7a14dbd467d70f60d5ba855ef89dac3/botstory/ast/story_context/reducers.py#L117-L158 |
38,764 | MacHu-GWU/rolex-project | rolex/parse.py | Parser.str2date | def str2date(self, date_str):
"""
Parse date from string.
If there's no template matches your string, Please go
https://github.com/MacHu-GWU/rolex-project/issues
submit your datetime string. I 'll update templates ASAP.
This method is faster than :meth:`dateutil.parser.... | python | def str2date(self, date_str):
"""
Parse date from string.
If there's no template matches your string, Please go
https://github.com/MacHu-GWU/rolex-project/issues
submit your datetime string. I 'll update templates ASAP.
This method is faster than :meth:`dateutil.parser.... | [
"def",
"str2date",
"(",
"self",
",",
"date_str",
")",
":",
"# try default date template",
"try",
":",
"a_datetime",
"=",
"datetime",
".",
"strptime",
"(",
"date_str",
",",
"self",
".",
"_default_date_template",
")",
"return",
"a_datetime",
".",
"date",
"(",
")... | Parse date from string.
If there's no template matches your string, Please go
https://github.com/MacHu-GWU/rolex-project/issues
submit your datetime string. I 'll update templates ASAP.
This method is faster than :meth:`dateutil.parser.parse`.
:param date_str: a string represe... | [
"Parse",
"date",
"from",
"string",
"."
] | a1111b410ed04b4b6eddd81df110fa2dacfa6537 | https://github.com/MacHu-GWU/rolex-project/blob/a1111b410ed04b4b6eddd81df110fa2dacfa6537/rolex/parse.py#L129-L168 |
38,765 | MacHu-GWU/rolex-project | rolex/parse.py | Parser._str2datetime | def _str2datetime(self, datetime_str):
"""
Parse datetime from string.
If there's no template matches your string, Please go
https://github.com/MacHu-GWU/rolex-project/issues
submit your datetime string. I 'll update templates ASAP.
This method is faster than :meth:`dat... | python | def _str2datetime(self, datetime_str):
"""
Parse datetime from string.
If there's no template matches your string, Please go
https://github.com/MacHu-GWU/rolex-project/issues
submit your datetime string. I 'll update templates ASAP.
This method is faster than :meth:`dat... | [
"def",
"_str2datetime",
"(",
"self",
",",
"datetime_str",
")",
":",
"# try default datetime template",
"try",
":",
"a_datetime",
"=",
"datetime",
".",
"strptime",
"(",
"datetime_str",
",",
"self",
".",
"_default_datetime_template",
")",
"return",
"a_datetime",
"exce... | Parse datetime from string.
If there's no template matches your string, Please go
https://github.com/MacHu-GWU/rolex-project/issues
submit your datetime string. I 'll update templates ASAP.
This method is faster than :meth:`dateutil.parser.parse`.
:param datetime_str: a string... | [
"Parse",
"datetime",
"from",
"string",
"."
] | a1111b410ed04b4b6eddd81df110fa2dacfa6537 | https://github.com/MacHu-GWU/rolex-project/blob/a1111b410ed04b4b6eddd81df110fa2dacfa6537/rolex/parse.py#L170-L216 |
38,766 | GeorgeArgyros/symautomata | symautomata/pythondfa.py | PythonDFA.define | def define(self):
"""If DFA is empty, create a sink state"""
if len(self.states) == 0:
for char in self.alphabet:
self.add_arc(0, 0, char)
self[0].final = False | python | def define(self):
"""If DFA is empty, create a sink state"""
if len(self.states) == 0:
for char in self.alphabet:
self.add_arc(0, 0, char)
self[0].final = False | [
"def",
"define",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"states",
")",
"==",
"0",
":",
"for",
"char",
"in",
"self",
".",
"alphabet",
":",
"self",
".",
"add_arc",
"(",
"0",
",",
"0",
",",
"char",
")",
"self",
"[",
"0",
"]",
".",... | If DFA is empty, create a sink state | [
"If",
"DFA",
"is",
"empty",
"create",
"a",
"sink",
"state"
] | f5d66533573b27e155bec3f36b8c00b8e3937cb3 | https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pythondfa.py#L160-L165 |
38,767 | GeorgeArgyros/symautomata | symautomata/pythondfa.py | PythonDFA.add_state | def add_state(self):
"""Adds a new state"""
sid = len(self.states)
self.states.append(DFAState(sid))
return sid | python | def add_state(self):
"""Adds a new state"""
sid = len(self.states)
self.states.append(DFAState(sid))
return sid | [
"def",
"add_state",
"(",
"self",
")",
":",
"sid",
"=",
"len",
"(",
"self",
".",
"states",
")",
"self",
".",
"states",
".",
"append",
"(",
"DFAState",
"(",
"sid",
")",
")",
"return",
"sid"
] | Adds a new state | [
"Adds",
"a",
"new",
"state"
] | f5d66533573b27e155bec3f36b8c00b8e3937cb3 | https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pythondfa.py#L167-L171 |
38,768 | GeorgeArgyros/symautomata | symautomata/pythondfa.py | PythonDFA._epsilon_closure | def _epsilon_closure(self, state):
"""
Returns the \epsilon-closure for the state given as input.
"""
closure = set([state.stateid])
stack = [state]
while True:
if not stack:
break
s = stack.pop()
for arc in s:
... | python | def _epsilon_closure(self, state):
"""
Returns the \epsilon-closure for the state given as input.
"""
closure = set([state.stateid])
stack = [state]
while True:
if not stack:
break
s = stack.pop()
for arc in s:
... | [
"def",
"_epsilon_closure",
"(",
"self",
",",
"state",
")",
":",
"closure",
"=",
"set",
"(",
"[",
"state",
".",
"stateid",
"]",
")",
"stack",
"=",
"[",
"state",
"]",
"while",
"True",
":",
"if",
"not",
"stack",
":",
"break",
"s",
"=",
"stack",
".",
... | Returns the \epsilon-closure for the state given as input. | [
"Returns",
"the",
"\\",
"epsilon",
"-",
"closure",
"for",
"the",
"state",
"given",
"as",
"input",
"."
] | f5d66533573b27e155bec3f36b8c00b8e3937cb3 | https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pythondfa.py#L426-L442 |
38,769 | GeorgeArgyros/symautomata | symautomata/pythondfa.py | PythonDFA.invert | def invert(self):
"""Inverts the DFA final states"""
for state in self.states:
if state.final:
state.final = False
else:
state.final = True | python | def invert(self):
"""Inverts the DFA final states"""
for state in self.states:
if state.final:
state.final = False
else:
state.final = True | [
"def",
"invert",
"(",
"self",
")",
":",
"for",
"state",
"in",
"self",
".",
"states",
":",
"if",
"state",
".",
"final",
":",
"state",
".",
"final",
"=",
"False",
"else",
":",
"state",
".",
"final",
"=",
"True"
] | Inverts the DFA final states | [
"Inverts",
"the",
"DFA",
"final",
"states"
] | f5d66533573b27e155bec3f36b8c00b8e3937cb3 | https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pythondfa.py#L523-L529 |
38,770 | Equitable/trump | trump/templating/converters.py | _ListConverter.as_list | def as_list(self):
"""
returns a list version of the object, based on it's attributes
"""
if hasattr(self, 'cust_list'):
return self.cust_list
if hasattr(self, 'attr_check'):
self.attr_check()
cls_bltns = set(dir(self.__class__))
r... | python | def as_list(self):
"""
returns a list version of the object, based on it's attributes
"""
if hasattr(self, 'cust_list'):
return self.cust_list
if hasattr(self, 'attr_check'):
self.attr_check()
cls_bltns = set(dir(self.__class__))
r... | [
"def",
"as_list",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'cust_list'",
")",
":",
"return",
"self",
".",
"cust_list",
"if",
"hasattr",
"(",
"self",
",",
"'attr_check'",
")",
":",
"self",
".",
"attr_check",
"(",
")",
"cls_bltns",
"=",... | returns a list version of the object, based on it's attributes | [
"returns",
"a",
"list",
"version",
"of",
"the",
"object",
"based",
"on",
"it",
"s",
"attributes"
] | a2802692bc642fa32096374159eea7ceca2947b4 | https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/templating/converters.py#L27-L37 |
38,771 | Equitable/trump | trump/templating/converters.py | _DictConverter.as_dict | def as_dict(self):
"""
returns an dict version of the object, based on it's attributes
"""
if hasattr(self, 'cust_dict'):
return self.cust_dict
if hasattr(self, 'attr_check'):
self.attr_check()
cls_bltns = set(dir(self.__class__))
... | python | def as_dict(self):
"""
returns an dict version of the object, based on it's attributes
"""
if hasattr(self, 'cust_dict'):
return self.cust_dict
if hasattr(self, 'attr_check'):
self.attr_check()
cls_bltns = set(dir(self.__class__))
... | [
"def",
"as_dict",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'cust_dict'",
")",
":",
"return",
"self",
".",
"cust_dict",
"if",
"hasattr",
"(",
"self",
",",
"'attr_check'",
")",
":",
"self",
".",
"attr_check",
"(",
")",
"cls_bltns",
"=",... | returns an dict version of the object, based on it's attributes | [
"returns",
"an",
"dict",
"version",
"of",
"the",
"object",
"based",
"on",
"it",
"s",
"attributes"
] | a2802692bc642fa32096374159eea7ceca2947b4 | https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/templating/converters.py#L46-L55 |
38,772 | Equitable/trump | trump/templating/converters.py | _OrderedDictConverter.as_odict | def as_odict(self):
"""
returns an odict version of the object, based on it's attributes
"""
if hasattr(self, 'cust_odict'):
return self.cust_odict
if hasattr(self, 'attr_check'):
self.attr_check()
odc = odict()
for attr in self.at... | python | def as_odict(self):
"""
returns an odict version of the object, based on it's attributes
"""
if hasattr(self, 'cust_odict'):
return self.cust_odict
if hasattr(self, 'attr_check'):
self.attr_check()
odc = odict()
for attr in self.at... | [
"def",
"as_odict",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'cust_odict'",
")",
":",
"return",
"self",
".",
"cust_odict",
"if",
"hasattr",
"(",
"self",
",",
"'attr_check'",
")",
":",
"self",
".",
"attr_check",
"(",
")",
"odc",
"=",
... | returns an odict version of the object, based on it's attributes | [
"returns",
"an",
"odict",
"version",
"of",
"the",
"object",
"based",
"on",
"it",
"s",
"attributes"
] | a2802692bc642fa32096374159eea7ceca2947b4 | https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/templating/converters.py#L68-L79 |
38,773 | mnkhouri/news_scraper | news_scraper/scrape.py | fetch_and_parse | def fetch_and_parse(url, bodyLines):
"""Takes a url, and returns a dictionary of data with 'bodyLines' lines"""
pageHtml = fetch_page(url)
return parse(url, pageHtml, bodyLines) | python | def fetch_and_parse(url, bodyLines):
"""Takes a url, and returns a dictionary of data with 'bodyLines' lines"""
pageHtml = fetch_page(url)
return parse(url, pageHtml, bodyLines) | [
"def",
"fetch_and_parse",
"(",
"url",
",",
"bodyLines",
")",
":",
"pageHtml",
"=",
"fetch_page",
"(",
"url",
")",
"return",
"parse",
"(",
"url",
",",
"pageHtml",
",",
"bodyLines",
")"
] | Takes a url, and returns a dictionary of data with 'bodyLines' lines | [
"Takes",
"a",
"url",
"and",
"returns",
"a",
"dictionary",
"of",
"data",
"with",
"bodyLines",
"lines"
] | 7fd3487c587281a4816f0761f0c4d2196ae05702 | https://github.com/mnkhouri/news_scraper/blob/7fd3487c587281a4816f0761f0c4d2196ae05702/news_scraper/scrape.py#L68-L72 |
38,774 | jlesquembre/termite | termite/utils.py | copy_rec | def copy_rec(source, dest):
"""Copy files between diferent directories.
Copy one or more files to an existing directory. This function is
recursive, if the source is a directory, all its subdirectories are created
in the destination. Existing files in destination are overwrited without
any warning.... | python | def copy_rec(source, dest):
"""Copy files between diferent directories.
Copy one or more files to an existing directory. This function is
recursive, if the source is a directory, all its subdirectories are created
in the destination. Existing files in destination are overwrited without
any warning.... | [
"def",
"copy_rec",
"(",
"source",
",",
"dest",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"source",
")",
":",
"for",
"child",
"in",
"os",
".",
"listdir",
"(",
"source",
")",
":",
"new_dest",
"=",
"os",
".",
"path",
".",
"join",
"(",
... | Copy files between diferent directories.
Copy one or more files to an existing directory. This function is
recursive, if the source is a directory, all its subdirectories are created
in the destination. Existing files in destination are overwrited without
any warning.
Args:
source (str): F... | [
"Copy",
"files",
"between",
"diferent",
"directories",
"."
] | fb77dcaa31872dc14dd3eeac694cd4c44aeee27b | https://github.com/jlesquembre/termite/blob/fb77dcaa31872dc14dd3eeac694cd4c44aeee27b/termite/utils.py#L31-L58 |
38,775 | bitesofcode/projex | projex/xbuild/builder.py | Builder.build | def build(self):
"""
Builds this object into the desired output information.
"""
signed = bool(self.options() & Builder.Options.Signed)
# remove previous build information
buildpath = self.buildPath()
if not buildpath:
raise errors.InvalidBuildPath(bu... | python | def build(self):
"""
Builds this object into the desired output information.
"""
signed = bool(self.options() & Builder.Options.Signed)
# remove previous build information
buildpath = self.buildPath()
if not buildpath:
raise errors.InvalidBuildPath(bu... | [
"def",
"build",
"(",
"self",
")",
":",
"signed",
"=",
"bool",
"(",
"self",
".",
"options",
"(",
")",
"&",
"Builder",
".",
"Options",
".",
"Signed",
")",
"# remove previous build information",
"buildpath",
"=",
"self",
".",
"buildPath",
"(",
")",
"if",
"n... | Builds this object into the desired output information. | [
"Builds",
"this",
"object",
"into",
"the",
"desired",
"output",
"information",
"."
] | d31743ec456a41428709968ab11a2cf6c6c76247 | https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/xbuild/builder.py#L185-L243 |
38,776 | bitesofcode/projex | projex/xbuild/builder.py | Builder.generateRevision | def generateRevision(self):
"""
Generates the revision file for this builder.
"""
revpath = self.sourcePath()
if not os.path.exists(revpath):
return
# determine the revision location
revfile = os.path.join(revpath, self.revisionFilename())
mod... | python | def generateRevision(self):
"""
Generates the revision file for this builder.
"""
revpath = self.sourcePath()
if not os.path.exists(revpath):
return
# determine the revision location
revfile = os.path.join(revpath, self.revisionFilename())
mod... | [
"def",
"generateRevision",
"(",
"self",
")",
":",
"revpath",
"=",
"self",
".",
"sourcePath",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"revpath",
")",
":",
"return",
"# determine the revision location",
"revfile",
"=",
"os",
".",
"path"... | Generates the revision file for this builder. | [
"Generates",
"the",
"revision",
"file",
"for",
"this",
"builder",
"."
] | d31743ec456a41428709968ab11a2cf6c6c76247 | https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/xbuild/builder.py#L538-L578 |
38,777 | bitesofcode/projex | projex/xbuild/builder.py | Builder.generateSetupFile | def generateSetupFile(self, outpath='.', egg=False):
"""
Generates the setup file for this builder.
"""
outpath = os.path.abspath(outpath)
outfile = os.path.join(outpath, 'setup.py')
opts = {
'name': self.name(),
'distname': self.distributionName(... | python | def generateSetupFile(self, outpath='.', egg=False):
"""
Generates the setup file for this builder.
"""
outpath = os.path.abspath(outpath)
outfile = os.path.join(outpath, 'setup.py')
opts = {
'name': self.name(),
'distname': self.distributionName(... | [
"def",
"generateSetupFile",
"(",
"self",
",",
"outpath",
"=",
"'.'",
",",
"egg",
"=",
"False",
")",
":",
"outpath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"outpath",
")",
"outfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"outpath",
",",
"'... | Generates the setup file for this builder. | [
"Generates",
"the",
"setup",
"file",
"for",
"this",
"builder",
"."
] | d31743ec456a41428709968ab11a2cf6c6c76247 | https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/xbuild/builder.py#L709-L771 |
38,778 | bitesofcode/projex | projex/xbuild/builder.py | Builder.generateZipFile | def generateZipFile(self, outpath='.'):
"""
Generates the zip file for this builder.
"""
fname = self.installName() + '.zip'
outfile = os.path.abspath(os.path.join(outpath, fname))
# clears out the exiting archive
if os.path.exists(outfile):
try:
... | python | def generateZipFile(self, outpath='.'):
"""
Generates the zip file for this builder.
"""
fname = self.installName() + '.zip'
outfile = os.path.abspath(os.path.join(outpath, fname))
# clears out the exiting archive
if os.path.exists(outfile):
try:
... | [
"def",
"generateZipFile",
"(",
"self",
",",
"outpath",
"=",
"'.'",
")",
":",
"fname",
"=",
"self",
".",
"installName",
"(",
")",
"+",
"'.zip'",
"outfile",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"outpath",
... | Generates the zip file for this builder. | [
"Generates",
"the",
"zip",
"file",
"for",
"this",
"builder",
"."
] | d31743ec456a41428709968ab11a2cf6c6c76247 | https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/xbuild/builder.py#L773-L819 |
38,779 | e7dal/bubble3 | _features_base/steps/behave_undefined_steps.py | step_undefined_step_snippets_should_exist_for_table | def step_undefined_step_snippets_should_exist_for_table(context):
"""
Checks if undefined-step snippets are provided.
EXAMPLE:
Then undefined-step snippets should exist for:
| Step |
| When an undefined step is used |
| Then another undefined step is used |
"... | python | def step_undefined_step_snippets_should_exist_for_table(context):
"""
Checks if undefined-step snippets are provided.
EXAMPLE:
Then undefined-step snippets should exist for:
| Step |
| When an undefined step is used |
| Then another undefined step is used |
"... | [
"def",
"step_undefined_step_snippets_should_exist_for_table",
"(",
"context",
")",
":",
"assert",
"context",
".",
"table",
",",
"\"REQUIRES: table\"",
"for",
"row",
"in",
"context",
".",
"table",
".",
"rows",
":",
"step",
"=",
"row",
"[",
"\"Step\"",
"]",
"step_... | Checks if undefined-step snippets are provided.
EXAMPLE:
Then undefined-step snippets should exist for:
| Step |
| When an undefined step is used |
| Then another undefined step is used | | [
"Checks",
"if",
"undefined",
"-",
"step",
"snippets",
"are",
"provided",
"."
] | 59c735281a95b44f6263a25f4d6ce24fca520082 | https://github.com/e7dal/bubble3/blob/59c735281a95b44f6263a25f4d6ce24fca520082/_features_base/steps/behave_undefined_steps.py#L71-L84 |
38,780 | e7dal/bubble3 | _features_base/steps/behave_undefined_steps.py | step_undefined_step_snippets_should_not_exist_for_table | def step_undefined_step_snippets_should_not_exist_for_table(context):
"""
Checks if undefined-step snippets are not provided.
EXAMPLE:
Then undefined-step snippets should not exist for:
| Step |
| When an known step is used |
| Then another known step is used |
... | python | def step_undefined_step_snippets_should_not_exist_for_table(context):
"""
Checks if undefined-step snippets are not provided.
EXAMPLE:
Then undefined-step snippets should not exist for:
| Step |
| When an known step is used |
| Then another known step is used |
... | [
"def",
"step_undefined_step_snippets_should_not_exist_for_table",
"(",
"context",
")",
":",
"assert",
"context",
".",
"table",
",",
"\"REQUIRES: table\"",
"for",
"row",
"in",
"context",
".",
"table",
".",
"rows",
":",
"step",
"=",
"row",
"[",
"\"Step\"",
"]",
"s... | Checks if undefined-step snippets are not provided.
EXAMPLE:
Then undefined-step snippets should not exist for:
| Step |
| When an known step is used |
| Then another known step is used | | [
"Checks",
"if",
"undefined",
"-",
"step",
"snippets",
"are",
"not",
"provided",
"."
] | 59c735281a95b44f6263a25f4d6ce24fca520082 | https://github.com/e7dal/bubble3/blob/59c735281a95b44f6263a25f4d6ce24fca520082/_features_base/steps/behave_undefined_steps.py#L88-L101 |
38,781 | andy9775/pyevent | pyevent/pyevent.py | mixin | def mixin (cls):
"""
A decorator which adds event methods to a class giving it the ability to
bind to and trigger events
:param cls: the class to add the event logic to
:type cls: class
:return: the modified class
:rtype: class
"""
cls._events = {}
cls.bind = Pyevent.bind.__func... | python | def mixin (cls):
"""
A decorator which adds event methods to a class giving it the ability to
bind to and trigger events
:param cls: the class to add the event logic to
:type cls: class
:return: the modified class
:rtype: class
"""
cls._events = {}
cls.bind = Pyevent.bind.__func... | [
"def",
"mixin",
"(",
"cls",
")",
":",
"cls",
".",
"_events",
"=",
"{",
"}",
"cls",
".",
"bind",
"=",
"Pyevent",
".",
"bind",
".",
"__func__",
"cls",
".",
"unbind",
"=",
"Pyevent",
".",
"unbind",
".",
"__func__",
"cls",
".",
"trigger",
"=",
"Pyevent... | A decorator which adds event methods to a class giving it the ability to
bind to and trigger events
:param cls: the class to add the event logic to
:type cls: class
:return: the modified class
:rtype: class | [
"A",
"decorator",
"which",
"adds",
"event",
"methods",
"to",
"a",
"class",
"giving",
"it",
"the",
"ability",
"to",
"bind",
"to",
"and",
"trigger",
"events"
] | 8ed4a4246e7af53e37114e1eeddcd9960285e1d6 | https://github.com/andy9775/pyevent/blob/8ed4a4246e7af53e37114e1eeddcd9960285e1d6/pyevent/pyevent.py#L60-L74 |
38,782 | Equitable/trump | trump/options.py | _read_options | def _read_options(paths,fname_def=None):
"""Builds a configuration reader function"""
def reader_func(fname=fname_def, sect=None, sett=None, default=None):
"""Reads the configuration for trump"""
cur_dir = os.path.dirname(os.path.realpath(__file__))
config_dir = os.path.join(cur_d... | python | def _read_options(paths,fname_def=None):
"""Builds a configuration reader function"""
def reader_func(fname=fname_def, sect=None, sett=None, default=None):
"""Reads the configuration for trump"""
cur_dir = os.path.dirname(os.path.realpath(__file__))
config_dir = os.path.join(cur_d... | [
"def",
"_read_options",
"(",
"paths",
",",
"fname_def",
"=",
"None",
")",
":",
"def",
"reader_func",
"(",
"fname",
"=",
"fname_def",
",",
"sect",
"=",
"None",
",",
"sett",
"=",
"None",
",",
"default",
"=",
"None",
")",
":",
"\"\"\"Reads the configuration f... | Builds a configuration reader function | [
"Builds",
"a",
"configuration",
"reader",
"function"
] | a2802692bc642fa32096374159eea7ceca2947b4 | https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/options.py#L27-L92 |
38,783 | hollenstein/maspy | maspy/sil.py | returnLabelState | def returnLabelState(peptide, labelDescriptor, labelSymbols=None,
labelAminoacids=None):
"""Calculates the label state of a given peptide for the label setup
described in labelDescriptor
:param peptide: peptide which label state should be calcualted
:param labelDescriptor: :class:`... | python | def returnLabelState(peptide, labelDescriptor, labelSymbols=None,
labelAminoacids=None):
"""Calculates the label state of a given peptide for the label setup
described in labelDescriptor
:param peptide: peptide which label state should be calcualted
:param labelDescriptor: :class:`... | [
"def",
"returnLabelState",
"(",
"peptide",
",",
"labelDescriptor",
",",
"labelSymbols",
"=",
"None",
",",
"labelAminoacids",
"=",
"None",
")",
":",
"if",
"labelSymbols",
"is",
"None",
":",
"labelSymbols",
"=",
"modSymbolsFromLabelInfo",
"(",
"labelDescriptor",
")"... | Calculates the label state of a given peptide for the label setup
described in labelDescriptor
:param peptide: peptide which label state should be calcualted
:param labelDescriptor: :class:`LabelDescriptor`, describes the label setup
of an experiment.
:param labelSymbols: modifications that sho... | [
"Calculates",
"the",
"label",
"state",
"of",
"a",
"given",
"peptide",
"for",
"the",
"label",
"setup",
"described",
"in",
"labelDescriptor"
] | f15fcfd24df306d8420540460d902aa3073ec133 | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/sil.py#L159-L232 |
38,784 | hollenstein/maspy | maspy/sil.py | modSymbolsFromLabelInfo | def modSymbolsFromLabelInfo(labelDescriptor):
"""Returns a set of all modiciation symbols which were used in the
labelDescriptor
:param labelDescriptor: :class:`LabelDescriptor` describes the label setup
of an experiment
:returns: #TODO: docstring
"""
modSymbols = set()
for labelSt... | python | def modSymbolsFromLabelInfo(labelDescriptor):
"""Returns a set of all modiciation symbols which were used in the
labelDescriptor
:param labelDescriptor: :class:`LabelDescriptor` describes the label setup
of an experiment
:returns: #TODO: docstring
"""
modSymbols = set()
for labelSt... | [
"def",
"modSymbolsFromLabelInfo",
"(",
"labelDescriptor",
")",
":",
"modSymbols",
"=",
"set",
"(",
")",
"for",
"labelStateEntry",
"in",
"viewvalues",
"(",
"labelDescriptor",
".",
"labels",
")",
":",
"for",
"labelPositionEntry",
"in",
"viewvalues",
"(",
"labelState... | Returns a set of all modiciation symbols which were used in the
labelDescriptor
:param labelDescriptor: :class:`LabelDescriptor` describes the label setup
of an experiment
:returns: #TODO: docstring | [
"Returns",
"a",
"set",
"of",
"all",
"modiciation",
"symbols",
"which",
"were",
"used",
"in",
"the",
"labelDescriptor"
] | f15fcfd24df306d8420540460d902aa3073ec133 | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/sil.py#L235-L250 |
38,785 | hollenstein/maspy | maspy/sil.py | modAminoacidsFromLabelInfo | def modAminoacidsFromLabelInfo(labelDescriptor):
"""Returns a set of all amino acids and termini which can bear a label, as
described in "labelDescriptor".
:param labelDescriptor: :class:`LabelDescriptor` describes the label setup
of an experiment
:returns: #TODO: docstring
"""
modAmin... | python | def modAminoacidsFromLabelInfo(labelDescriptor):
"""Returns a set of all amino acids and termini which can bear a label, as
described in "labelDescriptor".
:param labelDescriptor: :class:`LabelDescriptor` describes the label setup
of an experiment
:returns: #TODO: docstring
"""
modAmin... | [
"def",
"modAminoacidsFromLabelInfo",
"(",
"labelDescriptor",
")",
":",
"modAminoacids",
"=",
"set",
"(",
")",
"for",
"labelStateEntry",
"in",
"viewvalues",
"(",
"labelDescriptor",
".",
"labels",
")",
":",
"for",
"labelPositionEntry",
"in",
"viewkeys",
"(",
"labelS... | Returns a set of all amino acids and termini which can bear a label, as
described in "labelDescriptor".
:param labelDescriptor: :class:`LabelDescriptor` describes the label setup
of an experiment
:returns: #TODO: docstring | [
"Returns",
"a",
"set",
"of",
"all",
"amino",
"acids",
"and",
"termini",
"which",
"can",
"bear",
"a",
"label",
"as",
"described",
"in",
"labelDescriptor",
"."
] | f15fcfd24df306d8420540460d902aa3073ec133 | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/sil.py#L253-L268 |
38,786 | hollenstein/maspy | maspy/sil.py | expectedLabelPosition | def expectedLabelPosition(peptide, labelStateInfo, sequence=None,
modPositions=None):
"""Returns a modification description of a certain label state of a peptide.
:param peptide: Peptide sequence used to calculat the expected label state
modifications
:param labelStateInfo... | python | def expectedLabelPosition(peptide, labelStateInfo, sequence=None,
modPositions=None):
"""Returns a modification description of a certain label state of a peptide.
:param peptide: Peptide sequence used to calculat the expected label state
modifications
:param labelStateInfo... | [
"def",
"expectedLabelPosition",
"(",
"peptide",
",",
"labelStateInfo",
",",
"sequence",
"=",
"None",
",",
"modPositions",
"=",
"None",
")",
":",
"if",
"modPositions",
"is",
"None",
":",
"modPositions",
"=",
"maspy",
".",
"peptidemethods",
".",
"returnModPosition... | Returns a modification description of a certain label state of a peptide.
:param peptide: Peptide sequence used to calculat the expected label state
modifications
:param labelStateInfo: An entry of :attr:`LabelDescriptor.labels` that
describes a label state
:param sequence: unmodified amino... | [
"Returns",
"a",
"modification",
"description",
"of",
"a",
"certain",
"label",
"state",
"of",
"a",
"peptide",
"."
] | f15fcfd24df306d8420540460d902aa3073ec133 | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/sil.py#L271-L327 |
38,787 | hollenstein/maspy | maspy/sil.py | LabelDescriptor.addLabel | def addLabel(self, aminoAcidLabels, excludingModifications=None):
"""Adds a new labelstate.
:param aminoAcidsLabels: Describes which amino acids can bear which
labels. Possible keys are the amino acids in one letter code and
'nTerm', 'cTerm'. Possible values are the modification... | python | def addLabel(self, aminoAcidLabels, excludingModifications=None):
"""Adds a new labelstate.
:param aminoAcidsLabels: Describes which amino acids can bear which
labels. Possible keys are the amino acids in one letter code and
'nTerm', 'cTerm'. Possible values are the modification... | [
"def",
"addLabel",
"(",
"self",
",",
"aminoAcidLabels",
",",
"excludingModifications",
"=",
"None",
")",
":",
"if",
"excludingModifications",
"is",
"not",
"None",
":",
"self",
".",
"excludingModifictions",
"=",
"True",
"labelEntry",
"=",
"{",
"'aminoAcidLabels'",
... | Adds a new labelstate.
:param aminoAcidsLabels: Describes which amino acids can bear which
labels. Possible keys are the amino acids in one letter code and
'nTerm', 'cTerm'. Possible values are the modifications ids from
:attr:`maspy.constants.aaModMass` as strings or a list... | [
"Adds",
"a",
"new",
"labelstate",
"."
] | f15fcfd24df306d8420540460d902aa3073ec133 | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/sil.py#L61-L88 |
38,788 | e7dal/bubble3 | bubble3/util/generators.py | get_gen_slice | def get_gen_slice(ctx=Bubble(), iterable=[], amount=-1, index=-1):
"""very crude way of slicing a generator"""
ctx.gbc.say('get_gen_slice', stuff=iterable, verbosity=10)
i = -1
# TODO
# i = 0 #NATURAL INDEX, this will break all features with exports and -p
if amount > 0:
if index < 0:
... | python | def get_gen_slice(ctx=Bubble(), iterable=[], amount=-1, index=-1):
"""very crude way of slicing a generator"""
ctx.gbc.say('get_gen_slice', stuff=iterable, verbosity=10)
i = -1
# TODO
# i = 0 #NATURAL INDEX, this will break all features with exports and -p
if amount > 0:
if index < 0:
... | [
"def",
"get_gen_slice",
"(",
"ctx",
"=",
"Bubble",
"(",
")",
",",
"iterable",
"=",
"[",
"]",
",",
"amount",
"=",
"-",
"1",
",",
"index",
"=",
"-",
"1",
")",
":",
"ctx",
".",
"gbc",
".",
"say",
"(",
"'get_gen_slice'",
",",
"stuff",
"=",
"iterable"... | very crude way of slicing a generator | [
"very",
"crude",
"way",
"of",
"slicing",
"a",
"generator"
] | 59c735281a95b44f6263a25f4d6ce24fca520082 | https://github.com/e7dal/bubble3/blob/59c735281a95b44f6263a25f4d6ce24fca520082/bubble3/util/generators.py#L35-L78 |
38,789 | sparknetworks/pgpm | pgpm/lib/deploy.py | DeploymentManager._get_scripts | def _get_scripts(self, scripts_path_rel, files_deployment, script_type, project_path):
"""
Gets scripts from specified folders
"""
scripts_dict = {}
if scripts_path_rel:
self._logger.debug('Getting scripts with {0} definitions'.format(script_type))
scrip... | python | def _get_scripts(self, scripts_path_rel, files_deployment, script_type, project_path):
"""
Gets scripts from specified folders
"""
scripts_dict = {}
if scripts_path_rel:
self._logger.debug('Getting scripts with {0} definitions'.format(script_type))
scrip... | [
"def",
"_get_scripts",
"(",
"self",
",",
"scripts_path_rel",
",",
"files_deployment",
",",
"script_type",
",",
"project_path",
")",
":",
"scripts_dict",
"=",
"{",
"}",
"if",
"scripts_path_rel",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"'Getting scripts wi... | Gets scripts from specified folders | [
"Gets",
"scripts",
"from",
"specified",
"folders"
] | 1a060df46a886095181f692ea870a73a32510a2e | https://github.com/sparknetworks/pgpm/blob/1a060df46a886095181f692ea870a73a32510a2e/pgpm/lib/deploy.py#L467-L483 |
38,790 | sparknetworks/pgpm | pgpm/lib/deploy.py | DeploymentManager._resolve_dependencies | def _resolve_dependencies(self, cur, dependencies):
"""
Function checks if dependant packages are installed in DB
"""
list_of_deps_ids = []
_list_of_deps_unresolved = []
_is_deps_resolved = True
for k, v in dependencies.items():
pgpm.lib.utils.db.SqlSc... | python | def _resolve_dependencies(self, cur, dependencies):
"""
Function checks if dependant packages are installed in DB
"""
list_of_deps_ids = []
_list_of_deps_unresolved = []
_is_deps_resolved = True
for k, v in dependencies.items():
pgpm.lib.utils.db.SqlSc... | [
"def",
"_resolve_dependencies",
"(",
"self",
",",
"cur",
",",
"dependencies",
")",
":",
"list_of_deps_ids",
"=",
"[",
"]",
"_list_of_deps_unresolved",
"=",
"[",
"]",
"_is_deps_resolved",
"=",
"True",
"for",
"k",
",",
"v",
"in",
"dependencies",
".",
"items",
... | Function checks if dependant packages are installed in DB | [
"Function",
"checks",
"if",
"dependant",
"packages",
"are",
"installed",
"in",
"DB"
] | 1a060df46a886095181f692ea870a73a32510a2e | https://github.com/sparknetworks/pgpm/blob/1a060df46a886095181f692ea870a73a32510a2e/pgpm/lib/deploy.py#L485-L505 |
38,791 | sparknetworks/pgpm | pgpm/lib/deploy.py | DeploymentManager._reorder_types | def _reorder_types(self, types_script):
"""
Takes type scripts and reorders them to avoid Type doesn't exist exception
"""
self._logger.debug('Running types definitions scripts')
self._logger.debug('Reordering types definitions scripts to avoid "type does not exist" exceptions')
... | python | def _reorder_types(self, types_script):
"""
Takes type scripts and reorders them to avoid Type doesn't exist exception
"""
self._logger.debug('Running types definitions scripts')
self._logger.debug('Reordering types definitions scripts to avoid "type does not exist" exceptions')
... | [
"def",
"_reorder_types",
"(",
"self",
",",
"types_script",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"'Running types definitions scripts'",
")",
"self",
".",
"_logger",
".",
"debug",
"(",
"'Reordering types definitions scripts to avoid \"type does not exist\" e... | Takes type scripts and reorders them to avoid Type doesn't exist exception | [
"Takes",
"type",
"scripts",
"and",
"reorders",
"them",
"to",
"avoid",
"Type",
"doesn",
"t",
"exist",
"exception"
] | 1a060df46a886095181f692ea870a73a32510a2e | https://github.com/sparknetworks/pgpm/blob/1a060df46a886095181f692ea870a73a32510a2e/pgpm/lib/deploy.py#L507-L568 |
38,792 | codeforamerica/epa_python | scrape_definitions.py | Scraper.find_table_links | def find_table_links(self):
"""
When given a url, this function will find all the available table names
for that EPA dataset.
"""
html = urlopen(self.model_url).read()
doc = lh.fromstring(html)
href_list = [area.attrib['href'] for area in doc.cssselect('map area')... | python | def find_table_links(self):
"""
When given a url, this function will find all the available table names
for that EPA dataset.
"""
html = urlopen(self.model_url).read()
doc = lh.fromstring(html)
href_list = [area.attrib['href'] for area in doc.cssselect('map area')... | [
"def",
"find_table_links",
"(",
"self",
")",
":",
"html",
"=",
"urlopen",
"(",
"self",
".",
"model_url",
")",
".",
"read",
"(",
")",
"doc",
"=",
"lh",
".",
"fromstring",
"(",
"html",
")",
"href_list",
"=",
"[",
"area",
".",
"attrib",
"[",
"'href'",
... | When given a url, this function will find all the available table names
for that EPA dataset. | [
"When",
"given",
"a",
"url",
"this",
"function",
"will",
"find",
"all",
"the",
"available",
"table",
"names",
"for",
"that",
"EPA",
"dataset",
"."
] | 62a53da62936bea8daa487a01a52b973e9062b2c | https://github.com/codeforamerica/epa_python/blob/62a53da62936bea8daa487a01a52b973e9062b2c/scrape_definitions.py#L37-L46 |
38,793 | codeforamerica/epa_python | scrape_definitions.py | Scraper.find_definition_urls | def find_definition_urls(self, set_of_links):
"""Find the available definition URLs for the columns in a table."""
definition_dict = {}
re_link_name = re.compile('.*p_table_name=(\w+)&p_topic.*')
for link in set_of_links:
if link.startswith('http://'):
table_d... | python | def find_definition_urls(self, set_of_links):
"""Find the available definition URLs for the columns in a table."""
definition_dict = {}
re_link_name = re.compile('.*p_table_name=(\w+)&p_topic.*')
for link in set_of_links:
if link.startswith('http://'):
table_d... | [
"def",
"find_definition_urls",
"(",
"self",
",",
"set_of_links",
")",
":",
"definition_dict",
"=",
"{",
"}",
"re_link_name",
"=",
"re",
".",
"compile",
"(",
"'.*p_table_name=(\\w+)&p_topic.*'",
")",
"for",
"link",
"in",
"set_of_links",
":",
"if",
"link",
".",
... | Find the available definition URLs for the columns in a table. | [
"Find",
"the",
"available",
"definition",
"URLs",
"for",
"the",
"columns",
"in",
"a",
"table",
"."
] | 62a53da62936bea8daa487a01a52b973e9062b2c | https://github.com/codeforamerica/epa_python/blob/62a53da62936bea8daa487a01a52b973e9062b2c/scrape_definitions.py#L69-L84 |
38,794 | codeforamerica/epa_python | scrape_definitions.py | Scraper.create_agency | def create_agency(self):
"""Create an agency text file of definitions."""
agency = self.agency
links = self.find_table_links()
definition_dict = self.find_definition_urls(links)
with open(agency + '.txt', 'w') as f:
f.write(str(definition_dict)) | python | def create_agency(self):
"""Create an agency text file of definitions."""
agency = self.agency
links = self.find_table_links()
definition_dict = self.find_definition_urls(links)
with open(agency + '.txt', 'w') as f:
f.write(str(definition_dict)) | [
"def",
"create_agency",
"(",
"self",
")",
":",
"agency",
"=",
"self",
".",
"agency",
"links",
"=",
"self",
".",
"find_table_links",
"(",
")",
"definition_dict",
"=",
"self",
".",
"find_definition_urls",
"(",
"links",
")",
"with",
"open",
"(",
"agency",
"+"... | Create an agency text file of definitions. | [
"Create",
"an",
"agency",
"text",
"file",
"of",
"definitions",
"."
] | 62a53da62936bea8daa487a01a52b973e9062b2c | https://github.com/codeforamerica/epa_python/blob/62a53da62936bea8daa487a01a52b973e9062b2c/scrape_definitions.py#L86-L92 |
38,795 | codeforamerica/epa_python | scrape_definitions.py | Scraper.loop_through_agency | def loop_through_agency(self):
"""Loop through an agency to grab the definitions for its tables."""
agency = self.agency
with open(agency + '.txt') as f:
data = eval(f.read())
for table in data:
for column in data[table]:
value_link = data[table][c... | python | def loop_through_agency(self):
"""Loop through an agency to grab the definitions for its tables."""
agency = self.agency
with open(agency + '.txt') as f:
data = eval(f.read())
for table in data:
for column in data[table]:
value_link = data[table][c... | [
"def",
"loop_through_agency",
"(",
"self",
")",
":",
"agency",
"=",
"self",
".",
"agency",
"with",
"open",
"(",
"agency",
"+",
"'.txt'",
")",
"as",
"f",
":",
"data",
"=",
"eval",
"(",
"f",
".",
"read",
"(",
")",
")",
"for",
"table",
"in",
"data",
... | Loop through an agency to grab the definitions for its tables. | [
"Loop",
"through",
"an",
"agency",
"to",
"grab",
"the",
"definitions",
"for",
"its",
"tables",
"."
] | 62a53da62936bea8daa487a01a52b973e9062b2c | https://github.com/codeforamerica/epa_python/blob/62a53da62936bea8daa487a01a52b973e9062b2c/scrape_definitions.py#L94-L105 |
38,796 | codeforamerica/epa_python | scrape_definitions.py | Scraper.grab_definition | def grab_definition(self, url):
"""
Grab the column definition of a table from the EPA using a combination
of regular expressions and lxml.
"""
re_description = re.compile('Description:(.+?\\n)')
re_table_name = re.compile("(\w+ Table.+)")
if url.startswith('//'):... | python | def grab_definition(self, url):
"""
Grab the column definition of a table from the EPA using a combination
of regular expressions and lxml.
"""
re_description = re.compile('Description:(.+?\\n)')
re_table_name = re.compile("(\w+ Table.+)")
if url.startswith('//'):... | [
"def",
"grab_definition",
"(",
"self",
",",
"url",
")",
":",
"re_description",
"=",
"re",
".",
"compile",
"(",
"'Description:(.+?\\\\n)'",
")",
"re_table_name",
"=",
"re",
".",
"compile",
"(",
"\"(\\w+ Table.+)\"",
")",
"if",
"url",
".",
"startswith",
"(",
"... | Grab the column definition of a table from the EPA using a combination
of regular expressions and lxml. | [
"Grab",
"the",
"column",
"definition",
"of",
"a",
"table",
"from",
"the",
"EPA",
"using",
"a",
"combination",
"of",
"regular",
"expressions",
"and",
"lxml",
"."
] | 62a53da62936bea8daa487a01a52b973e9062b2c | https://github.com/codeforamerica/epa_python/blob/62a53da62936bea8daa487a01a52b973e9062b2c/scrape_definitions.py#L107-L129 |
38,797 | nicferrier/md | src/mdlib/cli.py | main | def main(*argv,
filesystem=None,
do_exit=True,
stdout=None,
stderr=None):
"""Main method for the cli.
We allow the filesystem to be overridden for test purposes."""
try:
mdcli = MdCLI()
mdcli.filesystem = filesystem
mdcli.stdout = stdout or ... | python | def main(*argv,
filesystem=None,
do_exit=True,
stdout=None,
stderr=None):
"""Main method for the cli.
We allow the filesystem to be overridden for test purposes."""
try:
mdcli = MdCLI()
mdcli.filesystem = filesystem
mdcli.stdout = stdout or ... | [
"def",
"main",
"(",
"*",
"argv",
",",
"filesystem",
"=",
"None",
",",
"do_exit",
"=",
"True",
",",
"stdout",
"=",
"None",
",",
"stderr",
"=",
"None",
")",
":",
"try",
":",
"mdcli",
"=",
"MdCLI",
"(",
")",
"mdcli",
".",
"filesystem",
"=",
"filesyste... | Main method for the cli.
We allow the filesystem to be overridden for test purposes. | [
"Main",
"method",
"for",
"the",
"cli",
"."
] | 302ca8882dae060fb15bd5ae470d8e661fb67ec4 | https://github.com/nicferrier/md/blob/302ca8882dae060fb15bd5ae470d8e661fb67ec4/src/mdlib/cli.py#L361-L380 |
38,798 | nicferrier/md | src/mdlib/cli.py | MdCLI.get_optparser | def get_optparser(self):
"""Override to allow specification of the maildir"""
p = Cmdln.get_optparser(self)
p.add_option(
"-M",
"--maildir",
action="store",
dest="maildir"
)
p.add_option(
"-V",
"--verbose... | python | def get_optparser(self):
"""Override to allow specification of the maildir"""
p = Cmdln.get_optparser(self)
p.add_option(
"-M",
"--maildir",
action="store",
dest="maildir"
)
p.add_option(
"-V",
"--verbose... | [
"def",
"get_optparser",
"(",
"self",
")",
":",
"p",
"=",
"Cmdln",
".",
"get_optparser",
"(",
"self",
")",
"p",
".",
"add_option",
"(",
"\"-M\"",
",",
"\"--maildir\"",
",",
"action",
"=",
"\"store\"",
",",
"dest",
"=",
"\"maildir\"",
")",
"p",
".",
"add... | Override to allow specification of the maildir | [
"Override",
"to",
"allow",
"specification",
"of",
"the",
"maildir"
] | 302ca8882dae060fb15bd5ae470d8e661fb67ec4 | https://github.com/nicferrier/md/blob/302ca8882dae060fb15bd5ae470d8e661fb67ec4/src/mdlib/cli.py#L62-L77 |
38,799 | stephrdev/django-tapeforms | tapeforms/templatetags/tapeforms.py | form | def form(context, form, **kwargs):
"""
The `form` template tag will render a tape-form enabled form using the template
provided by `get_layout_template` method of the form using the context generated
by `get_layout_context` method of the form.
Usage::
{% load tapeforms %}
{% form m... | python | def form(context, form, **kwargs):
"""
The `form` template tag will render a tape-form enabled form using the template
provided by `get_layout_template` method of the form using the context generated
by `get_layout_context` method of the form.
Usage::
{% load tapeforms %}
{% form m... | [
"def",
"form",
"(",
"context",
",",
"form",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"form",
",",
"(",
"forms",
".",
"BaseForm",
",",
"TapeformFieldset",
")",
")",
":",
"raise",
"template",
".",
"TemplateSyntaxError",
"(",
"'P... | The `form` template tag will render a tape-form enabled form using the template
provided by `get_layout_template` method of the form using the context generated
by `get_layout_context` method of the form.
Usage::
{% load tapeforms %}
{% form my_form %}
You can override the used layout... | [
"The",
"form",
"template",
"tag",
"will",
"render",
"a",
"tape",
"-",
"form",
"enabled",
"form",
"using",
"the",
"template",
"provided",
"by",
"get_layout_template",
"method",
"of",
"the",
"form",
"using",
"the",
"context",
"generated",
"by",
"get_layout_context... | 255602de43777141f18afaf30669d7bdd4f7c323 | https://github.com/stephrdev/django-tapeforms/blob/255602de43777141f18afaf30669d7bdd4f7c323/tapeforms/templatetags/tapeforms.py#L11-L39 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.