function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def validate_default(self, value):
"""Validate default value assigned to field.
Args:
value: Value to validate.
Returns:
the value in casted in the correct type.
Raises:
ValidationError if value is not expected type.
"""
return self.__vali... | catapult-project/catapult | [
1835,
570,
1835,
1039,
1429033745
] |
def default(self):
"""Get default value for field."""
return self.__default | catapult-project/catapult | [
1835,
570,
1835,
1039,
1429033745
] |
def lookup_field_type_by_variant(cls, variant):
return cls.__variant_to_type[variant] | catapult-project/catapult | [
1835,
570,
1835,
1039,
1429033745
] |
def validate_element(self, value):
"""Validate StringField allowing for str and unicode.
Raises:
ValidationError if a str value is not UTF-8.
"""
# If value is str is it considered valid. Satisfies "required=True".
if isinstance(value, bytes):
try:
... | catapult-project/catapult | [
1835,
570,
1835,
1039,
1429033745
] |
def __init__(self,
message_type,
number,
required=False,
repeated=False,
variant=None):
"""Constructor.
Args:
message_type: Message type for field. Must be subclass of Message.
number: Number of fi... | catapult-project/catapult | [
1835,
570,
1835,
1039,
1429033745
] |
def type(self):
"""Message type used for field."""
if self.__type is None:
message_type = find_definition(
self.__type_name, self.message_definition())
if not (message_type is not Message and
isinstance(message_type, type) and
... | catapult-project/catapult | [
1835,
570,
1835,
1039,
1429033745
] |
def message_type(self):
"""Underlying message type used for serialization.
Will always be a sub-class of Message. This is different from type
which represents the python value that message_type is mapped to for
use by the user.
"""
return self.type | catapult-project/catapult | [
1835,
570,
1835,
1039,
1429033745
] |
def value_to_message(self, value):
"""Convert a value instance to a message.
Used by serializers to convert Python user types to underlying
messages for transmission.
Args:
value: A value of type self.type.
Returns:
An instance of type self.message_type.
... | catapult-project/catapult | [
1835,
570,
1835,
1039,
1429033745
] |
def __init__(self, enum_type, number, **kwargs):
"""Constructor.
Args:
enum_type: Enum type for field. Must be subclass of Enum.
number: Number of field. Must be unique per message class.
required: Whether or not field is required. Mutually exclusive to
'rep... | catapult-project/catapult | [
1835,
570,
1835,
1039,
1429033745
] |
def type(self):
"""Enum type used for field."""
if self.__type is None:
found_type = find_definition(
self.__type_name, self.message_definition())
if not (found_type is not Enum and
isinstance(found_type, type) and
issubclas... | catapult-project/catapult | [
1835,
570,
1835,
1039,
1429033745
] |
def default(self):
"""Default for enum field.
Will cause resolution of Enum type and unresolved default value.
"""
try:
return self.__resolved_default
except AttributeError:
resolved_default = super(EnumField, self).default
if isinstance(resol... | catapult-project/catapult | [
1835,
570,
1835,
1039,
1429033745
] |
def plural(word, pos=NOUN, classical=True, custom={}):
""" Returns the plural of a given word. | RensaProject/nodebox_linguistics_extended | [
2,
11,
2,
1,
1479284521
] |
def noun_plural(word, classical=True, custom={}):
return plural(word, NOUN, classical, custom) | RensaProject/nodebox_linguistics_extended | [
2,
11,
2,
1,
1479284521
] |
def create(self, cr, uid, vals, context=None):
vals_reformated = self._generic_reformat_phonenumbers(
cr, uid, None, vals, context=context)
return super(CrmLead, self).create(
cr, uid, vals_reformated, context=context) | cgstudiomap/cgstudiomap | [
3,
2,
3,
45,
1427859918
] |
def name_get(self, cr, uid, ids, context=None):
if context is None:
context = {}
if context.get('callerid'):
res = []
if isinstance(ids, (int, long)):
ids = [ids]
for lead in self.browse(cr, uid, ids, context=context):
if le... | cgstudiomap/cgstudiomap | [
3,
2,
3,
45,
1427859918
] |
def create(self, cr, uid, vals, context=None):
vals_reformated = self._generic_reformat_phonenumbers(
cr, uid, None, vals, context=context)
return super(CrmPhonecall, self).create(
cr, uid, vals_reformated, context=context) | cgstudiomap/cgstudiomap | [
3,
2,
3,
45,
1427859918
] |
def testNumber(self):
"""Verifies basic behavior of ee.Number."""
num = ee.Number(1)
self.assertEquals(1, num.encode())
computed = ee.Number(1).add(2)
self.assertTrue(isinstance(computed, ee.Number))
self.assertEquals(ee.ApiFunction.lookup('Number.add'), computed.func)
self.assertEquals({'l... | mortcanty/earthengine | [
127,
52,
127,
4,
1487864153
] |
def _call_if_exists(parent, attr):
func = getattr(parent, attr, lambda: None)
func() | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def __init__(self, tests=()):
self._tests = []
self._removed_tests = 0
self.addTests(tests) | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def __eq__(self, other):
if not isinstance(other, self.__class__):
return NotImplemented
return list(self) == list(other) | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def countTestCases(self):
cases = self._removed_tests
for test in self:
if test:
cases += test.countTestCases()
return cases | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def addTests(self, tests):
if isinstance(tests, str):
raise TypeError("tests must be an iterable of tests, not a string")
for test in tests:
self.addTest(test) | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def _removeTestAtIndex(self, index):
"""Stop holding a reference to the TestCase at index."""
try:
test = self._tests[index]
except TypeError:
# support for suite implementations that have overriden self._tests
pass
else:
# Some unittest te... | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def debug(self):
"""Run the tests without collecting errors in a TestResult"""
for test in self:
test.debug() | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def run(self, result, debug=False):
topLevel = False
if getattr(result, '_testRunEntered', False) is False:
result._testRunEntered = topLevel = True
for index, test in enumerate(self):
if result.shouldStop:
break
if _isnotsuite(test):
... | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def _handleClassSetUp(self, test, result):
previousClass = getattr(result, '_previousTestClass', None)
currentClass = test.__class__
if currentClass == previousClass:
return
if result._moduleSetUpFailed:
return
if getattr(currentClass, "__unittest_skip__",... | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def _handleModuleFixture(self, test, result):
previousModule = self._get_previous_module(result)
currentModule = test.__class__.__module__
if currentModule == previousModule:
return
self._handleModuleTearDown(result)
result._moduleSetUpFailed = False
try:
... | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def _handleModuleTearDown(self, result):
previousModule = self._get_previous_module(result)
if previousModule is None:
return
if result._moduleSetUpFailed:
return
try:
module = sys.modules[previousModule]
except KeyError:
return
... | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def __init__(self, description):
self.description = description | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def shortDescription(self):
return None | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def __str__(self):
return self.id() | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def __call__(self, result):
return self.run(result) | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def _isnotsuite(test):
"A crude way to tell apart testcases and suites with duck-typing"
try:
iter(test)
except TypeError:
return True
return False | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def get_lastrowid(self):
return self.cursor.lastrowid | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def visit_mod_binary(self, binary, operator, **kw):
if self.dialect._mysqlconnector_double_percents:
return self.process(binary.left, **kw) + " %% " + \
self.process(binary.right, **kw)
else:
return self.process(binary.left, **kw) + " % " + \
self.... | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def escape_literal_column(self, text):
if self.dialect._mysqlconnector_double_percents:
return text.replace('%', '%%')
else:
return text | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def _escape_identifier(self, value):
value = value.replace(self.escape_quote, self.escape_to_quote)
if self.dialect._mysqlconnector_double_percents:
return value.replace("%", "%%")
else:
return value | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def result_processor(self, dialect, coltype):
"""MySQL-connector already converts mysql bits, so."""
return None | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def supports_unicode_statements(self):
return util.py3k or self._mysqlconnector_version_info > (2, 0) | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def dbapi(cls):
from mysql import connector
return connector | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def _mysqlconnector_version_info(self):
if self.dbapi and hasattr(self.dbapi, '__version__'):
m = re.match(r'(\d+)\.(\d+)(?:\.(\d+))?',
self.dbapi.__version__)
if m:
return tuple(
int(x)
for x in m.group(1, ... | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def _mysqlconnector_double_percents(self):
return not util.py3k and self._mysqlconnector_version_info < (2, 0) | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def _detect_charset(self, connection):
return connection.connection.charset | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def is_disconnect(self, e, connection, cursor):
errnos = (2006, 2013, 2014, 2045, 2055, 2048)
exceptions = (self.dbapi.OperationalError, self.dbapi.InterfaceError)
if isinstance(e, exceptions):
return e.errno in errnos or \
"MySQL Connection not available." in str(e)
... | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def _compat_fetchone(self, rp, charset=None):
return rp.fetchone() | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def get_sandbox_env(env):
"""Returns the environment flags needed for the SUID sandbox to work."""
extra_env = {}
chrome_sandbox_path = env.get(CHROME_SANDBOX_ENV, CHROME_SANDBOX_PATH)
# The above would silently disable the SUID sandbox if the env value were
# an empty string. We don't want to allow that. htt... | Teamxrtc/webrtc-streaming-node | [
6,
5,
6,
2,
1449773735
] |
def fix_python_path(cmd):
"""Returns the fixed command line to call the right python executable."""
out = cmd[:]
if out[0] == 'python':
out[0] = sys.executable
elif out[0].endswith('.py'):
out.insert(0, sys.executable)
return out | Teamxrtc/webrtc-streaming-node | [
6,
5,
6,
2,
1449773735
] |
def get_sanitizer_symbolize_command(json_path=None, executable_path=None):
"""Construct the command to invoke offline symbolization script."""
script_path = '../tools/valgrind/asan/asan_symbolize.py'
cmd = [sys.executable, script_path]
if json_path is not None:
cmd.append('--test-summary-json-file=%s' % jso... | Teamxrtc/webrtc-streaming-node | [
6,
5,
6,
2,
1449773735
] |
def symbolize_snippets_in_json(cmd, env):
"""Symbolize output snippets inside the JSON test summary."""
json_path = get_json_path(cmd)
if json_path is None:
return
try:
symbolize_command = get_sanitizer_symbolize_command(
json_path=json_path, executable_path=cmd[0])
p = subprocess.Popen(sym... | Teamxrtc/webrtc-streaming-node | [
6,
5,
6,
2,
1449773735
] |
def main():
return run_executable(sys.argv[1:], os.environ.copy()) | Teamxrtc/webrtc-streaming-node | [
6,
5,
6,
2,
1449773735
] |
def package_installed(module, name, category):
cmd = [module.get_bin_path('pkginfo', True)]
cmd.append('-q')
if category:
cmd.append('-c')
cmd.append(name)
rc, out, err = module.run_command(' '.join(cmd))
if rc == 0:
return True
else:
return False | mattbernst/polyhartree | [
4,
1,
4,
7,
1379927298
] |
def run_command(module, cmd):
progname = cmd[0]
cmd[0] = module.get_bin_path(progname, True)
return module.run_command(cmd) | mattbernst/polyhartree | [
4,
1,
4,
7,
1379927298
] |
def package_uninstall(module, name, src, category):
adminfile = create_admin_file()
if category:
cmd = [ 'pkgrm', '-na', adminfile, '-Y', name ]
else:
cmd = [ 'pkgrm', '-na', adminfile, name]
(rc, out, err) = run_command(module, cmd)
os.unlink(adminfile)
return (rc, out, err) | mattbernst/polyhartree | [
4,
1,
4,
7,
1379927298
] |
def AddBuildTypeOption(option_parser):
"""Decorates OptionParser with build type option."""
default_build_type = 'Debug'
if 'BUILDTYPE' in os.environ:
default_build_type = os.environ['BUILDTYPE']
option_parser.add_option('--debug', action='store_const', const='Debug',
dest='build_... | hugegreenbug/libgestures | [
14,
10,
14,
7,
1391194004
] |
def _npSoftplus(self, np_features):
np_features = np.asarray(np_features)
zero = np.asarray(0).astype(np_features.dtype)
return np.logaddexp(zero, np_features) | npuichigo/ttsflow | [
16,
6,
16,
1,
1500635633
] |
def testNumbers(self):
for t in [np.float16, np.float32, np.float64]:
self._testSoftplus(
np.array([[-9, 7, -5, 3, -1], [1, -3, 5, -7, 9]]).astype(t),
use_gpu=False)
self._testSoftplus(
np.array([[-9, 7, -5, 3, -1], [1, -3, 5, -7, 9]]).astype(t),
use_gpu=True)
... | npuichigo/ttsflow | [
16,
6,
16,
1,
1500635633
] |
def testGradGrad(self):
with self.test_session():
x = constant_op.constant(
[-0.9, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.7, 0.9],
shape=[2, 5],
name="x")
y = nn_ops.softplus(x, name="softplus")
(grad,) = gradients_impl.gradients(y, x)
x_init = np.asarray(
... | npuichigo/ttsflow | [
16,
6,
16,
1,
1500635633
] |
def testWarnInts(self):
# Running the op triggers address sanitizer errors, so we just make it
nn_ops.softplus(constant_op.constant(7)) | npuichigo/ttsflow | [
16,
6,
16,
1,
1500635633
] |
def testStringToOneHashBucketFast(self):
with self.test_session():
input_string = array_ops.placeholder(dtypes.string)
output = string_ops.string_to_hash_bucket_fast(input_string, 1)
result = output.eval(feed_dict={input_string: ['a', 'b', 'c']})
self.assertAllEqual([0, 0, 0], result) | npuichigo/ttsflow | [
16,
6,
16,
1,
1500635633
] |
def testStringToOneHashBucketLegacyHash(self):
with self.test_session():
input_string = array_ops.placeholder(dtypes.string)
output = string_ops.string_to_hash_bucket(input_string, 1)
result = output.eval(feed_dict={input_string: ['a', 'b', 'c']})
self.assertAllEqual([0, 0, 0], result) | npuichigo/ttsflow | [
16,
6,
16,
1,
1500635633
] |
def testStringToOneHashBucketStrongOneHashBucket(self):
with self.test_session():
input_string = constant_op.constant(['a', 'b', 'c'])
output = string_ops.string_to_hash_bucket_strong(
input_string, 1, key=[123, 345])
self.assertAllEqual([0, 0, 0], output.eval()) | npuichigo/ttsflow | [
16,
6,
16,
1,
1500635633
] |
def testStringToHashBucketsStrongInvalidKey(self):
with self.test_session():
input_string = constant_op.constant(['a', 'b', 'c'])
with self.assertRaisesOpError('Key must have 2 elements'):
string_ops.string_to_hash_bucket_strong(
input_string, 10, key=[98765]).eval() | npuichigo/ttsflow | [
16,
6,
16,
1,
1500635633
] |
def __init__(self, t, name, unprinted_runtime=False):
self.t = t
self.name = name
self.start = None
self.unprinted_runtime = unprinted_runtime | SymbiFlow/fpga-tool-perf | [
78,
23,
78,
85,
1529693672
] |
def __exit__(self, type, value, traceback):
end = time.time()
self.t.add_runtime(
self.name,
end - self.start,
unprinted_runtime=self.unprinted_runtime
) | SymbiFlow/fpga-tool-perf | [
78,
23,
78,
85,
1529693672
] |
def get_yosys_resources(yosys_log):
with open(yosys_log, "r") as f:
data = f.readlines()
resources = dict()
print_stats = False
proc_cells = False
for line in data:
print_stats = "Printing statistics" in line or print_stats
if not print_stats:
continue
... | SymbiFlow/fpga-tool-perf | [
78,
23,
78,
85,
1529693672
] |
def which(program, get_dir=False):
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
exe... | SymbiFlow/fpga-tool-perf | [
78,
23,
78,
85,
1529693672
] |
def __init__(self, plotly_name="textfont", parent_name="funnelarea", **kwargs):
super(TextfontValidator, self).__init__(
plotly_name=plotly_name,
parent_name=parent_name,
data_class_str=kwargs.pop("data_class_str", "Textfont"),
data_docs=kwargs.pop(
... | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def __init__(self, html,isForeign = True, url=None):
"""Generate the document
:param html: string of the html content.
:param url: url of the html
"""
self.url = url
self.html = html
self.link_num = 0
self.link_text_len = 0
self.total_text_tag_num ... | desion/tidy_page | [
5,
4,
5,
1,
1487582485
] |
def _parse(self, html):
soup = BeautifulSoup(html, "lxml")
return soup | desion/tidy_page | [
5,
4,
5,
1,
1487582485
] |
def prettify(self):
"""Returns prettify document"""
return self.doc.prettify("utf-8") | desion/tidy_page | [
5,
4,
5,
1,
1487582485
] |
def content(self):
"""get the content of html page"""
clean_spam(self.doc)
candidates = self.get_candidates()
best_node = self.best_candidates(candidates)
if best_node:
return self.purify(best_node["elem"])
else:
return None | desion/tidy_page | [
5,
4,
5,
1,
1487582485
] |
def walk(self):
"""walk the dom tree and get the info of the page"""
g = self.doc.recursiveChildGenerator()
while True:
try:
tag = g.next()
if not isinstance(tag,unicode):
if tag.name == "a" and ((self.is_foreign and len(tag.text) >... | desion/tidy_page | [
5,
4,
5,
1,
1487582485
] |
def text_weight(self, elem):
content_score = 1
long_text_line = 0
block_size = 3
inner_text = ""
for string in elem.stripped_strings:
if (self.is_foreign and len(string) > 100) or (not self.is_foreign and len(string) > 50):
long_text_line += 1
... | desion/tidy_page | [
5,
4,
5,
1,
1487582485
] |
def class_weight(self, elem):
weight = 0
for feature in [elem.get('class', None), elem.get('id', None)]:
try:
if feature:
if REGEXES['negativeRe'].search(feature):
weight -= 25
if REGEXES['positiveRe'].search(fe... | desion/tidy_page | [
5,
4,
5,
1,
1487582485
] |
def score_node(self, elem):
class_score = self.class_weight(elem)
node_score = self.node_weight(elem)
content_score = class_score + node_score
return {
'score': content_score,
'elem': elem
} | desion/tidy_page | [
5,
4,
5,
1,
1487582485
] |
def get_link_tag_density(self, elem):
"""get the link tag density"""
return float(self.link_text_len) / max(self.total_text_len, 1) | desion/tidy_page | [
5,
4,
5,
1,
1487582485
] |
def purify(self, best_elem):
del best_elem['class']
del best_elem['id']
g = best_elem.recursiveChildGenerator()
while True:
try:
tag = g.next()
if tag is None:
break
#text node
if not isinstan... | desion/tidy_page | [
5,
4,
5,
1,
1487582485
] |
def __init__(
self, plotly_name="colorsrc", parent_name="waterfall.insidetextfont", **kwargs | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list.metadat... | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=resp... | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get(
self,
regulatory_compliance_standard_name, # type: str
regulatory_compliance_control_name, # type: str
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def gen_jump_list(ft, name, data):
res = []
if not data:
return res
items = data[0]
if items is None:
return res
for item in items:
uri = parse_uri(item['uri'])
if ft == 'go':
uri = uri.replace('%21', '!')
start = item['range']['start']
... | maralla/completor.vim | [
1205,
59,
1205,
84,
1473832352
] |
def format_text(data):
if not data:
return
for item in data[0]:
pass | maralla/completor.vim | [
1205,
59,
1205,
84,
1473832352
] |
def _shouldHidden(line):
for item in hiddenLines:
if item in line:
return True
return False | maralla/completor.vim | [
1205,
59,
1205,
84,
1473832352
] |
def setThreadPool(threadPool):
"""Set the default thread pool to use for executing new tasks.
@param threadPool: The new default thread pool.
@return: The previous default thread pool. This is intially None.
"""
global _threadPool, _threadPoolLock
_threadPoolLock.acquire()
try:
oldThreadPool = _th... | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
def _makeTasks(value):
if value is None:
return []
elif isinstance(value, Task):
return [value]
else:
return list(value) | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
def __init__(self, func=None):
"""Construct a task given a function. | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
def getCurrent():
"""Get the currently executing task. | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
def state(self):
"""Get the state of this task.
"""
return self._state | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
def parent(self):
"""Get the parent of this task.
The parent task is the task that created this task.
"""
return self._parent | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
def required(self):
"""True if this task is required to execute, False if it
has not yet been required to execute.
"""
return self._required | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
def started(self):
"""True if this task has been started. | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
def completed(self):
"""True if this task has finished execution or has been cancelled.
"""
s = self._state
return s is Task.State.SUCCEEDED or s is Task.State.FAILED | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
def succeeded(self):
"""True if this task successfully finished execution.
"""
return self._state is Task.State.SUCCEEDED | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
def failed(self):
"""True if this task failed or was cancelled.
"""
return self._state is Task.State.FAILED | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
def result(self):
"""If the task has completed successfully then holds the
return value of the task, otherwise raises AttributeError.
"""
if self.succeeded:
task = self
while isinstance(task._result, Task):
task = task._result
return task._result
else:
raise Attribute... | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
def lazyStartAfter(self, other, threadPool=None):
"""Start this task only if required as a dependency of another 'required' task.
But do not start this task until the 'other' tasks have completed.
If any of the other tasks complete with failure then this task will complete
with failure without being ex... | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
def startAfter(self, other, immediate=False, threadPool=None):
"""Start this task after other tasks have completed. | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
def _start(self, other, immediate, required, threadPool):
immediate = bool(immediate)
required = bool(required)
otherTasks = _makeTasks(other)
if threadPool is None:
threadPool = getDefaultThreadPool()
self._lock.acquire()
try:
if self._state is not Task.State.NEW:
raise Tas... | lewissbaker/cake | [
16,
7,
16,
11,
1377774432
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.