code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
async def send(self, *args, **kwargs):
if not self.frozen:
raise RuntimeError("Cannot send non-frozen signal.")
for receiver in self:
await receiver(*args, **kwargs)
|
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement await call identifier argument_list list_splat identifier dictionary_splat identifier
|
Sends data to all registered receivers.
|
def main(directories):
msg = 'Checking module "{}" from directory "{}" for coding errors.'
api_checker = ApiChecker()
resource_checker = ResourceChecker()
errors = []
modules = []
for loader, mname, _ in pkgutil.walk_packages(directories):
sys.path.append(os.path.abspath(loader.path))
log.info(msg.format(mname, loader.path))
modules.append(mname)
import_module(mname)
for api in Api:
if api.__module__.split('.')[-1] not in modules:
continue
log.debug('Anlysing Api class: {}'.format(api.__name__))
errors.extend(api_checker(api))
for res in Resource:
if res.__module__.split('.')[-1] not in modules:
continue
log.debug('Anlysing Resource class: {}'.format(res.__name__))
errors.extend(resource_checker(res))
else:
log.info('All modules tested, no problem detected.')
return errors
|
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier list expression_statement assignment identifier list for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end unary_operator integer identifier block continue_statement 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 call attribute identifier identifier argument_list call identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end unary_operator integer identifier block continue_statement 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 call attribute identifier identifier argument_list call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
|
Perform all checks on the API's contained in `directory`.
|
def _from_string(cls, serialized):
course_key = CourseLocator._from_string(serialized)
parsed_parts = cls.parse_url(serialized)
block_id = parsed_parts.get('block_id', None)
if block_id is None:
raise InvalidKeyError(cls, serialized)
return cls(course_key, parsed_parts.get('block_type'), block_id)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none if_statement comparison_operator identifier none block raise_statement call identifier argument_list identifier identifier return_statement call identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier
|
Requests CourseLocator to deserialize its part and then adds the local deserialization of block
|
def load_data_to_net(net, inst_net):
net.dat['nodes'] = inst_net['nodes']
net.dat['mat'] = inst_net['mat']
data_formats.mat_to_numpy_arr(net)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
|
load data into nodes and mat, also convert mat to numpy array
|
def close(self, code: int = None, reason: str = None) -> None:
if not self.server_terminated:
if not self.stream.closed():
if code is None and reason is not None:
code = 1000
if code is None:
close_data = b""
else:
close_data = struct.pack(">H", code)
if reason is not None:
close_data += utf8(reason)
try:
self._write_frame(True, 0x8, close_data)
except StreamClosedError:
self._abort()
self.server_terminated = True
if self.client_terminated:
if self._waiting is not None:
self.stream.io_loop.remove_timeout(self._waiting)
self._waiting = None
self.stream.close()
elif self._waiting is None:
self._waiting = self.stream.io_loop.add_timeout(
self.stream.io_loop.time() + 5, self._abort
)
|
module function_definition identifier parameters identifier typed_default_parameter identifier type identifier none typed_default_parameter identifier type identifier none type none block if_statement not_operator attribute identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none block expression_statement assignment identifier integer if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_end else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier call identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list true integer identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier true if_statement attribute identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier none expression_statement call attribute attribute identifier identifier identifier argument_list elif_clause comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list binary_operator call attribute attribute attribute identifier identifier identifier identifier argument_list integer attribute identifier identifier
|
Closes the WebSocket connection.
|
def remove_checksum(path):
path = '{}.md5sum'.format(path)
if os.path.exists(path):
os.remove(path)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Remove the checksum of an image from cache if exists
|
def grow(self):
"Add another worker to the pool."
t = self.worker_factory(self)
t.start()
self._size += 1
|
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement augmented_assignment attribute identifier identifier integer
|
Add another worker to the pool.
|
async def set_config(self, on=None, long=None, lat=None,
sunriseoffset=None, sunsetoffset=None):
data = {
key: value for key, value in {
'on': on,
'long': long,
'lat': lat,
'sunriseoffset': sunriseoffset,
'sunsetoffset': sunsetoffset,
}.items() if value is not None
}
await self._request('put', 'sensors/{}/config'.format(self.id),
json=data)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute 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 identifier identifier argument_list if_clause comparison_operator identifier none expression_statement await call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier keyword_argument identifier identifier
|
Change config of a Daylight sensor.
|
def _earth_orientation(date):
ttt = date.change_scale('TT').julian_century
s_prime = - 0.000047 * ttt
return date.eop.x / 3600., date.eop.y / 3600., s_prime / 3600
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier binary_operator unary_operator float identifier return_statement expression_list binary_operator attribute attribute identifier identifier identifier float binary_operator attribute attribute identifier identifier identifier float binary_operator identifier integer
|
Earth orientation parameters in degrees
|
def expanded_transform(self):
segments = self._expand_transform(self.transform)
if segments:
segments[0]['datatype'] = self.valuetype_class
for s in segments:
s['column'] = self
else:
segments = [self.make_xform_seg(datatype=self.valuetype_class, column=self)]
return segments
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement identifier block expression_statement assignment subscript subscript identifier integer string string_start string_content string_end attribute identifier identifier for_statement identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier else_clause block expression_statement assignment identifier list call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier return_statement identifier
|
Expands the transform string into segments
|
def callback(self, provider):
provider = self.get_provider(provider)
try:
return provider.authorized_handler(self.login)(provider=provider)
except OAuthException as ex:
logging.error("Data: %s", ex.data)
raise
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block return_statement call call attribute identifier identifier argument_list attribute identifier identifier argument_list keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier raise_statement
|
Handles 3rd party callback and processes it's data
|
async def home_z(self, mount: top_types.Mount = None):
if not mount:
axes = [Axis.Z, Axis.A]
else:
axes = [Axis.by_mount(mount)]
await self.home(axes)
|
module function_definition identifier parameters identifier typed_default_parameter identifier type attribute identifier identifier none block if_statement not_operator identifier block expression_statement assignment identifier list attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier list call attribute identifier identifier argument_list identifier expression_statement await call attribute identifier identifier argument_list identifier
|
Home the two z-axes
|
def open( self, **kwargs ):
if self.tag in self.parent.twotags or self.tag in self.parent.onetags:
self.render( self.tag, False, None, kwargs )
elif self.mode == 'strict_html' and self.tag in self.parent.deptags:
raise DeprecationError( self.tag )
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block if_statement boolean_operator comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier false none identifier elif_clause boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block raise_statement call identifier argument_list attribute identifier identifier
|
Append an opening tag.
|
def render_label(content, label_for=None, label_class=None, label_title=""):
attrs = {}
if label_for:
attrs["for"] = label_for
if label_class:
attrs["class"] = label_class
if label_title:
attrs["title"] = label_title
return render_tag("label", attrs=attrs, content=content)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier string string_start string_end block expression_statement assignment identifier dictionary if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier
|
Render a label with content
|
def draw_commands(self, surf):
past_abilities = {act.ability for act in self._past_actions if act.ability}
for y, cmd in enumerate(sorted(self._abilities(
lambda c: c.name != "Smart"), key=lambda c: c.name), start=2):
if self._queued_action and cmd == self._queued_action:
color = colors.green
elif self._queued_hotkey and cmd.hotkey.startswith(self._queued_hotkey):
color = colors.green * 0.75
elif cmd.ability_id in past_abilities:
color = colors.red
else:
color = colors.yellow
hotkey = cmd.hotkey[0:3]
surf.write_screen(self._font_large, color, (0.2, y), hotkey)
surf.write_screen(self._font_large, color, (3, y), cmd.name)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier set_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier if_clause attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list lambda lambda_parameters identifier comparison_operator attribute identifier identifier string string_start string_content string_end keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier keyword_argument identifier integer block if_statement boolean_operator attribute identifier identifier comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier elif_clause boolean_operator attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier float elif_clause comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier subscript attribute identifier identifier slice integer integer expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier tuple float identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier tuple integer identifier attribute identifier identifier
|
Draw the list of available commands.
|
def _update_clipper(self):
if self.clip_children and self._clipper is None:
self._clipper = Clipper()
elif not self.clip_children:
self._clipper = None
if self._clipper is None:
return
self._clipper.rect = self.inner_rect
self._clipper.transform = self.get_transform('framebuffer', 'visual')
|
module function_definition identifier parameters identifier block if_statement boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list elif_clause not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier none if_statement comparison_operator attribute identifier identifier none block return_statement expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end
|
Called whenever the clipper for this widget may need to be updated.
|
def render_url(self):
url = self.url.format(**self.replacements)
if self.params:
return url + '?' + urlencode(self.params)
return url
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat attribute identifier identifier if_statement attribute identifier identifier block return_statement binary_operator binary_operator identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier return_statement identifier
|
Render the final URL based on available variables
|
def add_bgp_error_metadata(code, sub_code, def_desc='unknown'):
if _EXCEPTION_REGISTRY.get((code, sub_code)) is not None:
raise ValueError('BGPSException with code %d and sub-code %d '
'already defined.' % (code, sub_code))
def decorator(subclass):
if issubclass(subclass, BGPSException):
_EXCEPTION_REGISTRY[(code, sub_code)] = subclass
subclass.CODE = code
subclass.SUB_CODE = sub_code
subclass.DEF_DESC = def_desc
return subclass
return decorator
|
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block if_statement comparison_operator call attribute identifier identifier argument_list tuple identifier identifier none block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple identifier identifier function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment subscript identifier tuple identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier return_statement identifier
|
Decorator for all exceptions that want to set exception class meta-data.
|
def _combined_wildcards_iter(flatterm: Iterator[TermAtom]) -> Iterator[TermAtom]:
last_wildcard = None
for term in flatterm:
if isinstance(term, Wildcard) and not isinstance(term, SymbolWildcard):
if last_wildcard is not None:
new_min_count = last_wildcard.min_count + term.min_count
new_fixed_size = last_wildcard.fixed_size and term.fixed_size
last_wildcard = Wildcard(new_min_count, new_fixed_size)
else:
last_wildcard = Wildcard(term.min_count, term.fixed_size)
else:
if last_wildcard is not None:
yield last_wildcard
last_wildcard = None
yield term
if last_wildcard is not None:
yield last_wildcard
|
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier none for_statement identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier not_operator call identifier argument_list identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier boolean_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier else_clause block if_statement comparison_operator identifier none block expression_statement yield identifier expression_statement assignment identifier none expression_statement yield identifier if_statement comparison_operator identifier none block expression_statement yield identifier
|
Combine consecutive wildcards in a flatterm into a single one.
|
def ConsultarTipoRetencion(self, sep="||"):
"Consulta de tipos de Retenciones."
ret = self.client.tipoRetencionConsultar(
auth={
'token': self.Token, 'sign': self.Sign,
'cuit': self.Cuit, },
)['tipoRetencionReturn']
self.__analizar_errores(ret)
array = ret.get('tiposRetencion', [])
return [("%s %%s %s %%s %s" % (sep, sep, sep)) %
(it['codigoDescripcion']['codigo'],
it['codigoDescripcion']['descripcion'])
for it in array]
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement string string_start string_content string_end expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list keyword_argument identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier 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 list return_statement list_comprehension binary_operator parenthesized_expression binary_operator string string_start string_content string_end tuple identifier identifier identifier tuple subscript subscript identifier string string_start string_content string_end string string_start string_content string_end subscript subscript identifier string string_start string_content string_end string string_start string_content string_end for_in_clause identifier identifier
|
Consulta de tipos de Retenciones.
|
def add_package(self, check_name, package):
self._package_set.add(package)
package_data = self._packages[package.name]
self._checks_deps[check_name].append(package)
if package.version:
versions = package_data['versions']
versions[package.version].append(check_name)
if package.marker:
markers = package_data['markers']
markers[package.marker].append(check_name)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement call attribute subscript identifier attribute identifier identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement call attribute subscript identifier attribute identifier identifier identifier argument_list identifier
|
Add a Package to the catalog for the given check
|
def _increment(self, n=1):
if self._cur_position >= self.num_tokens-1:
self._cur_positon = self.num_tokens - 1
self._finished = True
else:
self._cur_position += n
|
module function_definition identifier parameters identifier default_parameter identifier integer block if_statement comparison_operator attribute identifier identifier binary_operator attribute identifier identifier integer block expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier integer expression_statement assignment attribute identifier identifier true else_clause block expression_statement augmented_assignment attribute identifier identifier identifier
|
Move forward n tokens in the stream.
|
def search_browser(self, text):
self.impl.get(self.base_url)
search_div = self.impl.find_element_by_id("search")
search_term = search_div.find_element_by_id("term")
search_term.send_keys(text)
search_div.find_element_by_id("submit").click()
e = self.impl.find_element_by_css_selector("table.list tr td a")
return e.get_attribute("href")
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list string string_start string_content string_end
|
do a slow search via the website and return the first match
|
def pcap_name(self, devname):
try:
pcap_name = self.data[devname].pcap_name
except KeyError:
raise ValueError("Unknown network interface %r" % devname)
else:
return pcap_name
|
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier attribute subscript attribute identifier identifier identifier identifier except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier else_clause block return_statement identifier
|
Return pcap device name for given Windows device name.
|
def op_symbol(op_node):
ops = {
ast.UAdd: '+',
ast.USub: '-',
ast.Add: '+',
ast.Sub: '-',
ast.Mult: '*',
ast.Div: '/',
ast.Mod: '%',
ast.Eq: '=',
ast.NotEq: '!=',
ast.Lt: '<',
ast.LtE: '<=',
ast.Gt: '>',
ast.GtE: '>=',
}
if hasattr(ast, 'MatMult'):
ops[ast.MatMult] = '*'
return ops[op_node.__class__]
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair attribute identifier identifier string string_start string_content string_end pair attribute identifier identifier string string_start string_content string_end pair attribute identifier identifier string string_start string_content string_end pair attribute identifier identifier string string_start string_content string_end pair attribute identifier identifier string string_start string_content string_end pair attribute identifier identifier string string_start string_content string_end pair attribute identifier identifier string string_start string_content string_end pair attribute identifier identifier string string_start string_content string_end pair attribute identifier identifier string string_start string_content string_end pair attribute identifier identifier string string_start string_content string_end pair attribute identifier identifier string string_start string_content string_end pair attribute identifier identifier string string_start string_content string_end pair attribute identifier identifier string string_start string_content string_end if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment subscript identifier attribute identifier identifier string string_start string_content string_end return_statement subscript identifier attribute identifier identifier
|
Get the GLSL symbol for a Python operator.
|
def clear_caches(self):
for element_name in dir(self.components):
element = getattr(self.components, element_name)
if hasattr(element, 'cache_val'):
delattr(element, 'cache_val')
|
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call identifier argument_list identifier string string_start string_content string_end
|
Clears the Caches for all model elements
|
def revnet_base():
hparams = common_hparams.basic_params1()
hparams.add_hparam('num_channels', [64, 128, 256, 416])
hparams.add_hparam('num_layers_per_block', [1, 1, 10, 1])
hparams.add_hparam('bottleneck', True)
hparams.add_hparam('first_batch_norm', [False, True, True, True])
hparams.add_hparam('init_stride', 2)
hparams.add_hparam('init_kernel_size', 7)
hparams.add_hparam('init_maxpool', True)
hparams.add_hparam('strides', [1, 2, 2, 2])
hparams.add_hparam('num_channels_init_block', 64)
hparams.add_hparam('dim', '2d')
hparams.initializer = 'normal_unit_scaling'
hparams.initializer_gain = 2.
hparams.optimizer = 'Momentum'
hparams.optimizer_momentum_momentum = 0.9
hparams.optimizer_momentum_nesterov = True
hparams.weight_decay = 1e-4
hparams.clip_grad_norm = 0.0
hparams.learning_rate = 0.4
hparams.learning_rate_decay_scheme = 'cosine'
hparams.learning_rate_cosine_cycle_steps = 120000
hparams.batch_size = 128
return hparams
|
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 list integer integer integer integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end list integer integer integer integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end list false true true true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end list integer integer integer integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier float expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier float expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier float expression_statement assignment attribute identifier identifier float expression_statement assignment attribute identifier identifier float expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer return_statement identifier
|
Default hparams for Revnet.
|
def to_unix_ts(start_time):
if isinstance(start_time, datetime):
if is_timezone_aware(start_time):
start_time = start_time.astimezone(pytz.utc)
else:
log.warning(
"Non timezone-aware datetime object passed to IncrementalEndpoint. "
"The Zendesk API expects UTC time, if this is not the case results will be incorrect!"
)
unix_time = calendar.timegm(start_time.timetuple())
else:
unix_time = start_time
return int(unix_time)
|
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block if_statement call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier identifier return_statement call identifier argument_list identifier
|
Given a datetime object, returns its value as a unix timestamp
|
def setOutputObject(self, newOutput=output.CalcpkgOutput(True, True)):
self.output = newOutput
|
module function_definition identifier parameters identifier default_parameter identifier call attribute identifier identifier argument_list true true block expression_statement assignment attribute identifier identifier identifier
|
Set an object where all output from calcpkg will be redirected to for this repository
|
def print_region_quota(access_token, sub_id, region):
print(region + ':')
quota = azurerm.get_compute_usage(access_token, sub_id, region)
if SUMMARY is False:
print(json.dumps(quota, sort_keys=False, indent=2, separators=(',', ': ')))
try:
for resource in quota['value']:
if resource['name']['value'] == 'cores':
print(' Current: ' + str(resource['currentValue']) + ', limit: '
+ str(resource['limit']))
break
except KeyError:
print('Invalid data for region: ' + region)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list binary_operator identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier if_statement comparison_operator identifier false block expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier false keyword_argument identifier integer keyword_argument identifier tuple string string_start string_content string_end string string_start string_content string_end try_statement block for_statement identifier subscript identifier string string_start string_content string_end block if_statement comparison_operator subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement call identifier argument_list binary_operator binary_operator binary_operator string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end break_statement except_clause identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
|
Print the Compute usage quota for a specific region
|
def get(self, namespace, key):
cfg = self.dbconfig.get(key, namespace, as_object=True)
return self.make_response({
'message': None,
'config': cfg
})
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier true return_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end none pair string string_start string_content string_end identifier
|
Get a specific configuration item
|
def onchain_exchange(self, withdraw_crypto, withdraw_address, value, unit='satoshi'):
self.onchain_rate = get_onchain_exchange_rates(
self.crypto, withdraw_crypto, best=True, verbose=self.verbose
)
exchange_rate = float(self.onchain_rate['rate'])
result = self.onchain_rate['service'].get_onchain_exchange_address(
self.crypto, withdraw_crypto, withdraw_address
)
address = result['deposit']
value_satoshi = self.from_unit_to_satoshi(value, unit)
if self.verbose:
print("Adding output of: %s satoshi (%.8f) via onchain exchange, converting to %s %s" % (
value_satoshi, (value_satoshi / 1e8),
exchange_rate * value_satoshi / 1e8, withdraw_crypto.upper()
))
self.outs.append({
'address': address,
'value': value_satoshi
})
|
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier identifier keyword_argument identifier true keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list attribute identifier identifier identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement attribute identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier parenthesized_expression binary_operator identifier float binary_operator binary_operator identifier identifier float call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
|
This method is like `add_output` but it sends to another
|
def spec(self):
from ambry_sources.sources import SourceSpec
d = self.dict
d['url'] = self.url
return SourceSpec(**d)
|
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list dictionary_splat identifier
|
Return a SourceSpec to describe this source
|
def bethe_fermi(energy, quasipart, shift, hopping, beta):
return fermi_dist(quasipart * energy - shift, beta) \
* bethe_lattice(energy, hopping)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block return_statement binary_operator call identifier argument_list binary_operator binary_operator identifier identifier identifier identifier line_continuation call identifier argument_list identifier identifier
|
product of the bethe lattice dos, fermi distribution
|
def _get_gcloud_sdk_credentials():
from google.auth import _cloud_sdk
credentials_filename = (
_cloud_sdk.get_application_default_credentials_path())
if not os.path.isfile(credentials_filename):
return None, None
credentials, project_id = _load_credentials_from_file(
credentials_filename)
if not project_id:
project_id = _cloud_sdk.get_project_id()
return credentials, project_id
|
module function_definition identifier parameters block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier parenthesized_expression call attribute identifier identifier argument_list if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block return_statement expression_list none none expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement expression_list identifier identifier
|
Gets the credentials and project ID from the Cloud SDK.
|
def _postprocess(valuestr):
intpattern = re.compile(r'^\-?\d+$')
floatpattern = re.compile(r'^\-?\d+\.\d+(E[+-]?\d\d+)?$')
datedtpattern = '%Y-%m-%d'
datedttimepattern = '%Y-%m-%dT%H:%M:%SZ'
timedtpattern = '%H:%M:%S.%f'
timepattern = re.compile(r'^\d{2}:\d{2}:\d{2}(\.\d{6})?')
if valuestr.startswith('"') and valuestr.endswith('"'):
return valuestr[1:-1]
elif re.match(intpattern, valuestr):
return int(valuestr)
elif re.match(floatpattern, valuestr):
return float(valuestr)
try:
return datetime.datetime.strptime(valuestr, datedtpattern).date()
except ValueError:
pass
try:
return datetime.datetime.strptime(valuestr, datedttimepattern)
except ValueError:
pass
mat = re.match(timepattern, valuestr)
if mat:
test = mat.group(0)
try:
return datetime.datetime.strptime(test, timedtpattern).time()
except ValueError:
pass
logging.info(
"The value %s couldn't be parsed as " % valuestr
+ "int, float, date, time, datetime. Returning it as string.")
return valuestr
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block return_statement subscript identifier slice integer unary_operator integer elif_clause call attribute identifier identifier argument_list identifier identifier block return_statement call identifier argument_list identifier elif_clause call attribute identifier identifier argument_list identifier identifier block return_statement call identifier argument_list identifier try_statement block return_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier identifier argument_list except_clause identifier block pass_statement try_statement block return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier except_clause identifier block pass_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer try_statement block return_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier identifier argument_list except_clause identifier block pass_statement expression_statement call attribute identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end return_statement identifier
|
Takes value as str, returns str, int, float, date, datetime, or time
|
def _get_metadata(self):
self.metadata = self.fetch_header()
self.variables = {g.name for g in self.metadata.grids}
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier set_comprehension attribute identifier identifier for_in_clause identifier attribute attribute identifier identifier identifier
|
Get header information and store as metadata for the endpoint.
|
def read(self, _file):
with open(_file) as fh:
data = fh.read()
if self.verbose:
sys.stdout.write("read %d bytes from %s\n"
% (fh.tell(), _file))
return data
|
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple call attribute identifier identifier argument_list identifier return_statement identifier
|
return local file contents as endpoint.
|
def start_logger(self):
level = self.real_level(self.level)
logging.basicConfig(level=level)
self.set_logger(self.name, self.level)
config.dictConfig(self.config)
self.logger = logging.getLogger(self.name)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier 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 expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier
|
Enables the root logger and configures extra loggers.
|
def _approximate_unkown_bond_lengths(self):
dataset = self.lengths[BOND_SINGLE]
for n1 in periodic.iter_numbers():
for n2 in periodic.iter_numbers():
if n1 <= n2:
pair = frozenset([n1, n2])
atom1 = periodic[n1]
atom2 = periodic[n2]
if (pair not in dataset) and (atom1.covalent_radius is not None) and (atom2.covalent_radius is not None):
dataset[pair] = (atom1.covalent_radius + atom2.covalent_radius)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier for_statement identifier call attribute identifier identifier argument_list block for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement assignment identifier call identifier argument_list list identifier identifier expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier subscript identifier identifier if_statement boolean_operator boolean_operator parenthesized_expression comparison_operator identifier identifier parenthesized_expression comparison_operator attribute identifier identifier none parenthesized_expression comparison_operator attribute identifier identifier none block expression_statement assignment subscript identifier identifier parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier
|
Completes the bond length database with approximations based on VDW radii
|
def status(self):
return self.repository._repo.status(self._ctx.p1().node(),
self._ctx.node())
|
module function_definition identifier parameters identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list call attribute attribute identifier identifier identifier argument_list
|
Returns modified, added, removed, deleted files for current changeset
|
def escape(self):
self.obj = self.obj.replace("&", self._html_escape_table["&"])
for i, k in enumerate(self._html_escape_table):
v = self._html_escape_table[k]
if k is not "&":
self.obj = self.obj.replace(k, v)
return self._wrap(self.obj)
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier
|
Escape a string for HTML interpolation.
|
def write_long(self, n, pack=Struct('>I').pack):
if 0 <= n <= 0xFFFFFFFF:
self._output_buffer.extend(pack(n))
else:
raise ValueError('Long %d out of range 0..0xFFFFFFFF', n)
return self
|
module function_definition identifier parameters identifier identifier default_parameter identifier attribute call identifier argument_list string string_start string_content string_end identifier block if_statement comparison_operator integer identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end identifier return_statement identifier
|
Write an integer as an unsigned 32-bit value.
|
def _get_default_annual_spacing(nyears):
if nyears < 11:
(min_spacing, maj_spacing) = (1, 1)
elif nyears < 20:
(min_spacing, maj_spacing) = (1, 2)
elif nyears < 50:
(min_spacing, maj_spacing) = (1, 5)
elif nyears < 100:
(min_spacing, maj_spacing) = (5, 10)
elif nyears < 200:
(min_spacing, maj_spacing) = (5, 25)
elif nyears < 600:
(min_spacing, maj_spacing) = (10, 50)
else:
factor = nyears // 1000 + 1
(min_spacing, maj_spacing) = (factor * 20, factor * 100)
return (min_spacing, maj_spacing)
|
module function_definition identifier parameters identifier block if_statement comparison_operator identifier integer block expression_statement assignment tuple_pattern identifier identifier tuple integer integer elif_clause comparison_operator identifier integer block expression_statement assignment tuple_pattern identifier identifier tuple integer integer elif_clause comparison_operator identifier integer block expression_statement assignment tuple_pattern identifier identifier tuple integer integer elif_clause comparison_operator identifier integer block expression_statement assignment tuple_pattern identifier identifier tuple integer integer elif_clause comparison_operator identifier integer block expression_statement assignment tuple_pattern identifier identifier tuple integer integer elif_clause comparison_operator identifier integer block expression_statement assignment tuple_pattern identifier identifier tuple integer integer else_clause block expression_statement assignment identifier binary_operator binary_operator identifier integer integer expression_statement assignment tuple_pattern identifier identifier tuple binary_operator identifier integer binary_operator identifier integer return_statement tuple identifier identifier
|
Returns a default spacing between consecutive ticks for annual data.
|
def split_by_idx(self, valid_idx:Collection[int])->'ItemLists':
"Split the data according to the indexes in `valid_idx`."
train_idx = np.setdiff1d(arange_of(self.items), valid_idx)
return self.split_by_idxs(train_idx, valid_idx)
|
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type string string_start string_content string_end block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier
|
Split the data according to the indexes in `valid_idx`.
|
def as_dict(self):
attrs = vars(self)
return {key: attrs[key] for key in attrs if not key.startswith('_')}
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement dictionary_comprehension pair identifier subscript identifier identifier for_in_clause identifier identifier if_clause not_operator call attribute identifier identifier argument_list string string_start string_content string_end
|
Package up the public attributes as a dict.
|
def on_unicode_checkbox(self, w=None, state=False):
logging.debug("unicode State is %s", state)
self.controller.smooth_graph_mode = state
if state:
self.hline = urwid.AttrWrap(
urwid.SolidFill(u'\N{LOWER ONE QUARTER BLOCK}'), 'line')
else:
self.hline = urwid.AttrWrap(urwid.SolidFill(u' '), 'line')
for graph in self.graphs.values():
graph.set_smooth_colors(state)
self.show_graphs()
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier false block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment attribute attribute identifier identifier identifier identifier if_statement identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
Enable smooth edges if utf-8 is supported
|
def _get_num_interval(config, num_pre, num_post):
post = int(num_post) if num_post else 0
pre = int(num_pre) if num_pre is not None else _get_last_snapshot(config)['id']
return pre, post
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier conditional_expression call identifier argument_list identifier identifier integer expression_statement assignment identifier conditional_expression call identifier argument_list identifier comparison_operator identifier none subscript call identifier argument_list identifier string string_start string_content string_end return_statement expression_list identifier identifier
|
Returns numerical interval based on optionals num_pre, num_post values
|
def create(
self, request, parent_lookup_seedteam=None,
parent_lookup_seedteam__organization=None):
team = self.check_team_permissions(
request, parent_lookup_seedteam,
parent_lookup_seedteam__organization)
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
permission = team.permissions.create(**serializer.validated_data)
serializer = self.get_serializer(instance=permission)
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier true expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement call identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier
|
Add a permission to a team.
|
def _poll_trigger(self):
try:
os.write(self._poll_send, '\0'.encode('utf-8'))
except Exception as e:
log = self._getparam('log', self._discard)
log.debug("Ignoring self-pipe write error -- %s", e)
|
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute identifier identifier argument_list attribute identifier identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list 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
|
Trigger activity for the caller by writting a NUL to the self-pipe.
|
def as_dict(self):
dicts = [x.as_dict for x in self.children]
return {'{0} {1}'.format(self.name, self.value): dicts}
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier return_statement dictionary pair call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier identifier
|
Return all child objects in nested dict.
|
def from_name(cls, name):
result = cls.list()
vlans = {}
for vlan in result:
vlans[vlan['name']] = vlan['id']
return vlans.get(name)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment subscript identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier
|
Retrieve vlan id associated to a name.
|
def change_column_length(table: Table, column: Column, length: int, engine: Engine) -> None:
if column.type.length < length:
print("Changing length of {} from {} to {}".format(column, column.type.length, length))
column.type.length = length
column_name = column.name
column_type = column.type.compile(engine.dialect)
engine.execute('ALTER TABLE {table} ALTER COLUMN {column_name} TYPE {column_type}'.format(**locals()))
|
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type none block if_statement comparison_operator attribute attribute identifier identifier identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute attribute identifier identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list dictionary_splat call identifier argument_list
|
Change the column length in the supplied table
|
def read_event(suppress=False):
queue = _queue.Queue(maxsize=1)
hooked = hook(queue.put, suppress=suppress)
while True:
event = queue.get()
unhook(hooked)
return event
|
module function_definition identifier parameters default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier integer expression_statement assignment identifier call identifier argument_list attribute identifier identifier keyword_argument identifier identifier while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list identifier return_statement identifier
|
Blocks until a keyboard event happens, then returns that event.
|
def fetch_deposits(self, limit: int) -> List[Deposit]:
return self._transactions(self._deposits, 'deposits', limit)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end identifier
|
Fetch latest deposits, must provide a limit.
|
def createNew(cls, store, pathSegments):
if isinstance(pathSegments, basestring):
raise ValueError(
'Received %r instead of a sequence' % (pathSegments,))
if store.dbdir is None:
self = cls(store=store, storepath=None)
else:
storepath = store.newDirectory(*pathSegments)
self = cls(store=store, storepath=storepath)
self.open()
self.close()
return self
|
module function_definition identifier parameters identifier identifier identifier block if_statement call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier none else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list list_splat identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement identifier
|
Create a new SubStore, allocating a new file space for it.
|
def rdf_source(self, aformat="turtle"):
if aformat and aformat not in self.SUPPORTED_FORMATS:
return "Sorry. Allowed formats are %s" % str(self.SUPPORTED_FORMATS)
if aformat == "dot":
return self.__serializedDot()
else:
return self.rdflib_graph.serialize(format=aformat)
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block if_statement boolean_operator identifier comparison_operator identifier attribute identifier identifier block return_statement binary_operator string string_start string_content string_end call identifier argument_list attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list else_clause block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier
|
Serialize graph using the format required
|
def from_description(cls, description, attrs):
hash_key = None
range_key = None
index_type = description["Projection"]["ProjectionType"]
includes = description["Projection"].get("NonKeyAttributes")
for data in description["KeySchema"]:
name = data["AttributeName"]
if name not in attrs:
continue
key_type = data["KeyType"]
if key_type == "HASH":
hash_key = TableField(name, attrs[name].data_type, key_type)
elif key_type == "RANGE":
range_key = TableField(name, attrs[name].data_type, key_type)
throughput = description["ProvisionedThroughput"]
return cls(
description["IndexName"],
index_type,
description["IndexStatus"],
hash_key,
range_key,
throughput["ReadCapacityUnits"],
throughput["WriteCapacityUnits"],
description.get("IndexSizeBytes", 0),
includes,
description,
)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier none expression_statement assignment identifier none expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end for_statement identifier subscript identifier string string_start string_content string_end block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator identifier identifier block continue_statement expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier attribute subscript identifier identifier identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier attribute subscript identifier identifier identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end return_statement call identifier argument_list subscript identifier string string_start string_content string_end identifier subscript identifier string string_start string_content string_end identifier identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end integer identifier identifier
|
Create an object from a dynamo3 response
|
def format_hsl(hsl_color):
hue, saturation, lightness = hsl_color
return 'hsl({}, {:.2%}, {:.2%})'.format(hue, saturation, lightness)
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier
|
Format hsl color as css color string.
|
def toggle_value(request, name):
obj = service.system.namespace.get(name, None)
if not obj or service.read_only:
raise Http404
new_status = obj.status = not obj.status
if service.redirect_from_setters:
return HttpResponseRedirect(reverse('set_ready', args=(name, new_status)))
else:
return set_ready(request, name, new_status)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier none if_statement boolean_operator not_operator identifier attribute identifier identifier block raise_statement identifier expression_statement assignment identifier assignment attribute identifier identifier not_operator attribute identifier identifier if_statement attribute identifier identifier block return_statement call identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier tuple identifier identifier else_clause block return_statement call identifier argument_list identifier identifier identifier
|
For manual shortcut links to perform toggle actions
|
def by_current_session(cls):
session = Session.current_session()
if session is None:
return None
return cls.where_id(session.user_id)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block return_statement none return_statement call attribute identifier identifier argument_list attribute identifier identifier
|
Returns current user session
|
def disconnect(self):
for name, wire in self.wires():
self.cut(name, disconnect=True)
|
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true
|
Cut all wires and disconnect all connections established on this link
|
def _walk(self, root_path='', root_id=''):
title = '%s._walk' % self.__class__.__name__
if root_id:
pass
elif root_path:
root_id, root_parent = self._get_id(root_path)
for file_id, name, mimetype in self._list_directory(root_id):
file_path = os.path.join(root_path, name)
if mimetype == 'application/vnd.google-apps.folder':
for path, id in self._walk(root_path=file_path, root_id=file_id):
yield path, id
else:
yield file_path, file_id
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier string string_start string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier if_statement identifier block pass_statement elif_clause identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier block expression_statement yield expression_list identifier identifier else_clause block expression_statement yield expression_list identifier identifier
|
a generator method which walks the file structure of the dropbox collection
|
def _complete_exit(self, cmd, args, text):
if args:
return
return [ x for x in { 'root', 'all', } \
if x.startswith(text) ]
|
module function_definition identifier parameters identifier identifier identifier identifier block if_statement identifier block return_statement return_statement list_comprehension identifier for_in_clause identifier set string string_start string_content string_end string string_start string_content string_end line_continuation if_clause call attribute identifier identifier argument_list identifier
|
Find candidates for the 'exit' command.
|
def numpyview(arr, datatype, shape, raw=False):
if raw:
return n.frombuffer(arr, dtype=n.dtype(datatype)).view(n.dtype(datatype)).reshape(shape)
else:
return n.frombuffer(arr.get_obj(), dtype=n.dtype(datatype)).view(n.dtype(datatype)).reshape(shape)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block if_statement identifier block return_statement call attribute call attribute call attribute identifier identifier argument_list identifier keyword_argument identifier call attribute identifier identifier argument_list identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier argument_list identifier else_clause block return_statement call attribute call attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier argument_list identifier
|
Takes mp shared array and returns numpy array with given shape.
|
def main(ctx, opts, version):
if version:
print_version()
elif ctx.invoked_subcommand is None:
click.echo(ctx.get_help())
|
module function_definition identifier parameters identifier identifier identifier block if_statement identifier block expression_statement call identifier argument_list elif_clause comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list
|
Handle entrypoint to CLI.
|
def __create_output_dir(base_dir):
root, tail = os.path.split(base_dir)
dir = None
if tail:
if base_dir.endswith('/'):
dir = base_dir
else:
dir = root
else:
if base_dir.endswith('/'):
dir = base_dir
if dir and not os.path.isdir(dir):
os.makedirs(dir)
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier none if_statement identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier identifier else_clause block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier identifier if_statement boolean_operator identifier not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Ensure that the output directory base_dir exists.
|
def check_spinning_children(self):
child_jobs = self.task_master.get_child_work_units(self.worker_id)
now = time.time() + self.stop_jobs_early
for child, wul in child_jobs.iteritems():
if not isinstance(wul, (list, tuple)):
wul = [wul]
if not wul:
continue
wul = filter(lambda wu: wu.worker_id == child, wul)
if any(filter(lambda wu: wu.expires > now, wul)):
continue
environment = self.task_master.get_heartbeat(child)
if not environment:
continue
if 'pid' not in environment:
continue
if environment['pid'] not in self.children:
continue
os.kill(environment['pid'], signal.SIGTERM)
for wu in wul:
if wu.data is None:
logger.critical('how did wu.data become: %r' % wu.data)
else:
wu.data['traceback'] = 'job expired'
wu.fail(exc=Exception('job expired'))
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list attribute identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement not_operator call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier list identifier if_statement not_operator identifier block continue_statement expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier comparison_operator attribute identifier identifier identifier identifier if_statement call identifier argument_list call identifier argument_list lambda lambda_parameters identifier comparison_operator attribute identifier identifier identifier identifier block continue_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator identifier block continue_statement if_statement comparison_operator string string_start string_content string_end identifier block continue_statement if_statement comparison_operator subscript identifier string string_start string_content string_end attribute identifier identifier block continue_statement expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end attribute identifier identifier for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier else_clause block 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 keyword_argument identifier call identifier argument_list string string_start string_content string_end
|
Stop children that are working on overdue jobs.
|
def vdp_vlan_change_cb(self, port_uuid, lvid, vdp_vlan, fail_reason):
LOG.info("Vlan change CB lvid %(lvid)s VDP %(vdp)s",
{'lvid': lvid, 'vdp': vdp_vlan})
self.update_vm_result(port_uuid, constants.RESULT_SUCCESS,
lvid=lvid, vdp_vlan=vdp_vlan,
fail_reason=fail_reason)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Callback function for updating the VDP VLAN in DB.
|
def write_batch_json(self, content):
timestamp = str(time.time()).replace('.', '')
batch_json_file = os.path.join(
self.tcex.args.tc_temp_path, 'batch-{}.json'.format(timestamp)
)
with open(batch_json_file, 'w') as fh:
json.dump(content, fh, indent=2)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute attribute identifier identifier identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier integer
|
Write batch json data to a file.
|
def rd_files(self, study_fn, pop_fn):
study, pop = self._read_geneset(study_fn, pop_fn)
print("Study: {0} vs. Population {1}\n".format(len(study), len(pop)))
return study, pop
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list call identifier argument_list identifier call identifier argument_list identifier return_statement expression_list identifier identifier
|
Read files and return study and population.
|
def journals(self):
try:
target = self._item_path
json_data = self._redmine.get(target % str(self.id),
parms={'include': 'journals'})
data = self._redmine.unwrap_json(None, json_data)
journals = [Journal(redmine=self._redmine,
data=journal,
type='issue_journal')
for journal in data['issue']['journals']]
return journals
except Exception:
return []
|
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list binary_operator identifier call identifier argument_list attribute identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list none identifier expression_statement assignment identifier list_comprehension call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end for_in_clause identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end return_statement identifier except_clause identifier block return_statement list
|
Retrieve journals attribute for this very Issue
|
def _split_tidy(self, string, maxsplit=None):
if maxsplit is None:
return string.rstrip("\n").split("\t")
else:
return string.rstrip("\n").split("\t", maxsplit)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block return_statement call attribute call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end identifier argument_list string string_start string_content escape_sequence string_end else_clause block return_statement call attribute call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end identifier argument_list string string_start string_content escape_sequence string_end identifier
|
Rstrips string for \n and splits string for \t
|
def allReadGroups(self):
for dataset in self.getDatasets():
for readGroupSet in dataset.getReadGroupSets():
for readGroup in readGroupSet.getReadGroups():
yield readGroup
|
module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list block for_statement identifier call attribute identifier identifier argument_list block for_statement identifier call attribute identifier identifier argument_list block expression_statement yield identifier
|
Return an iterator over all read groups in the data repo
|
def load(self, value):
if self.property_type is None:
return value
elif not isinstance(self.property_type, BaseType):
raise TypeError('property_type must be schematics BaseType')
else:
native_value = self.property_type.to_native(value)
self.property_type.validate(native_value)
return native_value
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block return_statement identifier elif_clause not_operator call identifier argument_list attribute identifier identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
|
Load a value, converting it to the proper type if validation_type exists.
|
def current_index(self):
i = self._parent.proxy_model.mapToSource(self._parent.currentIndex())
return i
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list return_statement identifier
|
Get the currently selected index in the parent table view.
|
def console(cls, id):
oper = cls.call('paas.update', cls.usable_id(id), {'console': 1})
cls.echo('Activation of the console on your PaaS instance')
cls.display_progress(oper)
console_url = Paas.info(cls.usable_id(id))['console']
access = 'ssh %s' % console_url
cls.execute(access)
|
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 attribute identifier identifier argument_list identifier dictionary pair string string_start string_content string_end integer 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 subscript call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier
|
Open a console to a PaaS instance.
|
def union(*args):
if not args:
return []
base = args[0]
for other in args[1:]:
base.extend(other)
return list(OrderedDict.fromkeys(base))
|
module function_definition identifier parameters list_splat_pattern identifier block if_statement not_operator identifier block return_statement list expression_statement assignment identifier subscript identifier integer for_statement identifier subscript identifier slice integer block expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list call attribute identifier identifier argument_list identifier
|
Return the union of lists, ordering by first seen in any list
|
def main(host, port, timeout, itimeout, qsize, backlog, maxtry, bsize, verbose, logfile=None, logcfgfile=None, cfgfile=None):
dict_cfg = {}
if cfgfile:
dict_cfg = app_config.get_config_by_file(cfgfile)
def get_param(key, param, default):
return param or dict_cfg.get(key, None) or default
cfg = app_config.Config(
address=(get_param("host", host, "localhost"), get_param("port", port, 3333)),
timeout=get_param("timeout", timeout, 10),
msg_size=get_param("bsize", bsize, 4096),
max_try_turn=get_param("maxtry", maxtry, 3),
backlog=get_param("backlog", backlog, 1024),
max_queue_size=get_param("qsize", qsize, 100),
endpoint_timeout=get_param("itimeout", itimeout, 60),
verbose=get_param("verbose", verbose, 0),
logfile=get_param("logfile", logfile, None),
logcfgfile=get_param("logcfgfile", logcfgfile, None)
)
click.echo("Starting sockspy...")
sockspy_main.run(cfg)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier dictionary if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier identifier identifier block return_statement boolean_operator boolean_operator identifier call attribute identifier identifier argument_list identifier none identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier tuple call identifier argument_list string string_start string_content string_end identifier string string_start string_content string_end call identifier argument_list string string_start string_content string_end identifier integer keyword_argument identifier call identifier argument_list string string_start string_content string_end identifier integer keyword_argument identifier call identifier argument_list string string_start string_content string_end identifier integer keyword_argument identifier call identifier argument_list string string_start string_content string_end identifier integer keyword_argument identifier call identifier argument_list string string_start string_content string_end identifier integer keyword_argument identifier call identifier argument_list string string_start string_content string_end identifier integer keyword_argument identifier call identifier argument_list string string_start string_content string_end identifier integer keyword_argument identifier call identifier argument_list string string_start string_content string_end identifier integer keyword_argument identifier call identifier argument_list string string_start string_content string_end identifier none keyword_argument identifier call identifier argument_list string string_start string_content string_end identifier none expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
|
Simple python implementation of a socks5 proxy server.
|
def _get_magnitude_term(self, C, mag):
if mag >= self.CONSTS["Mh"]:
return C["e1"] + C["b3"] * (mag - self.CONSTS["Mh"])
else:
return C["e1"] + (C["b1"] * (mag - self.CONSTS["Mh"])) +\
(C["b2"] * (mag - self.CONSTS["Mh"]) ** 2.)
|
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier subscript attribute identifier identifier string string_start string_content string_end block return_statement binary_operator subscript identifier string string_start string_content string_end binary_operator subscript identifier string string_start string_content string_end parenthesized_expression binary_operator identifier subscript attribute identifier identifier string string_start string_content string_end else_clause block return_statement binary_operator binary_operator subscript identifier string string_start string_content string_end parenthesized_expression binary_operator subscript identifier string string_start string_content string_end parenthesized_expression binary_operator identifier subscript attribute identifier identifier string string_start string_content string_end line_continuation parenthesized_expression binary_operator subscript identifier string string_start string_content string_end binary_operator parenthesized_expression binary_operator identifier subscript attribute identifier identifier string string_start string_content string_end float
|
Returns the magnitude scaling term - equation 3
|
def freeze_js(html):
matches = js_src_pattern.finditer(html)
if not matches:
return html
for match in reversed(tuple(matches)):
file_name = match.group(1)
file_path = os.path.join(js_files_path, file_name)
with open(file_path, "r", encoding="utf-8") as f:
file_content = f.read()
fmt = '<script type="text/javascript">{}</script>'
js_content = fmt.format(file_content)
html = html[:match.start()] + js_content + html[match.end():]
return html
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block return_statement identifier for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator subscript identifier slice call attribute identifier identifier argument_list identifier subscript identifier slice call attribute identifier identifier argument_list return_statement identifier
|
Freeze all JS assets to the rendered html itself.
|
def send(term, stream):
payload = erlang.term_to_binary(term)
header = struct.pack('!I', len(payload))
stream.write(header)
stream.write(payload)
stream.flush()
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier 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 identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
Write an Erlang term to an output stream.
|
def extract_full_summary_from_signature(operation):
lines = inspect.getdoc(operation)
regex = r'\s*(:param)\s+(.+?)\s*:(.*)'
summary = ''
if lines:
match = re.search(regex, lines)
summary = lines[:match.regs[0][0]] if match else lines
summary = summary.replace('\n', ' ').replace('\r', '')
return summary
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_end if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier conditional_expression subscript identifier slice subscript subscript attribute identifier identifier integer integer identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end identifier argument_list string string_start string_content escape_sequence string_end string string_start string_end return_statement identifier
|
Extract the summary from the docstring of the command.
|
def getParameters(self):
parameters = lock_and_call(
lambda: self._impl.getParameters(),
self._lock
)
return EntityMap(parameters, Parameter)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list lambda call attribute attribute identifier identifier identifier argument_list attribute identifier identifier return_statement call identifier argument_list identifier identifier
|
Get all the parameters declared.
|
def _color_attr(self, ground, attr):
attr = colors[ground][attr]
attrs = self.cursor_attributes
if ground == "foreground":
self.cursor_attributes = (attrs[0], attr, attrs[2])
elif ground == "background":
self.cursor_attributes = (attrs[0], attrs[1], attr)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript subscript identifier identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier tuple subscript identifier integer identifier subscript identifier integer elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier tuple subscript identifier integer subscript identifier integer identifier
|
Given a color attribute, set the current cursor appropriately.
|
def window_specialization(typename):
return Extension(
'zipline.lib._{name}window'.format(name=typename),
['zipline/lib/_{name}window.pyx'.format(name=typename)],
depends=['zipline/lib/_windowtemplate.pxi'],
)
|
module function_definition identifier parameters identifier block return_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier list string string_start string_content string_end
|
Make an extension for an AdjustedArrayWindow specialization.
|
def send_mfg_inspector_data(inspector_proto, credentials, destination_url):
envelope = guzzle_pb2.TestRunEnvelope()
envelope.payload = zlib.compress(inspector_proto.SerializeToString())
envelope.payload_type = guzzle_pb2.COMPRESSED_MFG_EVENT
envelope_data = envelope.SerializeToString()
for _ in xrange(5):
try:
result = _send_mfg_inspector_request(
envelope_data, credentials, destination_url)
return result
except UploadFailedError:
time.sleep(1)
logging.critical(
'Could not upload to mfg-inspector after 5 attempts. Giving up.')
return {}
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call identifier argument_list integer block try_statement block expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement dictionary
|
Upload MfgEvent to steam_engine.
|
async def fetch_status(self, request):
response = await self._query_validator(
Message.CLIENT_STATUS_GET_REQUEST,
client_status_pb2.ClientStatusGetResponse,
client_status_pb2.ClientStatusGetRequest())
return self._wrap_response(
request,
data={
'peers': response['peers'],
'endpoint': response['endpoint']
},
metadata=self._get_metadata(request, response))
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier await call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list identifier identifier
|
Fetches information pertaining to the valiator's status.
|
def _build_models_query(self, query):
registered_models_ct = self.build_models_list()
if registered_models_ct:
restrictions = [xapian.Query('%s%s' % (TERM_PREFIXES[DJANGO_CT], model_ct))
for model_ct in registered_models_ct]
limit_query = xapian.Query(xapian.Query.OP_OR, restrictions)
query = xapian.Query(xapian.Query.OP_AND, query, limit_query)
return query
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple subscript identifier identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier identifier return_statement identifier
|
Builds a query from `query` that filters to documents only from registered models.
|
def calculate_response(self, challenge, password):
to_hash = (challenge + "-" + password).encode("UTF-16LE")
hashed = hashlib.md5(to_hash).hexdigest()
return "{0}-{1}".format(challenge, hashed)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute parenthesized_expression binary_operator binary_operator identifier string string_start string_content string_end identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list return_statement call attribute string string_start string_content string_end identifier argument_list identifier identifier
|
Calculate response for the challenge-response authentication
|
def offset(self, offset):
clone = self._clone()
if isinstance(offset, int):
clone._offset = offset
return clone
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call identifier argument_list identifier identifier block expression_statement assignment attribute identifier identifier identifier return_statement identifier
|
Fetch results after `offset` value
|
def on_backward_end(self, **kwargs):
"Clip the gradient before the optimizer step."
if self.clip: nn.utils.clip_grad_norm_(self.learn.model.parameters(), self.clip)
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier
|
Clip the gradient before the optimizer step.
|
def evalsha(self, digest, keys=[], args=[]):
return self.execute(b'EVALSHA', digest, len(keys), *(keys + args))
|
module function_definition identifier parameters identifier identifier default_parameter identifier list default_parameter identifier list block return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier call identifier argument_list identifier list_splat parenthesized_expression binary_operator identifier identifier
|
Execute a Lua script server side by its SHA1 digest.
|
def _put_bucket_policy(self):
if self.s3props['bucket_policy']:
policy_str = json.dumps(self.s3props['bucket_policy'])
_response = self.s3client.put_bucket_policy(Bucket=self.bucket, Policy=policy_str)
else:
_response = self.s3client.delete_bucket_policy(Bucket=self.bucket)
LOG.debug('Response adding bucket policy: %s', _response)
LOG.info('S3 Bucket Policy Attached')
|
module function_definition identifier parameters identifier block if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
|
Attach a bucket policy to app bucket.
|
def _raise_error_if_column_exists(dataset, column_name = 'dataset',
dataset_variable_name = 'dataset',
column_name_error_message_name = 'column_name'):
err_msg = 'The SFrame {0} must contain the column {1}.'.format(
dataset_variable_name,
column_name_error_message_name)
if column_name not in dataset.column_names():
raise ToolkitError(str(err_msg))
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter 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 identifier identifier if_statement comparison_operator identifier call attribute identifier identifier argument_list block raise_statement call identifier argument_list call identifier argument_list identifier
|
Check if a column exists in an SFrame with error message.
|
def run(command, **kw):
if sys.platform == 'win32':
_cwd = kw.get('cwd', None)
if _cwd is not None:
kw['cwd'] = _cwd.decode()
try:
return check_output(command, **kw).splitlines()
except CalledProcessError:
return ()
except FileNotFoundError:
print("The {} binary was not found. Skipping directory {}.\n"
.format(command[0], kw['cwd'].decode("UTF-8")))
return ()
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list try_statement block return_statement call attribute call identifier argument_list identifier dictionary_splat identifier identifier argument_list except_clause identifier block return_statement tuple except_clause identifier block expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list subscript identifier integer call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end return_statement tuple
|
Run `command`, catch any exception, and return lines of output.
|
def clear_db():
cursor = '0'
while cursor != 0:
cursor, keys = DB.scan(cursor, match='*', count=5000)
if keys:
DB.delete(*keys)
|
module function_definition identifier parameters block expression_statement assignment identifier string string_start string_content string_end while_statement comparison_operator identifier integer block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer if_statement identifier block expression_statement call attribute identifier identifier argument_list list_splat identifier
|
Clear the entire db.
|
def update(self, device_json=None, info_json=None, settings_json=None,
avatar_json=None):
if device_json:
UTILS.update(self._device_json, device_json)
if avatar_json:
UTILS.update(self._avatar_json, avatar_json)
if info_json:
UTILS.update(self._info_json, info_json)
if settings_json:
UTILS.update(self._settings_json, settings_json)
|
module function_definition identifier parameters identifier 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 attribute identifier identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
|
Update the internal device json data.
|
def add(self, value):
path = value if isinstance(value, Path) else Path(str(value))
if path and path != path.parent:
destination = self
for part in path.parts:
destination = destination.setdefault(part, DirectoryTree())
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier conditional_expression identifier call identifier argument_list identifier identifier call identifier argument_list call identifier argument_list identifier if_statement boolean_operator identifier comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier call identifier argument_list
|
Create a safe directory from a value.
|
def report(self, req_handler):
"Send a response corresponding to this error to the client"
if self.exc:
req_handler.send_exception(self.code, self.exc, self.headers)
return
text = (self.text
or BaseHTTPRequestHandler.responses[self.code][1]
or "Unknown error")
getattr(req_handler, "send_error_%s" % self.ctype, 'send_error_msg')(self.code, text, self.headers)
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement expression_statement assignment identifier parenthesized_expression boolean_operator boolean_operator attribute identifier identifier subscript subscript attribute identifier identifier attribute identifier identifier integer string string_start string_content string_end expression_statement call call identifier argument_list identifier binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end argument_list attribute identifier identifier identifier attribute identifier identifier
|
Send a response corresponding to this error to the client
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.