code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def stop(self):
if self.container_id is None:
raise Exception('No Docker Selenium container was running')
check_call(['docker', 'stop', self.container_id])
self.container_id = None
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier none
|
Stop the Docker container
|
def preTranslate(self, tx, ty):
self.e += tx * self.a + ty * self.c
self.f += tx * self.b + ty * self.d
return self
|
module function_definition identifier parameters identifier identifier identifier block expression_statement augmented_assignment attribute identifier identifier binary_operator binary_operator identifier attribute identifier identifier binary_operator identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier binary_operator binary_operator identifier attribute identifier identifier binary_operator identifier attribute identifier identifier return_statement identifier
|
Calculate pre translation and replace current matrix.
|
def _resolve_children(self, ldap_user, groups):
for child in self.children:
if isinstance(child, LDAPGroupQuery):
yield child.resolve(ldap_user, groups)
else:
yield groups.is_member_of(child)
|
module function_definition identifier parameters identifier identifier identifier block for_statement identifier attribute identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement yield call attribute identifier identifier argument_list identifier identifier else_clause block expression_statement yield call attribute identifier identifier argument_list identifier
|
Generates the query result for each child.
|
def r_hat(self):
_, y_vals, values, colors = self.labels_ticks_and_vals()
for y, value, color in zip(y_vals, values, colors):
if value.ndim != 2 or value.shape[0] < 2:
yield y, None, color
else:
yield y, _get_split_rhat(value), color
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier identifier call identifier argument_list identifier identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier integer comparison_operator subscript attribute identifier identifier integer integer block expression_statement yield expression_list identifier none identifier else_clause block expression_statement yield expression_list identifier call identifier argument_list identifier identifier
|
Get rhat data for the variable.
|
def hasDefault(self, param):
param = self._resolveParam(param)
return param in self._defaultParamMap
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement comparison_operator identifier attribute identifier identifier
|
Checks whether a param has a default value.
|
def gen_bsh(src1, src2, dst):
assert src1.size == src2.size
return ReilBuilder.build(ReilMnemonic.BSH, src1, src2, dst)
|
module function_definition identifier parameters identifier identifier identifier block assert_statement comparison_operator attribute identifier identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier identifier identifier identifier
|
Return a BSH instruction.
|
def _do_save_as(self, filename):
if len(self.spectrum.x) < 2:
raise RuntimeError("Spectrum must have at least two points")
if os.path.isfile(filename):
os.unlink(filename)
hdu = self.spectrum.to_hdu()
overwrite_fits(hdu, filename)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list attribute attribute identifier identifier identifier integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call identifier argument_list identifier identifier
|
Saves spectrum back to FITS file.
|
def read_uic_image_property(fh):
size = struct.unpack('B', fh.read(1))[0]
name = struct.unpack('%is' % size, fh.read(size))[0][:-1]
flags, prop = struct.unpack('<IB', fh.read(5))
if prop == 1:
value = struct.unpack('II', fh.read(8))
value = value[0] / value[1]
else:
size = struct.unpack('B', fh.read(1))[0]
value = struct.unpack('%is' % size, fh.read(size))[0]
return dict(name=name, flags=flags, value=value)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list integer integer expression_statement assignment identifier subscript subscript call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier call attribute identifier identifier argument_list identifier integer slice unary_operator integer expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list integer if_statement comparison_operator identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list integer expression_statement assignment identifier binary_operator subscript identifier integer subscript identifier integer else_clause block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list integer integer expression_statement assignment identifier subscript call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier call attribute identifier identifier argument_list identifier integer return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Read UIC ImagePropertyEx tag from file and return as dict.
|
async def _run_state(self, responder, state, trigger, request) \
-> BaseState:
user_trigger = trigger
try:
if trigger:
await state.handle()
else:
await state.confused()
for i in range(0, settings.MAX_INTERNAL_JUMPS + 1):
if i == settings.MAX_INTERNAL_JUMPS:
raise MaxInternalJump()
trigger, state_class, dnr = \
await self._find_trigger(request, state.name(), True)
if not trigger:
break
logger.debug('Jumping to state: %s', state_class.name())
state = state_class(request, responder, trigger, user_trigger)
await state.handle()
except Exception:
logger.exception('Error while handling state "%s"', state.name())
responder.clear()
reporter.report(request, state.name())
await state.error()
return state
|
module function_definition identifier parameters identifier identifier identifier identifier identifier line_continuation type identifier block expression_statement assignment identifier identifier try_statement block if_statement identifier block expression_statement await call attribute identifier identifier argument_list else_clause block expression_statement await call attribute identifier identifier argument_list for_statement identifier call identifier argument_list integer binary_operator attribute identifier identifier integer block if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list expression_statement assignment pattern_list identifier identifier identifier line_continuation await call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list true if_statement not_operator identifier block break_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier expression_statement await call attribute identifier identifier argument_list except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list expression_statement await call attribute identifier identifier argument_list return_statement identifier
|
Execute the state, or if execution fails handle it.
|
def extend (name, values):
assert isinstance(name, basestring)
assert is_iterable_typed(values, basestring)
name = add_grist (name)
__validate_feature (name)
feature = __all_features [name]
if feature.implicit:
for v in values:
if v in __implicit_features:
raise BaseException ("'%s' is already associated with the feature '%s'" % (v, __implicit_features [v]))
__implicit_features[v] = feature
if values and not feature.values and not(feature.free or feature.optional):
feature.set_default(values[0])
feature.add_values(values)
|
module function_definition identifier parameters identifier identifier block assert_statement call identifier argument_list identifier identifier assert_statement call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement assignment identifier subscript identifier identifier if_statement attribute identifier identifier block for_statement identifier identifier block if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier subscript identifier identifier expression_statement assignment subscript identifier identifier identifier if_statement boolean_operator boolean_operator identifier not_operator attribute identifier identifier not_operator parenthesized_expression boolean_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list subscript identifier integer expression_statement call attribute identifier identifier argument_list identifier
|
Adds the given values to the given feature.
|
def steadystate(A, max_iter=100):
P = np.linalg.matrix_power(A, max_iter)
v = []
for i in range(len(P)):
if not np.any([np.allclose(P[i], vi, ) for vi in v]):
v.append(P[i])
return normalize(np.sum(v, axis=0))
|
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier list for_statement identifier call identifier argument_list call identifier argument_list identifier block if_statement not_operator call attribute identifier identifier argument_list list_comprehension call attribute identifier identifier argument_list subscript identifier identifier identifier for_in_clause identifier identifier block expression_statement call attribute identifier identifier argument_list subscript identifier identifier return_statement call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier integer
|
Empirically determine the steady state probabilities from a stochastic matrix
|
def reconstruct_cdm(dm, absolute_angles, all_points, W=None):
from pylocus.point_set import dmi_from_V, sdm_from_dmi, get_V
from pylocus.mds import signedMDS
N = all_points.shape[0]
V = get_V(absolute_angles, dm)
dmx = dmi_from_V(V, 0)
dmy = dmi_from_V(V, 1)
sdmx = sdm_from_dmi(dmx, N)
sdmy = sdm_from_dmi(dmy, N)
points_x = signedMDS(sdmx, W)
points_y = signedMDS(sdmy, W)
Xhat = np.c_[points_x, points_y]
Y, R, t, c = procrustes(all_points, Xhat, scale=False)
return Y
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block import_from_statement dotted_name identifier identifier dotted_name identifier dotted_name identifier dotted_name identifier import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier integer expression_statement assignment identifier call identifier argument_list identifier integer expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier identifier expression_statement assignment pattern_list identifier identifier identifier identifier call identifier argument_list identifier identifier keyword_argument identifier false return_statement identifier
|
Reconstruct point set from angle and distance measurements, using coordinate difference matrices.
|
def csv_line_items(self):
if not hasattr(self, '_csv_line_items'):
url = '{}/{}'.format(self.base_url, self.id)
self._csv_line_items = self.harvest._get_element_values(url, self.element_name).next().get('csv-line-items', '')
return self._csv_line_items
|
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute call attribute call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_end return_statement attribute identifier identifier
|
Invoices from lists omit csv-line-items
|
def user_info(self, kv):
key, value = kv
self.__user_info[key] = value
|
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier
|
Sets user_info dict entry through a tuple.
|
def create_onvif_service(self, name, from_template=True, portType=None):
name = name.lower()
xaddr, wsdl_file = self.get_definition(name)
with self.services_lock:
svt = self.services_template.get(name)
if svt and from_template and self.use_services_template.get(name):
service = ONVIFService.clone(svt, xaddr, self.user,
self.passwd, wsdl_file,
self.cache_location,
self.cache_duration,
self.encrypt,
self.daemon,
no_cache=self.no_cache, portType=portType, dt_diff=self.dt_diff)
else:
service = ONVIFService(xaddr, self.user, self.passwd,
wsdl_file, self.cache_location,
self.cache_duration, self.encrypt,
self.daemon, no_cache=self.no_cache, portType=portType, dt_diff=self.dt_diff)
self.services[name] = service
setattr(self, name, service)
if not self.services_template.get(name):
self.services_template[name] = service
return service
|
module function_definition identifier parameters identifier identifier default_parameter identifier true default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier with_statement with_clause with_item attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement boolean_operator boolean_operator identifier identifier call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier attribute identifier identifier attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement call identifier argument_list identifier identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier
|
Create ONVIF service client
|
def _tempfilepager(generator, cmd, color):
import tempfile
filename = tempfile.mktemp()
text = "".join(generator)
if not color:
text = strip_ansi(text)
encoding = get_best_encoding(sys.stdout)
with open_stream(filename, 'wb')[0] as f:
f.write(text.encode(encoding))
try:
os.system(cmd + ' "' + filename + '"')
finally:
os.unlink(filename)
|
module function_definition identifier parameters identifier identifier identifier block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute string string_start string_end identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier with_statement with_clause with_item as_pattern subscript call identifier argument_list identifier string string_start string_content string_end integer as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator binary_operator identifier string string_start string_content string_end identifier string string_start string_content string_end finally_clause block expression_statement call attribute identifier identifier argument_list identifier
|
Page through text by invoking a program on a temporary file.
|
def migrateProvPre010(self, newslab):
did_migrate = self._migrate_db_pre010('prov', newslab)
if not did_migrate:
return
self._migrate_db_pre010('provs', newslab)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement not_operator identifier block return_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
|
Check for any pre-010 provstacks and migrate those to the new slab.
|
def data_in_label(intvl_in, dtype_in_time, dtype_in_vert=False):
intvl_lbl = intvl_in
time_lbl = dtype_in_time
lbl = '_'.join(['from', intvl_lbl, time_lbl]).replace('__', '_')
vert_lbl = dtype_in_vert if dtype_in_vert else False
if vert_lbl:
lbl = '_'.join([lbl, vert_lbl]).replace('__', '_')
return lbl
|
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier call attribute call attribute string string_start string_content string_end identifier argument_list list string string_start string_content string_end identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier conditional_expression identifier identifier false if_statement identifier block expression_statement assignment identifier call attribute call attribute string string_start string_content string_end identifier argument_list list identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement identifier
|
Create string label specifying the input data of a calculation.
|
def crc7(data):
crc = 0
for c in data:
crc = CRC7_TABLE[crc ^ c]
return crc
|
module function_definition identifier parameters identifier block expression_statement assignment identifier integer for_statement identifier identifier block expression_statement assignment identifier subscript identifier binary_operator identifier identifier return_statement identifier
|
Compute CRC of a whole message.
|
def picard_formatconverter(picard, align_sam):
out_bam = "%s.bam" % os.path.splitext(align_sam)[0]
if not file_exists(out_bam):
with tx_tmpdir(picard._config) as tmp_dir:
with file_transaction(picard._config, out_bam) as tx_out_bam:
opts = [("INPUT", align_sam),
("OUTPUT", tx_out_bam),
("TMP_DIR", tmp_dir)]
picard.run("SamFormatConverter", opts)
return out_bam
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end subscript call attribute attribute identifier identifier identifier argument_list identifier integer if_statement not_operator call identifier argument_list identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier as_pattern_target identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier identifier as_pattern_target identifier block expression_statement assignment identifier list tuple string string_start string_content string_end identifier tuple string string_start string_content string_end identifier tuple string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier
|
Convert aligned SAM file to BAM format.
|
def available_state(self, state: State) -> Tuple[State, ...]:
result = []
for gene in self.genes:
result.extend(self.available_state_for_gene(gene, state))
if len(result) > 1 and state in result:
result.remove(state)
return tuple(result)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier type ellipsis block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier if_statement boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier
|
Return the state reachable from a given state.
|
def path(self):
"Returns the path up to the root for the current node."
if self.parent:
return '.'.join([self.parent.path, str(self.identifier)])
else:
return self.identifier if self.identifier else self.__class__.__name__
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement attribute identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list list attribute attribute identifier identifier identifier call identifier argument_list attribute identifier identifier else_clause block return_statement conditional_expression attribute identifier identifier attribute identifier identifier attribute attribute identifier identifier identifier
|
Returns the path up to the root for the current node.
|
def lookup(self, tmp):
if tmp < 0 or tmp > self.types_used:
l.debug("Invalid temporary number %d", tmp)
raise IndexError(tmp)
return self.types[tmp]
|
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier raise_statement call identifier argument_list identifier return_statement subscript attribute identifier identifier identifier
|
Return the type of temporary variable `tmp` as an enum string
|
def _get_domain_event_detail(event, detail):
event_name = _get_libvirt_enum_string('VIR_DOMAIN_EVENT_', event)
if event_name == 'unknown':
return event_name, 'unknown'
prefix = 'VIR_DOMAIN_EVENT_{0}_'.format(event_name.upper())
detail_name = _get_libvirt_enum_string(prefix, detail)
return event_name, detail_name
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement expression_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier return_statement expression_list identifier identifier
|
Convert event and detail numeric values into a tuple of human readable strings
|
def adaptive_universal_transformer_multilayer_hard():
hparams = adaptive_universal_transformer_multilayer_tpu()
hparams.batch_size = 256
hparams.hard_attention_k = 8
hparams.add_step_timing_signal = True
hparams.self_attention_type = "dot_product_relative_v2"
hparams.max_relative_position = 256
return hparams
|
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier integer return_statement identifier
|
Multi-layer config for adaptive Transformer with hard attention.
|
def initialize_ray():
if threading.current_thread().name == "MainThread":
plasma_directory = None
object_store_memory = os.environ.get("MODIN_MEMORY", None)
if os.environ.get("MODIN_OUT_OF_CORE", "False").title() == "True":
from tempfile import gettempdir
plasma_directory = gettempdir()
if object_store_memory is None:
mem_bytes = ray.utils.get_system_memory() // 10 ** 9 * 10 ** 9
object_store_memory = 8 * mem_bytes
if object_store_memory is None:
object_store_memory = int(
0.6 * ray.utils.get_system_memory() // 10 ** 9 * 10 ** 9
)
if object_store_memory == 0:
object_store_memory = None
else:
object_store_memory = int(object_store_memory)
ray.init(
include_webui=False,
ignore_reinit_error=True,
plasma_directory=plasma_directory,
object_store_memory=object_store_memory,
)
ray.register_custom_serializer(types.MethodType, use_pickle=True)
|
module function_definition identifier parameters block if_statement comparison_operator attribute call attribute identifier identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier none expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none if_statement comparison_operator call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier argument_list string string_start string_content string_end block import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator binary_operator call attribute attribute identifier identifier identifier argument_list binary_operator integer integer binary_operator integer integer expression_statement assignment identifier binary_operator integer identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list binary_operator binary_operator binary_operator float call attribute attribute identifier identifier identifier argument_list binary_operator integer integer binary_operator integer integer if_statement comparison_operator identifier integer block expression_statement assignment identifier none else_clause block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier false keyword_argument identifier true keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier true
|
Initializes ray based on environment variables and internal defaults.
|
def proselint(paths=None, version=None, clean=None, debug=None,
output_json=None, time=None, demo=None, compact=None):
if time:
click.echo(timing_test())
return
if debug or clean:
clear_cache()
if demo:
paths = [demo_file]
filepaths = extract_files(list(paths))
num_errors = 0
if len(paths) == 0:
filepaths.append('-')
for fp in filepaths:
try:
if fp == '-':
fp = '<stdin>'
f = sys.stdin
else:
f = click.open_file(
fp, 'r', encoding="utf-8", errors="replace")
errors = lint(f, debug=debug)
num_errors += len(errors)
print_errors(fp, errors, output_json, compact=compact)
except Exception:
traceback.print_exc()
close_cache_shelves()
if num_errors > 0:
sys.exit(1)
else:
sys.exit(0)
|
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list return_statement if_statement boolean_operator identifier identifier block expression_statement call identifier argument_list if_statement identifier block expression_statement assignment identifier list identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier expression_statement assignment identifier integer if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block try_statement block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement augmented_assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier identifier identifier keyword_argument identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list integer else_clause block expression_statement call attribute identifier identifier argument_list integer
|
A CLI for proselint, a linter for prose.
|
def reply(self):
reply = []
for f in self.fragments:
if not (f.hidden or f.quoted):
reply.append(f.content)
return '\n'.join(reply)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block if_statement not_operator parenthesized_expression boolean_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier
|
Captures reply message within email
|
def plot(self, ax=None, **kwargs):
ax, fig, plt = get_ax_fig_plt(ax)
yy = [len(v) for v in self.values]
ax.plot(self.binvals, yy, **kwargs)
return fig
|
module function_definition identifier parameters identifier default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier dictionary_splat identifier return_statement identifier
|
Plot the histogram with matplotlib, returns `matplotlib` figure.
|
def render_category(slug):
try:
category = EntryCategory.objects.get(slug=slug)
except EntryCategory.DoesNotExist:
pass
else:
return {'category': category}
return {}
|
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier except_clause attribute identifier identifier block pass_statement else_clause block return_statement dictionary pair string string_start string_content string_end identifier return_statement dictionary
|
Template tag to render a category with all it's entries.
|
def execute(self, conn, name='', transaction = False):
binds={}
if name:
op = ('=', 'like')['%' in name]
sql = self.sql + " WHERE pg.physics_group_name %s :physicsgroup" % (op)
binds = {"physicsgroup": name}
else:
sql = self.sql
self.logger.debug(sql)
result = self.dbi.processData(sql, binds, conn, transaction)
plist = self.formatDict(result)
self.logger.debug(plist)
if len(plist) < 1: return []
return plist
|
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end default_parameter identifier false block expression_statement assignment identifier dictionary if_statement identifier block expression_statement assignment identifier subscript tuple string string_start string_content string_end string string_start string_content string_end comparison_operator string string_start string_content string_end identifier expression_statement assignment identifier binary_operator attribute identifier identifier binary_operator string string_start string_content string_end parenthesized_expression identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block return_statement list return_statement identifier
|
returns id for a given physics group name
|
def create_hparams(hparams_set,
hparams_overrides_str="",
data_dir=None,
problem_name=None,
hparams_path=None):
hparams = registry.hparams(hparams_set)
if hparams_path and tf.gfile.Exists(hparams_path):
hparams = create_hparams_from_json(hparams_path, hparams)
if data_dir:
hparams.add_hparam("data_dir", data_dir)
if hparams_overrides_str:
tf.logging.info("Overriding hparams in %s with %s", hparams_set,
hparams_overrides_str)
hparams = hparams.parse(hparams_overrides_str)
if problem_name:
add_problem_hparams(hparams, problem_name)
return hparams
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator identifier call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call identifier argument_list identifier identifier return_statement identifier
|
Create HParams with data_dir and problem hparams, if kwargs provided.
|
def requiredGPU_MB(self, n):
from darknet.core import darknet_with_cuda
if (darknet_with_cuda()):
free = getFreeGPU_MB()
print("Yolo: requiredGPU_MB: required, free", n, free)
if (free == -1):
return True
return (free>=n)
else:
return True
|
module function_definition identifier parameters identifier identifier block import_from_statement dotted_name identifier identifier dotted_name identifier if_statement parenthesized_expression call identifier argument_list block expression_statement assignment identifier call identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end identifier identifier if_statement parenthesized_expression comparison_operator identifier unary_operator integer block return_statement true return_statement parenthesized_expression comparison_operator identifier identifier else_clause block return_statement true
|
Required GPU memory in MBytes
|
def setupEmptyTree(self):
if hasattr(self, "tree"):
del self.tree
self.tree = QtWidgets.QTreeWidget(self)
self.tree.header().close()
|
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block delete_statement attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list
|
Setup empty Tree at startup.
|
def add_response_headers(self, headers, **overrides):
response_headers = self.route.get('response_headers', {}).copy()
response_headers.update(headers)
return self.where(response_headers=response_headers, **overrides)
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier dictionary_splat identifier
|
Adds the specified response headers while keeping existing ones in-tact
|
def plot_knee(self, ):
import matplotlib.pyplot as plt
plt.figure(figsize=(8, 8))
plt.plot(self.x, self.y)
plt.vlines(self.knee, plt.ylim()[0], plt.ylim()[1])
|
module function_definition identifier parameters identifier block import_statement aliased_import dotted_name identifier identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier tuple integer integer expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier subscript call attribute identifier identifier argument_list integer subscript call attribute identifier identifier argument_list integer
|
Plot the curve and the knee, if it exists
|
def less_strict_bool(x):
if x is None:
return False
elif x is True or x is False:
return x
else:
return strict_bool(x)
|
module function_definition identifier parameters identifier block if_statement comparison_operator identifier none block return_statement false elif_clause boolean_operator comparison_operator identifier true comparison_operator identifier false block return_statement identifier else_clause block return_statement call identifier argument_list identifier
|
Idempotent and None-safe version of strict_bool.
|
def forward(self, is_train=False):
for texec in self.train_execs:
texec.forward(is_train=is_train)
|
module function_definition identifier parameters identifier default_parameter identifier false block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
|
Perform a forward pass on each executor.
|
def recall_series(y_true, y_score, k=None, value=True):
y_true, y_score = to_float(y_true, y_score)
top = _argsort(y_score, k)
if not value:
y_true = 1-y_true
a = np.nan_to_num(y_true[top]).cumsum()
return pd.Series(a, index=np.arange(1, len(a)+1))
|
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier true block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier if_statement not_operator identifier block expression_statement assignment identifier binary_operator integer identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list subscript identifier identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier call attribute identifier identifier argument_list integer binary_operator call identifier argument_list identifier integer
|
Returns series of length k whose i-th entry is the recall in the top i
|
def write_record(self, event_str):
header = struct.pack('Q', len(event_str))
header += struct.pack('I', masked_crc32c(header))
footer = struct.pack('I', masked_crc32c(event_str))
self._writer.write(header + event_str + footer)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier expression_statement augmented_assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator identifier identifier identifier
|
Writes a serialized event to file.
|
def activate_language(instances, language):
language = (
language if language in get_supported_languages() else get_fallback_language()
)
for instance in instances:
instance.activate_language(language)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier parenthesized_expression conditional_expression identifier comparison_operator identifier call identifier argument_list call identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Activates the given language for the given instances.
|
def _clear_namespace():
ok_names = set(default_backend.__dict__)
ok_names.update(['gl2', 'glplus'])
NS = globals()
for name in list(NS.keys()):
if name.lower().startswith('gl'):
if name not in ok_names:
del NS[name]
|
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end block if_statement comparison_operator identifier identifier block delete_statement subscript identifier identifier
|
Clear names that are not part of the strict ES API
|
def tax_ids(self):
fetch = select([self.nodes.c.tax_id]).execute().fetchall()
ids = [t[0] for t in fetch]
return ids
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute call identifier argument_list list attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier argument_list expression_statement assignment identifier list_comprehension subscript identifier integer for_in_clause identifier identifier return_statement identifier
|
Return all tax_ids in node table
|
def potential_purviews(self, direction, mechanism, purviews=False):
all_purviews = utils.powerset(self.node_indices)
return irreducible_purviews(
self.cm, direction, mechanism, all_purviews)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement call identifier argument_list attribute identifier identifier identifier identifier identifier
|
Override Subsystem implementation using Network-level indices.
|
def raster_to_shape(raster):
left = raster.bounds.left
right = raster.bounds.right
top = raster.bounds.top
bottom = raster.bounds.bottom
top_left = (left, top)
top_right = (right, top)
bottom_left = (left, bottom)
bottom_right = (right, bottom)
return Polygon((
top_left, top_right, bottom_right, bottom_left, top_left,
))
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier tuple identifier identifier expression_statement assignment identifier tuple identifier identifier expression_statement assignment identifier tuple identifier identifier expression_statement assignment identifier tuple identifier identifier return_statement call identifier argument_list tuple identifier identifier identifier identifier identifier
|
Take a raster and return a polygon representing the outer edge.
|
def _factln(num):
if num < 20:
log_factorial = log(factorial(num))
else:
log_factorial = num * log(num) - num + log(num * (1 + 4 * num * (
1 + 2 * num))) / 6.0 + log(pi) / 2
return log_factorial
|
module function_definition identifier parameters identifier block if_statement comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier else_clause block expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator identifier call identifier argument_list identifier identifier binary_operator call identifier argument_list binary_operator identifier parenthesized_expression binary_operator integer binary_operator binary_operator integer identifier parenthesized_expression binary_operator integer binary_operator integer identifier float binary_operator call identifier argument_list identifier integer return_statement identifier
|
Computes logfactorial regularly for tractable numbers, uses Ramanujans approximation otherwise.
|
def _split_index(params):
if isinstance(params, list):
return [params[0], _split_index(params[1])]
elif isinstance(params, dict):
if INDEX in params.keys():
return _split_index(params[VALUE])
result = dict()
for key in params:
result[key] = _split_index(params[key])
return result
else:
return params
|
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement list subscript identifier integer call identifier argument_list subscript identifier integer elif_clause call identifier argument_list identifier identifier block if_statement comparison_operator identifier call attribute identifier identifier argument_list block return_statement call identifier argument_list subscript identifier identifier expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list subscript identifier identifier return_statement identifier else_clause block return_statement identifier
|
Delete index infromation from params
|
def encode_simple(d):
if isinstance(d, unicode):
return d.encode()
if isinstance(d, list):
return list(map(encode_simple, d))
if isinstance(d, dict):
return dict([(encode_simple(k), encode_simple(v)) for k, v in d.items()])
return d
|
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list call identifier argument_list identifier identifier if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list list_comprehension tuple call identifier argument_list identifier call identifier argument_list identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list return_statement identifier
|
Encode strings in basic python objects.
|
def all_bases (type):
assert isinstance(type, basestring)
result = []
while type:
result.append (type)
type = __types [type]['base']
return result
|
module function_definition identifier parameters identifier block assert_statement call identifier argument_list identifier identifier expression_statement assignment identifier list while_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript subscript identifier identifier string string_start string_content string_end return_statement identifier
|
Returns type and all of its bases, in the order of their distance from type.
|
def signature(self):
mods = ", ".join(self.modifiers)
return "{} SUBROUTINE {}({})".format(mods, self.name,
self.parameters_as_string())
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier call attribute identifier identifier argument_list
|
Returns the signature definition for the subroutine.
|
def _iterative_matches(self, nodes):
nodelen = len(nodes)
if 0 >= self.min:
yield 0, {}
results = []
for alt in self.content:
for c, r in generate_matches(alt, nodes):
yield c, r
results.append((c, r))
while results:
new_results = []
for c0, r0 in results:
if c0 < nodelen and c0 <= self.max:
for alt in self.content:
for c1, r1 in generate_matches(alt, nodes[c0:]):
if c1 > 0:
r = {}
r.update(r0)
r.update(r1)
yield c0 + c1, r
new_results.append((c0 + c1, r))
results = new_results
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator integer attribute identifier identifier block expression_statement yield expression_list integer dictionary expression_statement assignment identifier list for_statement identifier attribute identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier identifier block expression_statement yield expression_list identifier identifier expression_statement call attribute identifier identifier argument_list tuple identifier identifier while_statement identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier identifier block if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier attribute identifier identifier block for_statement identifier attribute identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier subscript identifier slice identifier block if_statement comparison_operator identifier integer block expression_statement assignment identifier dictionary expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement yield expression_list binary_operator identifier identifier identifier expression_statement call attribute identifier identifier argument_list tuple binary_operator identifier identifier identifier expression_statement assignment identifier identifier
|
Helper to iteratively yield the matches.
|
def timing(name=''):
start = datetime.datetime.now()
timestamp = start.strftime('%H:%M')
tf.logging.info('Starting job [%s] at %s', name, timestamp)
yield
end = datetime.datetime.now()
timestamp = end.strftime('%H:%M')
tf.logging.info('Finished job [%s] at %s', name, timestamp)
duration = end - start
duration_mins = duration.total_seconds() / 60
tf.logging.info('Total time [%s] (m): %d', name, int(duration_mins))
|
module function_definition identifier parameters default_parameter identifier string string_start string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement yield expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list integer expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier call identifier argument_list identifier
|
Log start, end, and duration.
|
def colors_to_dict(colors, img):
return {
"wallpaper": img,
"alpha": util.Color.alpha_num,
"special": {
"background": colors[0],
"foreground": colors[15],
"cursor": colors[15]
},
"colors": {
"color0": colors[0],
"color1": colors[1],
"color2": colors[2],
"color3": colors[3],
"color4": colors[4],
"color5": colors[5],
"color6": colors[6],
"color7": colors[7],
"color8": colors[8],
"color9": colors[9],
"color10": colors[10],
"color11": colors[11],
"color12": colors[12],
"color13": colors[13],
"color14": colors[14],
"color15": colors[15]
}
}
|
module function_definition identifier parameters identifier identifier block return_statement dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end dictionary pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer
|
Convert list of colors to pywal format.
|
def draw_graph(G: nx.DiGraph, filename: str):
A = to_agraph(G)
A.graph_attr["rankdir"] = "LR"
A.draw(filename, prog="dot")
|
module function_definition identifier parameters typed_parameter identifier type attribute identifier identifier typed_parameter identifier type identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end
|
Draw a networkx graph with Pygraphviz.
|
def failover_limitation(self):
if not self.reachable:
return 'not reachable'
if self.tags.get('nofailover', False):
return 'not allowed to promote'
if self.watchdog_failed:
return 'not watchdog capable'
return None
|
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end false block return_statement string string_start string_content string_end if_statement attribute identifier identifier block return_statement string string_start string_content string_end return_statement none
|
Returns reason why this node can't promote or None if everything is ok.
|
def contains_is_html(cls, data):
for key, val in data.items():
if isinstance(key, str) and key.endswith("IsHTML"):
return True
if isinstance(val, (OrderedDict, dict)) and cls.contains_is_html(val):
return True
return False
|
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator call identifier argument_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end block return_statement true if_statement boolean_operator call identifier argument_list identifier tuple identifier identifier call attribute identifier identifier argument_list identifier block return_statement true return_statement false
|
Detect if the problem has at least one "xyzIsHTML" key
|
def _SnakeCaseToCamelCase(path_name):
result = []
after_underscore = False
for c in path_name:
if c.isupper():
raise Error('Fail to print FieldMask to Json string: Path name '
'{0} must not contain uppercase letters.'.format(path_name))
if after_underscore:
if c.islower():
result.append(c.upper())
after_underscore = False
else:
raise Error('Fail to print FieldMask to Json string: The '
'character after a "_" must be a lowercase letter '
'in path name {0}.'.format(path_name))
elif c == '_':
after_underscore = True
else:
result += c
if after_underscore:
raise Error('Fail to print FieldMask to Json string: Trailing "_" '
'in path name {0}.'.format(path_name))
return ''.join(result)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier false for_statement identifier identifier block if_statement call attribute identifier identifier argument_list block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier if_statement identifier block if_statement call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier false else_clause block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier true else_clause block expression_statement augmented_assignment identifier identifier if_statement identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier return_statement call attribute string string_start string_end identifier argument_list identifier
|
Converts a path name from snake_case to camelCase.
|
def visit_ifexp(self, node):
return "%s if %s else %s" % (
self._precedence_parens(node, node.body, is_left=True),
self._precedence_parens(node, node.test, is_left=True),
self._precedence_parens(node, node.orelse, is_left=False),
)
|
module function_definition identifier parameters identifier identifier block return_statement binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier attribute identifier identifier keyword_argument identifier true call attribute identifier identifier argument_list identifier attribute identifier identifier keyword_argument identifier true call attribute identifier identifier argument_list identifier attribute identifier identifier keyword_argument identifier false
|
return an astroid.IfExp node as string
|
def getall(self, key, default=_marker):
identity = self._title(key)
res = [v for i, k, v in self._impl._items if i == identity]
if res:
return res
if not res and default is not _marker:
return default
raise KeyError('Key not found: %r' % key)
|
module function_definition identifier parameters identifier identifier default_parameter identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension identifier for_in_clause pattern_list identifier identifier identifier attribute attribute identifier identifier identifier if_clause comparison_operator identifier identifier if_statement identifier block return_statement identifier if_statement boolean_operator not_operator identifier comparison_operator identifier identifier block return_statement identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
|
Return a list of all values matching the key.
|
def gf_poly_mul_simple(p, q):
r = bytearray(len(p) + len(q) - 1)
for j in xrange(len(q)):
for i in xrange(len(p)):
r[i + j] ^= gf_mul(p[i], q[j])
return r
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list binary_operator binary_operator call identifier argument_list identifier call identifier argument_list identifier integer for_statement identifier call identifier argument_list call identifier argument_list identifier block for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement augmented_assignment subscript identifier binary_operator identifier identifier call identifier argument_list subscript identifier identifier subscript identifier identifier return_statement identifier
|
Multiply two polynomials, inside Galois Field
|
def log_level_type(arg):
if not arg.upper() in ('NOTSET', 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'):
raise argparse.ArgumentTypeError("{0} is not a valid log level".format(repr(arg)))
return getattr(logging, arg.upper())
|
module function_definition identifier parameters identifier block if_statement not_operator comparison_operator call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier return_statement call identifier argument_list identifier call attribute identifier identifier argument_list
|
An argparse type representing a logging level.
|
def _compute_product(map1, map2):
data = map1.data * map2.data
return HpxMap(data, map1.hpx)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier return_statement call identifier argument_list identifier attribute identifier identifier
|
Make a map that is the product of two maps
|
def parse_swf (url_data):
linkfinder = linkparse.swf_url_re.finditer
for mo in linkfinder(url_data.get_content()):
url = mo.group()
url_data.add_url(url)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier
|
Parse a SWF file for URLs.
|
def print_subtree(self, fobj=sys.stdout, level=0):
fobj.write("{}{!r}\n".format(" " * (level * 2), self))
for child in self.get_children():
child.print_subtree(fobj, level + 1)
|
module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier default_parameter identifier integer block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression binary_operator identifier integer identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier binary_operator identifier integer
|
Print this group node and the subtree rooted at it
|
def addFileAnnot(self, point, buffer, filename, ufilename=None, desc=None):
CheckParent(self)
val = _fitz.Page_addFileAnnot(self, point, buffer, filename, ufilename, desc)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = val
return val
|
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier if_statement not_operator identifier block return_statement expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier call identifier argument_list identifier identifier return_statement identifier
|
Add a 'FileAttachment' annotation at location 'point'.
|
def dirBrowser(self):
if capable.OF_TKFD_IN_EPAR:
fname = askdirectory(parent=self.entry, title="Select Directory")
else:
raise NotImplementedError('Fix popupChoices() logic.')
if not fname:
return
self.choice.set(fname)
self.lastSelection = None
|
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator identifier block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier none
|
Invoke a tkinter directory dialog
|
def _service_by_name(name):
services = _available_services()
name = name.lower()
if name in services:
return services[name]
for service in six.itervalues(services):
if service['file_path'].lower() == name:
return service
basename, ext = os.path.splitext(service['filename'])
if basename.lower() == name:
return service
return False
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier identifier block return_statement subscript identifier identifier for_statement identifier call attribute identifier identifier argument_list identifier block if_statement comparison_operator call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier block return_statement identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator call attribute identifier identifier argument_list identifier block return_statement identifier return_statement false
|
Return the service info for a service by label, filename or path
|
def WritePathInfos(self, client_id, path_infos):
try:
self._MultiWritePathInfos({client_id: path_infos})
except MySQLdb.IntegrityError as error:
raise db.UnknownClientError(client_id=client_id, cause=error)
|
module function_definition identifier parameters identifier identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list dictionary pair identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block raise_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
|
Writes a collection of path_info records for a client.
|
def volumes_delete(storage_pool, logger):
try:
for vol_name in storage_pool.listVolumes():
try:
vol = storage_pool.storageVolLookupByName(vol_name)
vol.delete(0)
except libvirt.libvirtError:
logger.exception(
"Unable to delete storage volume %s.", vol_name)
except libvirt.libvirtError:
logger.exception("Unable to delete storage volumes.")
|
module function_definition identifier parameters identifier identifier block try_statement block for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
|
Deletes all storage volume disks contained in the given storage pool.
|
def _step(self, theme, direction):
if not self.themes:
self.reload()
key = (theme.source, theme.name)
for i, val in enumerate(self.themes):
if (val.source, val.name) == key:
index = i
break
else:
self.themes.insert(0, theme)
index = 0
index = (index + direction) % len(self.themes)
new_theme = self.themes[index]
return new_theme
|
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier tuple attribute identifier identifier attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block if_statement comparison_operator tuple attribute identifier identifier attribute identifier identifier identifier block expression_statement assignment identifier identifier break_statement else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list integer identifier expression_statement assignment identifier integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier return_statement identifier
|
Traverse the list in the given direction and return the next theme
|
def remove_empty_dirs(path):
for root, dirs, files in os.walk(path):
for d in dirs:
dir_path = os.path.join(root, d)
if not os.listdir(dir_path):
os.rmdir(dir_path)
|
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
|
removes empty dirs under a given path
|
def _showError(self, msg="", title="Error"):
self.errorWidget.setError(msg=msg, title=title)
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
|
Shows an error message.
|
async def make_default_options_response(self) -> Response:
methods = _request_ctx_stack.top.url_adapter.allowed_methods()
return self.response_class('', headers={'Allow': ', '.join(methods)})
|
module function_definition identifier parameters identifier type identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list return_statement call attribute identifier identifier argument_list string string_start string_end keyword_argument identifier dictionary pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier
|
This is the default route function for OPTIONS requests.
|
def pack(self):
diag = (self.ver << 5) + self.diag
flags = (self.state << 6) + self.flags
length = len(self)
return struct.pack(self._PACK_STR, diag, flags, self.detect_mult,
length, self.my_discr, self.your_discr,
self.desired_min_tx_interval,
self.required_min_rx_interval,
self.required_min_echo_rx_interval)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier integer attribute identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier integer attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier identifier identifier attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
|
Encode a BFD Control packet without authentication section.
|
def announce(self, number):
self.client.publish(self.keys.internal, self.keys.key(number))
self.message('{} granted'.format(number))
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
|
Announce an indicator change on both channels.
|
def _bsecurate_cli_make_graph_file(args):
curate.make_graph_file(args.basis, args.outfile, args.render, args.version, args.data_dir)
return ''
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement string string_start string_end
|
Handles the make-graph-file subcommand
|
def our_IsUsableForDesktopGUI(m):
if guess_bitDepth(Q.CGDisplayModeCopyPixelEncoding(m)) != 24:
return False
if Q.CGDisplayModeGetWidth(m) < 640:
return False
if Q.CGDisplayModeGetHeight(m) < 480:
return False
return True
|
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list call attribute identifier identifier argument_list identifier integer block return_statement false if_statement comparison_operator call attribute identifier identifier argument_list identifier integer block return_statement false if_statement comparison_operator call attribute identifier identifier argument_list identifier integer block return_statement false return_statement true
|
A more leniant version of CGDisplayModeIsUsableForDesktopGUI
|
def print_stats(img):
stat = ImageStat.Stat(img)
print("extrema : ", stat.extrema)
print("count : ", stat.count)
print("sum : ", stat.sum)
print("sum2 : ", stat.sum2)
print("mean : ", stat.mean)
print("median : ", stat.median)
print("rms : ", stat.rms)
print("var : ", stat.var)
print("stddev : ", stat.stddev)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier
|
prints stats, remember that img should already have been loaded
|
def H(self) -> 'Kraus':
operators = [op.H for op in self.operators]
return Kraus(operators, self.weights)
|
module function_definition identifier parameters identifier type string string_start string_content string_end block expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier return_statement call identifier argument_list identifier attribute identifier identifier
|
Return the complex conjugate of this Kraus operation
|
def bind_model_cls(self, model_cls):
if self.model_cls:
raise errors.Error('"{0}" has been already bound to "{1}" and '
'could not be rebound to "{2}"'.format(
self, self.model_cls, model_cls))
self.model_cls = model_cls
return self
|
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block raise_statement call attribute identifier identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
|
Bind field to model class.
|
def invalidate(self):
if self._invalidated:
return
else:
self._invalidated = True
self.on_invalidate.fire()
if self.eventloop is not None:
def redraw():
self._invalidated = False
self._redraw()
if self.max_render_postpone_time:
_max_postpone_until = time.time() + self.max_render_postpone_time
else:
_max_postpone_until = None
self.eventloop.call_from_executor(
redraw, _max_postpone_until=_max_postpone_until)
|
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement else_clause block expression_statement assignment attribute identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier none block function_definition identifier parameters block expression_statement assignment attribute identifier identifier false expression_statement call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier none expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier
|
Thread safe way of sending a repaint trigger to the input event loop.
|
def delete_all_versions(self, model_name, obj_pk):
if self.cache:
for version in self.versions:
key = self.key_for(version, model_name, obj_pk)
self.cache.delete(key)
|
module function_definition identifier parameters identifier identifier identifier block if_statement attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Delete all versions of a cached instance.
|
def print_preview(self):
from qtpy.QtPrintSupport import QPrintPreviewDialog
editor = self.get_current_editor()
printer = Printer(mode=QPrinter.HighResolution,
header_font=self.get_plugin_font('printer_header'))
preview = QPrintPreviewDialog(printer, self)
preview.setWindowFlags(Qt.Window)
preview.paintRequested.connect(lambda printer: editor.print_(printer))
self.redirect_stdio.emit(False)
preview.exec_()
self.redirect_stdio.emit(True)
|
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list lambda lambda_parameters identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list false expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list true
|
Print preview for current file
|
def parse_volumedetect_stats(self):
logger.info(
"Running first pass volumedetect filter for stream {}".format(self.stream_id)
)
filter_str = '[0:{}]volumedetect'.format(self.stream_id)
cmd = [
self.media_file.ffmpeg_normalize.ffmpeg_exe, '-nostdin', '-y',
'-i', self.media_file.input_file,
'-filter_complex', filter_str,
'-vn', '-sn', '-f', 'null', NUL
]
cmd_runner = CommandRunner(cmd)
for progress in cmd_runner.run_ffmpeg_command():
yield progress
output = cmd_runner.get_output()
logger.debug("Volumedetect command output:")
logger.debug(output)
mean_volume_matches = re.findall(r"mean_volume: ([\-\d\.]+) dB", output)
if mean_volume_matches:
self.loudness_statistics['mean'] = float(mean_volume_matches[0])
else:
raise FFmpegNormalizeError(
"Could not get mean volume for {}".format(self.media_file.input_file)
)
max_volume_matches = re.findall(r"max_volume: ([\-\d\.]+) dB", output)
if max_volume_matches:
self.loudness_statistics['max'] = float(max_volume_matches[0])
else:
raise FFmpegNormalizeError(
"Could not get max volume for {}".format(self.media_file.input_file)
)
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier list attribute attribute attribute identifier identifier identifier identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end attribute attribute identifier identifier identifier string string_start string_content string_end identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement yield identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list subscript identifier integer else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list subscript identifier integer else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier
|
Use ffmpeg with volumedetect filter to get the mean volume of the input file.
|
def PauseHunt(hunt_id, reason=None):
hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id)
if hunt_obj.hunt_state != hunt_obj.HuntState.STARTED:
raise OnlyStartedHuntCanBePausedError(hunt_obj)
data_store.REL_DB.UpdateHuntObject(
hunt_id, hunt_state=hunt_obj.HuntState.PAUSED, hunt_state_comment=reason)
data_store.REL_DB.RemoveForemanRule(hunt_id=hunt_obj.hunt_id)
return data_store.REL_DB.ReadHuntObject(hunt_id)
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block raise_statement call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Pauses a hunt with a given id.
|
def visit_Str(self, node: AST, dfltChaining: bool = True) -> str:
return repr(node.s)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier true type identifier block return_statement call identifier argument_list attribute identifier identifier
|
Return `node`s string representation.
|
def reset(self):
for index in range(self.counts_len):
self.counts[index] = 0
self.total_count = 0
self.min_value = sys.maxsize
self.max_value = 0
self.start_time_stamp_msec = sys.maxsize
self.end_time_stamp_msec = 0
|
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier integer
|
Reset the histogram to a pristine state
|
def create_default_config():
config = configparser.RawConfigParser()
config.add_section('global')
config.set('global', 'env_source_rc', False)
config.add_section('shell')
config.set('shell', 'bash', "true")
config.set('shell', 'zsh', "true")
config.set('shell', 'gui', "true")
return config
|
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end false expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end return_statement identifier
|
Create a default configuration object, with all parameters filled
|
def append_string(t, string):
node = t.tree
if string:
if len(node) == 0:
if node.text is not None:
node.text += string
else:
node.text = string
else:
child = list(node)[-1]
if child.tail is not None:
child.tail += string
else:
child.tail = string
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement identifier block if_statement comparison_operator call identifier argument_list identifier integer block if_statement comparison_operator attribute identifier identifier none block expression_statement augmented_assignment attribute identifier identifier identifier else_clause block expression_statement assignment attribute identifier identifier identifier else_clause block expression_statement assignment identifier subscript call identifier argument_list identifier unary_operator integer if_statement comparison_operator attribute identifier identifier none block expression_statement augmented_assignment attribute identifier identifier identifier else_clause block expression_statement assignment attribute identifier identifier identifier
|
Append a string to a node, as text or tail of last child.
|
def do(self, command, files=None, use_long_polling=False, request_timeout=None, **query):
url, params = self._prepare_request(command, query)
return {
"url": url, "params": params, "files": files, "stream": use_long_polling,
"verify": True,
"timeout": request_timeout
}
|
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier false default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier return_statement dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end true pair string string_start string_content string_end identifier
|
Return the request params we would send to the api.
|
def allowed_transitions():
try:
sdp_state = SDPState()
return sdp_state.allowed_target_states[sdp_state.current_state]
except KeyError:
LOG.error("Key Error")
return dict(state="KeyError", reason="KeyError")
|
module function_definition identifier parameters block try_statement block expression_statement assignment identifier call identifier argument_list return_statement subscript attribute identifier identifier attribute identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
|
Get target states allowed for the current state.
|
def _build_menu(self, context_menu: QMenu):
logger.debug("Show tray icon enabled in settings: {}".format(cm.ConfigManager.SETTINGS[cm.SHOW_TRAY_ICON]))
self._fill_context_menu_with_model_item_actions(context_menu)
context_menu.addAction(self.action_view_script_error)
context_menu.addAction(self.action_enable_monitoring)
context_menu.addAction(self.action_hide_icon)
context_menu.addAction(self.action_show_config_window)
context_menu.addAction(self.action_quit)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript attribute attribute identifier identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier
|
Build the context menu.
|
def build(self, builder):
params = dict(ODMVersion="1.3",
FileType=self.filetype,
CreationDateTime=self.creationdatetime,
Originator=self.originator,
FileOID=self.fileoid,
xmlns="http://www.cdisc.org/ns/odm/v1.3",
)
if self.granularity_type:
params['Granularity'] = self.granularity_type.value
if self.source_system:
params['SourceSystem'] = self.source_system
if self.source_system_version:
params['SourceSystemVersion'] = self.source_system_version
params['xmlns:mdsol'] = "http://www.mdsol.com/ns/odm/metadata"
if self.description:
params['Description'] = self.description
builder.start("ODM", params)
if self.study is not None:
self.study.build(builder)
if self.clinical_data:
for clinical_data in self.clinical_data:
clinical_data.build(builder)
if self.admindata is not None:
self.admindata.build(builder)
builder.end("ODM")
return builder.close()
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list
|
Build XML object, return the root, this is a copy for consistency and testing
|
def create_rbd_image(service, pool, image, sizemb):
cmd = ['rbd', 'create', image, '--size', str(sizemb), '--id', service,
'--pool', pool]
check_call(cmd)
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end identifier string string_start string_content string_end identifier expression_statement call identifier argument_list identifier
|
Create a new RADOS block device.
|
def record_received(self, msg):
release_lock = False
userdata = msg.userdata
rec = ALDBRecord.create_from_userdata(userdata)
self._records[rec.mem_addr] = rec
_LOGGER.debug('ALDB Record: %s', rec)
rec_count = self._load_action.rec_count
if rec_count == 1 or self._have_all_records():
release_lock = True
if self._is_first_record(rec):
self._mem_addr = rec.mem_addr
if release_lock and self._rec_mgr_lock.locked():
_LOGGER.debug('Releasing lock because record received')
self._rec_mgr_lock.release()
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier false expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement boolean_operator comparison_operator identifier integer call attribute identifier identifier argument_list block expression_statement assignment identifier true if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement boolean_operator identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list
|
Handle ALDB record received from device.
|
def jsonhash(obj, root=True, exclude=None, hash_func=_jsonhash_sha1):
if isinstance(obj, Mapping):
if root and exclude:
obj = {k: v for k, v in obj.iteritems() if k not in exclude}
result = sorted(
(k, jsonhash(v, False)) for k, v in obj.iteritems())
elif isinstance(obj, list):
result = tuple(jsonhash(e, False) for e in obj)
else:
result = obj
if root:
result = unicode(hash_func(result))
return result
|
module function_definition identifier parameters identifier default_parameter identifier true default_parameter identifier none default_parameter identifier identifier block if_statement call identifier argument_list identifier identifier block if_statement boolean_operator identifier identifier block expression_statement assignment identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list if_clause comparison_operator identifier identifier expression_statement assignment identifier call identifier generator_expression tuple identifier call identifier argument_list identifier false for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier generator_expression call identifier argument_list identifier false for_in_clause identifier identifier else_clause block expression_statement assignment identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier return_statement identifier
|
calculate the objects hash based on all field values
|
def to_header(self):
result = []
for value, quality in self:
if quality != 1:
value = '%s;q=%s' % (value, quality)
result.append(value)
return ','.join(result)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier identifier block if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier
|
Convert the header set into an HTTP header string.
|
def _inherited_row(row, base_rows_from_pillar, ret):
base_rows = []
for base_row_from_pillar in base_rows_from_pillar:
base_row = __salt__['pillar.get'](base_row_from_pillar)
if base_row:
base_rows.append(base_row)
elif base_row_from_pillar != _DEFAULT_ROW_PILLAR:
ret.setdefault('warnings', [])
warning_message = 'Cannot find row pillar "{0}".'.format(
base_row_from_pillar)
if warning_message not in ret['warnings']:
ret['warnings'].append(warning_message)
base_rows.append(row)
result_row = {}
for row in base_rows:
result_row.update(row)
return result_row
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end list expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator identifier subscript identifier string string_start string_content string_end block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Return a row with properties from parents.
|
def _clear_expired_zones(self):
zones = []
for z in list(self._zones.keys()):
zones += [z]
for z in zones:
if self._zones[z].status != Zone.CLEAR and self._zone_expired(z):
self._update_zone(z, Zone.CLEAR)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block expression_statement augmented_assignment identifier list identifier for_statement identifier identifier block if_statement boolean_operator comparison_operator attribute subscript attribute identifier identifier identifier identifier attribute identifier identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier
|
Update zone status for all expired zones.
|
def DomainFactory(domain_name, cmds):
klass = type(str(domain_name), (BaseDomain,), {})
for c in cmds:
command = get_command(domain_name, c['name'])
setattr(klass, c['name'], classmethod(command))
return klass
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier tuple identifier dictionary for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier subscript identifier string string_start string_content string_end expression_statement call identifier argument_list identifier subscript identifier string string_start string_content string_end call identifier argument_list identifier return_statement identifier
|
Dynamically create Domain class and set it's methods.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.