code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def _write_xml(xmlfile, srcs):
root = ElementTree.Element('source_library')
root.set('title', 'source_library')
for src in srcs:
src.write_xml(root)
output_file = open(xmlfile, 'w')
output_file.write(utils.prettify_xml(root))
|
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 expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
|
Save the ROI model as an XML
|
def viewlog(calc_id, host='localhost', port=8000):
base_url = 'http://%s:%s/v1/calc/' % (host, port)
start = 0
psize = 10
try:
while True:
url = base_url + '%d/log/%d:%d' % (calc_id, start, start + psize)
rows = json.load(urlopen(url))
for row in rows:
print(' '.join(row))
start += len(rows)
time.sleep(1)
except:
pass
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier integer block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier integer expression_statement assignment identifier integer try_statement block while_statement true block expression_statement assignment identifier binary_operator identifier binary_operator string string_start string_content string_end tuple identifier identifier binary_operator identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier for_statement identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement augmented_assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer except_clause block pass_statement
|
Extract the log of the given calculation ID from the WebUI
|
def validate_url(cls, url: str) -> Optional[Match[str]]:
match = re.match(cls._VALID_URL, url)
return match
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier return_statement identifier
|
Check if the Extractor can handle the given url.
|
def filter_batch(self, batch):
for item in batch:
if self.filter(item):
yield item
else:
self.set_metadata('filtered_out',
self.get_metadata('filtered_out') + 1)
self.total += 1
self._log_progress()
|
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement yield identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end binary_operator call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list
|
Receives the batch, filters it, and returns it.
|
def _first_expander(fringe, iteration, viewer):
current = fringe[0]
neighbors = current.expand(local_search=True)
if viewer:
viewer.event('expanded', [current], [neighbors])
fringe.extend(neighbors)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier true if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end list identifier list identifier expression_statement call attribute identifier identifier argument_list identifier
|
Expander that expands only the first node on the fringe.
|
def _handle_units_placement(changeset, units, records):
for service_name, service in sorted(changeset.bundle['services'].items()):
num_units = service.get('num_units')
if num_units is None:
continue
placement_directives = service.get('to', [])
if not isinstance(placement_directives, (list, tuple)):
placement_directives = [placement_directives]
if placement_directives and not changeset.is_legacy_bundle():
placement_directives += (
placement_directives[-1:] *
(num_units - len(placement_directives)))
placed_in_services = {}
for i in range(num_units):
unit = units['{}/{}'.format(service_name, i)]
record = records[unit['record']]
if i < len(placement_directives):
record = _handle_unit_placement(
changeset, units, unit, record, placement_directives[i],
placed_in_services)
changeset.send(record)
|
module function_definition identifier parameters identifier identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list if_statement not_operator call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier list identifier if_statement boolean_operator identifier not_operator call attribute identifier identifier argument_list block expression_statement augmented_assignment identifier parenthesized_expression binary_operator subscript identifier slice unary_operator integer parenthesized_expression binary_operator identifier call identifier argument_list identifier expression_statement assignment identifier dictionary for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier subscript identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier subscript identifier subscript identifier string string_start string_content string_end if_statement comparison_operator identifier call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier subscript identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier
|
Ensure that requires and placement directives are taken into account.
|
def ms_cutall(self, viewer, event, data_x, data_y):
if not self.cancut:
return True
x, y = self.get_win_xy(viewer)
if event.state == 'move':
self._cutboth_xy(viewer, x, y)
elif event.state == 'down':
self._start_x, self._start_y = x, y
image = viewer.get_image()
self._loval, self._hival = viewer.autocuts.calc_cut_levels(image)
else:
viewer.onscreen_message(None)
return True
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block if_statement not_operator attribute identifier identifier block return_statement true expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier expression_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list none return_statement true
|
An interactive way to set the low AND high cut levels.
|
def _new_cls_attr(self, clazz, name, cls=None, mult=MULT_ONE, cont=True,
ref=False, bool_assignment=False, position=0):
attr = MetaAttr(name, cls, mult, cont, ref, bool_assignment,
position)
clazz._tx_attrs[name] = attr
return attr
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier identifier default_parameter identifier true default_parameter identifier false default_parameter identifier false default_parameter identifier integer block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier
|
Creates new meta attribute of this class.
|
def find_deprecated_usages(
schema: GraphQLSchema, ast: DocumentNode
) -> List[GraphQLError]:
type_info = TypeInfo(schema)
visitor = FindDeprecatedUsages(type_info)
visit(ast, TypeInfoVisitor(type_info, visitor))
return visitor.errors
|
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier call identifier argument_list identifier identifier return_statement attribute identifier identifier
|
Get a list of GraphQLError instances describing each deprecated use.
|
def value(self):
from abilian.services.repository import session_repository as repository
repository.delete(self, self.uuid)
|
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier identifier aliased_import dotted_name identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier
|
Remove value from repository.
|
def deserialize(self, value, **kwargs):
kwargs.update({'trusted': kwargs.get('trusted', False)})
if self.deserializer is not None:
return self.deserializer(value, **kwargs)
if value is None:
return None
output_tuples = [
(
self.key_prop.deserialize(key, **kwargs),
self.value_prop.deserialize(val, **kwargs)
)
for key, val in iteritems(value)
]
try:
output_dict = {key: val for key, val in output_tuples}
except TypeError as err:
raise TypeError('Dictionary property {} cannot be deserialized - '
'keys contain {}'.format(self.name, err))
return self._class_container(output_dict)
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end false if_statement comparison_operator attribute identifier identifier none block return_statement call attribute identifier identifier argument_list identifier dictionary_splat identifier if_statement comparison_operator identifier none block return_statement none expression_statement assignment identifier list_comprehension tuple call attribute attribute identifier identifier identifier argument_list identifier dictionary_splat identifier call attribute attribute identifier identifier identifier argument_list identifier dictionary_splat identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier try_statement block expression_statement assignment identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier
|
Return a deserialized copy of the dict
|
def _configure_logging(self):
if not self.LOGGING_CONFIG:
dictConfig(self.DEFAULT_LOGGING)
else:
dictConfig(self.LOGGING_CONFIG)
|
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement call identifier argument_list attribute identifier identifier else_clause block expression_statement call identifier argument_list attribute identifier identifier
|
Setting up logging from logging config in settings
|
def visit_yield(self, node, parent):
newnode = nodes.Yield(node.lineno, node.col_offset, parent)
if node.value is not None:
newnode.postinit(self.visit(node.value, newnode))
return newnode
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier return_statement identifier
|
visit a Yield node by returning a fresh instance of it
|
def parents(self, vertex):
return [self.tail(edge) for edge in self.in_edges(vertex)]
|
module function_definition identifier parameters identifier identifier block return_statement list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list identifier
|
Return the list of immediate parents of this vertex.
|
def channel(self, match):
if len(match) == 9 and match[0] in ('C','G','D'):
return self._lookup(Channel, 'id', match)
return self._lookup(Channel, 'name', match)
|
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator subscript identifier integer tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end identifier
|
Return Channel object for a given Slack ID or name
|
def _initSwapInfo(self):
self._swapList = []
sysinfo = SystemInfo()
for (swap,attrs) in sysinfo.getSwapStats().iteritems():
if attrs['type'] == 'partition':
dev = self._getUniqueDev(swap)
if dev is not None:
self._swapList.append(dev)
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier list expression_statement assignment identifier call identifier argument_list for_statement tuple_pattern identifier identifier call attribute call attribute identifier identifier argument_list identifier argument_list block if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Initialize swap partition to device mappings.
|
def extract_status(self, status_headers):
self['status'] = status_headers.get_statuscode()
if not self['status']:
self['status'] = '-'
elif self['status'] == '204' and 'Error' in status_headers.statusline:
self['status'] = '-'
|
module function_definition identifier parameters identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list if_statement not_operator subscript identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end elif_clause boolean_operator comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end
|
Extract status code only from status line
|
def pub(self, topic, message):
return self.send(' '.join((constants.PUB, topic)), message)
|
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list tuple attribute identifier identifier identifier identifier
|
Publish to a topic
|
def error(self, message, code=1):
sys.stderr.write(message)
sys.exit(code)
|
module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
|
Prints the error, and exits with the given code.
|
def send_sms_message(sms_message, backend=None, fail_silently=False):
with get_sms_connection(backend=backend, fail_silently=fail_silently) as connection:
result = connection.send_messages([sms_message])
return result
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier false block with_statement with_clause with_item as_pattern call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list identifier return_statement identifier
|
Send an SMSMessage instance using a connection given by the specified `backend`.
|
def related_obj_to_dict(obj, **kwargs):
kwargs.pop('formatter', None)
suppress_private_attr = kwargs.get("suppress_private_attr", False)
suppress_empty_values = kwargs.get("suppress_empty_values", False)
attrs = fields(obj.__class__)
return_dict = kwargs.get("dict_factory", OrderedDict)()
for a in attrs:
if suppress_private_attr and a.name.startswith("_"):
continue
metadata = a.metadata or {}
formatter = metadata.get('formatter')
value = getattr(obj, a.name)
value = to_dict(value, formatter=formatter, **kwargs)
if suppress_empty_values and value is None:
continue
key_name = a.metadata.get('key') or a.name
return_dict[key_name] = value
return return_dict
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list for_statement identifier identifier block if_statement boolean_operator identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block continue_statement expression_statement assignment identifier boolean_operator attribute identifier identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier dictionary_splat identifier if_statement boolean_operator identifier comparison_operator identifier none block continue_statement expression_statement assignment identifier boolean_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
|
Covert a known related object to a dictionary.
|
def _netstat_route_netbsd():
ret = []
cmd = 'netstat -f inet -rn | tail -n+5'
out = __salt__['cmd.run'](cmd, python_shell=True)
for line in out.splitlines():
comps = line.split()
ret.append({
'addr_family': 'inet',
'destination': comps[0],
'gateway': comps[1],
'netmask': '',
'flags': comps[3],
'interface': comps[6]})
cmd = 'netstat -f inet6 -rn | tail -n+5'
out = __salt__['cmd.run'](cmd, python_shell=True)
for line in out.splitlines():
comps = line.split()
ret.append({
'addr_family': 'inet6',
'destination': comps[0],
'gateway': comps[1],
'netmask': '',
'flags': comps[3],
'interface': comps[6]})
return ret
|
module function_definition identifier parameters block expression_statement assignment identifier list expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier keyword_argument identifier true for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier keyword_argument identifier true for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer return_statement identifier
|
Return netstat routing information for NetBSD
|
def evaluate(self, x, y, flux, x_0, y_0):
if self.xname is None:
dx = x - x_0
else:
dx = x
setattr(self.psfmodel, self.xname, x_0)
if self.xname is None:
dy = y - y_0
else:
dy = y
setattr(self.psfmodel, self.yname, y_0)
if self.fluxname is None:
return (flux * self._psf_scale_factor *
self._integrated_psfmodel(dx, dy))
else:
setattr(self.psfmodel, self.yname, flux * self._psf_scale_factor)
return self._integrated_psfmodel(dx, dy)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier binary_operator identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier binary_operator identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier none block return_statement parenthesized_expression binary_operator binary_operator identifier attribute identifier identifier call attribute identifier identifier argument_list identifier identifier else_clause block expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier binary_operator identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier
|
The evaluation function for PRFAdapter.
|
def merge_versioned(releases, schema=None, merge_rules=None):
if not merge_rules:
merge_rules = get_merge_rules(schema)
merged = OrderedDict()
for release in sorted(releases, key=lambda release: release['date']):
release = release.copy()
ocid = release.pop('ocid')
merged[('ocid',)] = ocid
releaseID = release['id']
date = release['date']
tag = release.pop('tag', None)
flat = flatten(release, merge_rules)
processed = process_flattened(flat)
for key, value in processed.items():
if key in merged and value == merged[key][-1]['value']:
continue
if key not in merged:
merged[key] = []
merged[key].append(OrderedDict([
('releaseID', releaseID),
('releaseDate', date),
('releaseTag', tag),
('value', value),
]))
return unflatten(merged, merge_rules)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list for_statement identifier call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier subscript identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier tuple string string_start string_content string_end identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript 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 none expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier subscript subscript subscript identifier identifier unary_operator integer string string_start string_content string_end block continue_statement if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier list expression_statement call attribute subscript identifier identifier identifier argument_list call identifier argument_list list tuple string string_start string_content string_end identifier tuple string string_start string_content string_end identifier tuple string string_start string_content string_end identifier tuple string string_start string_content string_end identifier return_statement call identifier argument_list identifier identifier
|
Merges a list of releases into a versionedRelease.
|
def duration(self):
if not self._loaded:
return 0
delta = datetime.datetime.now() - self._start_time
total_secs = (delta.microseconds +
(delta.seconds + delta.days * 24 * 3600) *
10 ** 6) / 10 ** 6
return max(0, int(round(total_secs / 60.0)))
|
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement integer expression_statement assignment identifier binary_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier binary_operator binary_operator attribute identifier identifier integer integer binary_operator integer integer binary_operator integer integer return_statement call identifier argument_list integer call identifier argument_list call identifier argument_list binary_operator identifier float
|
Returns task's current duration in minutes.
|
def only_self(self):
others, self.others = self.others, []
try:
yield
finally:
self.others = others + self.others
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier attribute identifier identifier expression_list attribute identifier identifier list try_statement block expression_statement yield finally_clause block expression_statement assignment attribute identifier identifier binary_operator identifier attribute identifier identifier
|
Only match in self not others.
|
def shutdown(self):
self.__should_stop.set()
if self.__server_thread == threading.current_thread():
self.__is_shutdown.set()
self.__is_running.clear()
else:
if self.__wakeup_fd is not None:
os.write(self.__wakeup_fd.write_fd, b'\x00')
self.__is_shutdown.wait()
if self.__wakeup_fd is not None:
self.__wakeup_fd.close()
self.__wakeup_fd = None
for server in self.sub_servers:
server.shutdown()
|
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list else_clause block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier string string_start string_content escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list
|
Shutdown the server and stop responding to requests.
|
def predict(self, testing_features):
if self.clean:
testing_features = self.impute_data(testing_features)
if self._best_inds:
X_transform = self.transform(testing_features)
try:
return self._best_estimator.predict(self.transform(testing_features))
except ValueError as detail:
print('shape of X:',testing_features.shape)
print('shape of X_transform:',X_transform.transpose().shape)
print('best inds:',self.stacks_2_eqns(self._best_inds))
print('valid locs:',self.valid_loc(self._best_inds))
raise ValueError(detail)
else:
return self._best_estimator.predict(testing_features)
|
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block return_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier raise_statement call identifier argument_list identifier else_clause block return_statement call attribute attribute identifier identifier identifier argument_list identifier
|
predict on a holdout data set.
|
def start(port, root_directory, bucket_depth):
application = S3Application(root_directory, bucket_depth)
http_server = httpserver.HTTPServer(application)
http_server.listen(port)
ioloop.IOLoop.current().start()
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list
|
Starts the mock S3 server on the given port at the given path.
|
def AsyncResponseMiddleware(environ, resp):
future = create_future()
future._loop.call_soon(future.set_result, resp)
return future
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier return_statement identifier
|
This is just for testing the asynchronous response middleware
|
def inspect(item, maxchar=80):
for i in dir(item):
try:
member = str(getattr(item, i))
if maxchar and len(member) > maxchar:
member = member[:maxchar] + "..."
except:
member = "[ERROR]"
print("{}: {}".format(i, member), file=sys.stderr)
|
module function_definition identifier parameters identifier default_parameter identifier integer block for_statement identifier call identifier argument_list identifier block try_statement block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier if_statement boolean_operator identifier comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier binary_operator subscript identifier slice identifier string string_start string_content string_end except_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier keyword_argument identifier attribute identifier identifier
|
Inspect the attributes of an item.
|
def write_ha_config(ip, mac, hass, port, id):
click.echo("Write configuration for Home Assistant to device %s..." % ip)
action = "get://{1}:{2}/api/mystrom?{0}={3}"
data = {
'single': action.format('single', hass, port, id),
'double': action.format('double', hass, port, id),
'long': action.format('long', hass, port, id),
'touch': action.format('touch', hass, port, id),
}
request = requests.post(
'http://{}/{}/{}/'.format(ip, URI, mac), data=data, timeout=TIMEOUT)
if request.status_code == 200:
click.echo("Configuration for %s set" % ip)
click.echo("After using the push pattern the first time then "
"the myStrom WiFi Button will show up as %s" % id)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end identifier
|
Write the configuration for Home Assistant to a myStrom button.
|
def spit_config(self, conf_file, firstwordonly=False):
cfg = ConfigParser.RawConfigParser()
for sec in _CONFIG_SECS:
cfg.add_section(sec)
sec = 'channels'
for i in sorted(self.pack.D):
cfg.set(sec, str(i),
self.pack.name(i, firstwordonly=firstwordonly))
sec = 'conditions'
for k in self.sorted_conkeys():
cfg.set(sec, k, self.conditions[k])
cfg.write(conf_file)
|
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end for_statement identifier call identifier argument_list attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier
|
conf_file a file opened for writing.
|
def dump(self):
data = dict(
sessions_active=self.sess_active,
connections_active=self.conn_active,
connections_ps=self.conn_ps.last_average,
packets_sent_ps=self.pack_sent_ps.last_average,
packets_recv_ps=self.pack_recv_ps.last_average
)
for k, v in self.sess_transports.items():
data['transp_' + k] = v
return data
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier binary_operator string string_start string_content string_end identifier identifier return_statement identifier
|
Return dictionary with current statistical information
|
def configure_swagger(graph):
ns = Namespace(
subject=graph.config.swagger_convention.name,
version=graph.config.swagger_convention.version,
)
convention = SwaggerConvention(graph)
convention.configure(ns, discover=tuple())
return ns.subject
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute attribute attribute identifier identifier identifier identifier keyword_argument identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier call identifier argument_list return_statement attribute identifier identifier
|
Build a singleton endpoint that provides swagger definitions for all operations.
|
def register_combo(self, parent, legs):
parent = self.ibConn.contractString(parent)
legs_dict = {}
for leg in legs:
leg = self.ibConn.contractString(leg)
legs_dict[leg] = self.get_instrument(leg)
self.instrument_combos[parent] = legs_dict
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier identifier identifier
|
add contracts to groups
|
def _is_good_file_for_multiqc(fpath):
(ftype, encoding) = mimetypes.guess_type(fpath)
if encoding is not None:
return False
if ftype is not None and ftype.startswith('image'):
return False
return True
|
module function_definition identifier parameters identifier block expression_statement assignment tuple_pattern identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement false if_statement boolean_operator comparison_operator identifier none call attribute identifier identifier argument_list string string_start string_content string_end block return_statement false return_statement true
|
Returns False if the file is binary or image.
|
def disallow_positional_args(wrapped=None, allowed=None):
if wrapped is None:
return functools.partial(disallow_positional_args, allowed=allowed)
@wrapt.decorator
def disallow_positional_args_dec(fn, instance, args, kwargs):
ismethod = instance is not None
_check_no_positional(fn, args, ismethod, allowed=allowed)
_check_required(fn, kwargs)
return fn(*args, **kwargs)
return disallow_positional_args_dec(wrapped)
|
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier decorated_definition decorator attribute identifier identifier function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier comparison_operator identifier none expression_statement call identifier argument_list identifier identifier identifier keyword_argument identifier identifier expression_statement call identifier argument_list identifier identifier return_statement call identifier argument_list list_splat identifier dictionary_splat identifier return_statement call identifier argument_list identifier
|
Requires function to be called using keyword arguments.
|
def wp_draw_callback(self, points):
if len(points) < 3:
return
from MAVProxy.modules.lib import mp_util
home = self.wploader.wp(0)
self.wploader.clear()
self.wploader.target_system = self.target_system
self.wploader.target_component = self.target_component
self.wploader.add(home)
if self.get_default_frame() == mavutil.mavlink.MAV_FRAME_GLOBAL_TERRAIN_ALT:
use_terrain = True
else:
use_terrain = False
for p in points:
self.wploader.add_latlonalt(p[0], p[1], self.settings.wpalt, terrain_alt=use_terrain)
self.send_all_waypoints()
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block return_statement import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list integer expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator call attribute identifier identifier argument_list attribute attribute identifier identifier identifier block expression_statement assignment identifier true else_clause block expression_statement assignment identifier false for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier integer subscript identifier integer attribute attribute identifier identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list
|
callback from drawing waypoints
|
def connection(self):
if self._connection is None:
self._connection = self.client[self.database_name]
if self.disable_id_injector:
incoming = self._connection._Database__incoming_manipulators
for manipulator in incoming:
if isinstance(manipulator,
pymongo.son_manipulator.ObjectIdInjector):
incoming.remove(manipulator)
LOG.debug("Disabling %s on mongodb connection to "
"'%s'.",
manipulator.__class__.__name__,
self.database_name)
break
for manipulator in self.manipulators:
self._connection.add_son_manipulator(manipulator)
LOG.info("Connected to mongodb on %s (database=%s)",
self.safe_connection_string, self.database_name)
return self._connection
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier for_statement identifier identifier block if_statement call identifier argument_list identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end attribute attribute identifier identifier identifier attribute identifier identifier break_statement for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier return_statement attribute identifier identifier
|
Connect to and return mongodb database object.
|
def CreateHunt(hunt_obj):
data_store.REL_DB.WriteHuntObject(hunt_obj)
if hunt_obj.HasField("output_plugins"):
output_plugins_states = flow.GetOutputPluginStates(
hunt_obj.output_plugins,
source="hunts/%s" % hunt_obj.hunt_id,
token=access_control.ACLToken(username=hunt_obj.creator))
data_store.REL_DB.WriteHuntOutputPluginsStates(hunt_obj.hunt_id,
output_plugins_states)
|
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier binary_operator string string_start string_content string_end attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier
|
Creates a hunt using a given hunt object.
|
def user_exists(self, name):
users = self.data['users']
for user in users:
if user['name'] == name:
return True
return False
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end for_statement identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block return_statement true return_statement false
|
Check if a given user exists.
|
def register(cls, *args, **kwargs):
if cls.app is None:
return register(*args, handler=cls, **kwargs)
return cls.app.register(*args, handler=cls, **kwargs)
|
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement comparison_operator attribute identifier identifier none block return_statement call identifier argument_list list_splat identifier keyword_argument identifier identifier dictionary_splat identifier return_statement call attribute attribute identifier identifier identifier argument_list list_splat identifier keyword_argument identifier identifier dictionary_splat identifier
|
Register view to handler.
|
def _merge_default_values(self):
values = self._get_default_values()
for key, value in values.items():
if not self.data.get(key):
self.data[key] = value
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment subscript attribute identifier identifier identifier identifier
|
Merge default values with resource data.
|
def _mainthread_accept_clients(self):
try:
if self._accept_selector.select(timeout=self.block_time):
client = self._server_socket.accept()
logging.info('Client connected: {}'.format(client[1]))
self._threads_limiter.start_thread(target=self._subthread_handle_accepted,
args=(client,))
except socket.error:
pass
|
module function_definition identifier parameters identifier block try_statement block if_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier tuple identifier except_clause attribute identifier identifier block pass_statement
|
Accepts new clients and sends them to the to _handle_accepted within a subthread
|
def init_exporter(extract_images, execute, **exporter_config):
config = Config(InteractExporter=exporter_config)
preprocessors = []
if extract_images:
preprocessors.append(
'nbconvert.preprocessors.ExtractOutputPreprocessor'
)
if execute:
preprocessors.append('nbinteract.preprocessors.NbiExecutePreprocessor')
config.InteractExporter.preprocessors = preprocessors
exporter = InteractExporter(config=config)
return exporter
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier list if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier return_statement identifier
|
Returns an initialized exporter.
|
def update_security_of_project(self, ID, data):
log.info('Update project %s security %s' % (ID, data))
self.put('projects/%s/security.json' % ID, data)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier identifier
|
Update security of project.
|
def key_add(self):
from .main import add_api_key
add_api_key(self.key_name.get(), self.key_val.get())
self.key_name.set("")
self.key_val.set("")
|
module function_definition identifier parameters identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_end
|
Adds the current API key to the bot's data
|
def draw_rect(self, color, world_rect, thickness=0):
tl = self.world_to_surf.fwd_pt(world_rect.tl).round()
br = self.world_to_surf.fwd_pt(world_rect.br).round()
rect = pygame.Rect(tl, br - tl)
pygame.draw.rect(self.surf, color, rect, thickness)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier binary_operator identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier identifier identifier
|
Draw a rectangle using world coordinates.
|
def update(self, **kwargs):
"Update document not update index."
kw = dict(index=self.name, doc_type=self.doc_type, ignore=[404])
kw.update(**kwargs)
return self._client.update(**kw)
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier list integer expression_statement call attribute identifier identifier argument_list dictionary_splat identifier return_statement call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier
|
Update document not update index.
|
def color_parts(parts):
return parts._replace(
title=Fore.GREEN + parts.title + Style.RESET_ALL,
doi=Fore.CYAN + parts.doi + Style.RESET_ALL
)
|
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier binary_operator binary_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier binary_operator binary_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier
|
Adds colors to each part of the citation
|
def lowpass(var, key, factor):
global lowpass_data
if not key in lowpass_data:
lowpass_data[key] = var
else:
lowpass_data[key] = factor*lowpass_data[key] + (1.0 - factor)*var
return lowpass_data[key]
|
module function_definition identifier parameters identifier identifier identifier block global_statement identifier if_statement not_operator comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement assignment subscript identifier identifier binary_operator binary_operator identifier subscript identifier identifier binary_operator parenthesized_expression binary_operator float identifier identifier return_statement subscript identifier identifier
|
a simple lowpass filter
|
def _hash(self, string, hash_type):
hash_types = {
'TABLE_OFFSET': 0,
'HASH_A': 1,
'HASH_B': 2,
'TABLE': 3
}
seed1 = 0x7FED7FED
seed2 = 0xEEEEEEEE
for ch in string.upper():
if not isinstance(ch, int): ch = ord(ch)
value = self.encryption_table[(hash_types[hash_type] << 8) + ch]
seed1 = (value ^ (seed1 + seed2)) & 0xFFFFFFFF
seed2 = ch + seed1 + seed2 + (seed2 << 5) + 3 & 0xFFFFFFFF
return seed1
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end integer expression_statement assignment identifier integer expression_statement assignment identifier integer for_statement identifier call attribute identifier identifier argument_list block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier subscript attribute identifier identifier binary_operator parenthesized_expression binary_operator subscript identifier identifier integer identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier parenthesized_expression binary_operator identifier identifier integer expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator binary_operator identifier identifier identifier parenthesized_expression binary_operator identifier integer integer integer return_statement identifier
|
Hash a string using MPQ's hash function.
|
def http(container = None):
"wrap a WSGI-style class method to a HTTPRequest event handler"
def decorator(func):
@functools.wraps(func)
def handler(self, event):
return _handler(self if container is None else container, event, lambda env: func(self, env))
return handler
return decorator
|
module function_definition identifier parameters default_parameter identifier none block expression_statement string string_start string_content string_end function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier identifier block return_statement call identifier argument_list conditional_expression identifier comparison_operator identifier none identifier identifier lambda lambda_parameters identifier call identifier argument_list identifier identifier return_statement identifier return_statement identifier
|
wrap a WSGI-style class method to a HTTPRequest event handler
|
def setup(app):
sphinx_compatibility._app = app
app.add_config_value('sphinx_gallery_conf', DEFAULT_GALLERY_CONF, 'html')
for key in ['plot_gallery', 'abort_on_example_error']:
app.add_config_value(key, get_default_config_value(key), 'html')
try:
app.add_css_file('gallery.css')
except AttributeError:
app.add_stylesheet('gallery.css')
extensions_attr = '_extensions' if hasattr(
app, '_extensions') else 'extensions'
if 'sphinx.ext.autodoc' in getattr(app, extensions_attr):
app.connect('autodoc-process-docstring', touch_empty_backreferences)
app.connect('builder-inited', generate_gallery_rst)
app.connect('build-finished', copy_binder_files)
app.connect('build-finished', summarize_failing_examples)
app.connect('build-finished', embed_code_links)
metadata = {'parallel_read_safe': True,
'parallel_write_safe': False,
'version': _sg_version}
return metadata
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier string string_start string_content string_end for_statement identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list identifier string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier conditional_expression string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end call identifier argument_list identifier identifier block 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 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 identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end true pair string string_start string_content string_end false pair string string_start string_content string_end identifier return_statement identifier
|
Setup sphinx-gallery sphinx extension
|
def save_model(self, request, obj, form, change):
super(GenericPositionsAdmin, self).save_model(request, obj, form,
change)
c_type = ContentType.objects.get_for_model(obj)
try:
ObjectPosition.objects.get(content_type__pk=c_type.id,
object_id=obj.id)
except ObjectPosition.DoesNotExist:
position_objects = ObjectPosition.objects.filter(
content_type__pk=c_type.id, position__isnull=False).order_by(
'-position')
try:
position = (position_objects[0].position + 1)
except IndexError:
position = 1
ObjectPosition.objects.create(
content_object=obj, position=position)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier except_clause attribute identifier identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier false identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment identifier parenthesized_expression binary_operator attribute subscript identifier integer identifier integer except_clause identifier block expression_statement assignment identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
|
Add an ObjectPosition to the object.
|
def allow_role(role):
def processor(action, argument):
db.session.add(
ActionRoles.allow(action, argument=argument, role_id=role.id)
)
return processor
|
module function_definition identifier parameters identifier block function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier return_statement identifier
|
Allow a role identified by an email address.
|
def _logger_fh(self):
logfile = os.path.join(self.default_args.tc_log_path, self.default_args.tc_log_file)
fh = logging.FileHandler(logfile)
fh.set_name('fh')
fh.setLevel(logging.DEBUG)
fh.setFormatter(self._logger_formatter)
self.log.addHandler(fh)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Add File logging handler.
|
def unscale_dict_wet(C):
return {k: _scale_dict[k] * v for k, v in C.items()}
|
module function_definition identifier parameters identifier block return_statement dictionary_comprehension pair identifier binary_operator subscript identifier identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list
|
Undo the scaling applied in `scale_dict_wet`.
|
def from_iterable(cls, target_types, address_mapper, adaptor_iter):
inst = cls(target_types, address_mapper)
all_valid_addresses = set()
for target_adaptor in adaptor_iter:
inst._inject_target(target_adaptor)
all_valid_addresses.add(target_adaptor.address)
inst._validate(all_valid_addresses)
return inst
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Create a new DependentGraph from an iterable of TargetAdaptor subclasses.
|
def _finish(self, update_ops, name_scope):
iter_ = self._get_iter_variable()
beta1_power, beta2_power = self._get_beta_accumulators()
with tf.control_dependencies(update_ops):
with tf.colocate_with(iter_):
def update_beta_op():
update_beta1 = beta1_power.assign(
beta1_power * self._beta1_t,
use_locking=self._use_locking)
update_beta2 = beta2_power.assign(
beta2_power * self._beta2_t,
use_locking=self._use_locking)
return tf.group(update_beta1, update_beta2)
maybe_update_beta = tf.cond(
tf.equal(iter_, 0), update_beta_op, tf.no_op)
with tf.control_dependencies([maybe_update_beta]):
update_iter = iter_.assign(tf.mod(iter_ + 1, self._n_t),
use_locking=self._use_locking)
return tf.group(
*update_ops + [update_iter, maybe_update_beta], name=name_scope)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list with_statement with_clause with_item call attribute identifier identifier argument_list identifier block with_statement with_clause with_item call attribute identifier identifier argument_list identifier block function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier integer identifier attribute identifier identifier with_statement with_clause with_item call attribute identifier identifier argument_list list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list binary_operator identifier integer attribute identifier identifier keyword_argument identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list list_splat binary_operator identifier list identifier identifier keyword_argument identifier identifier
|
Updates beta_power variables every n batches and incrs counter.
|
def make_quantile_df(data, draw_quantiles):
dens = data['density'].cumsum() / data['density'].sum()
ecdf = interp1d(dens, data['y'], assume_sorted=True)
ys = ecdf(draw_quantiles)
violin_xminvs = interp1d(data['y'], data['xminv'])(ys)
violin_xmaxvs = interp1d(data['y'], data['xmaxv'])(ys)
data = pd.DataFrame({
'x': interleave(violin_xminvs, violin_xmaxvs),
'y': np.repeat(ys, 2),
'group': np.repeat(np.arange(1, len(ys)+1), 2)})
return data
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator call attribute subscript identifier string string_start string_content string_end identifier argument_list call attribute subscript identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call identifier argument_list identifier subscript identifier string string_start string_content string_end keyword_argument identifier true expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end argument_list identifier expression_statement assignment identifier call call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call identifier argument_list identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier integer pair string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer binary_operator call identifier argument_list identifier integer integer return_statement identifier
|
Return a dataframe with info needed to draw quantile segments
|
def _generator_file(self):
for path in self.paths:
if os.path.isfile(path):
if isvalid(path, self.access, self.extensions,
minsize=self.minsize):
yield os.path.abspath(path)
elif os.path.isdir(path):
for root, _, fnames in self._walker(path):
yield from self._generator_rebase(fnames, root)
|
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block if_statement call identifier argument_list identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier block expression_statement yield call attribute attribute identifier identifier identifier argument_list identifier elif_clause call attribute attribute identifier identifier identifier argument_list identifier block for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier block expression_statement yield call attribute identifier identifier argument_list identifier identifier
|
Generator for `self.filetype` of 'file
|
def instruction(self, val):
self._instruction = val
if isinstance(val, tuple):
if len(val) is 2:
self._action, self.command = val
else:
self._action, self.command, self.extra = val
else:
split = val.split(" ", 1)
if split[0] == "FROM":
split = val.split(" ", 2)
if len(split) == 3:
self._action, self.command, self.extra = split
else:
self._action, self.command = split
|
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier if_statement call identifier argument_list identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier identifier else_clause block expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end integer if_statement comparison_operator subscript identifier integer 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 integer if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier else_clause block expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier identifier
|
Set the action and command from an instruction
|
def pathExists(self, path):
def commandComplete(cmd):
return not cmd.didFail()
return self.runRemoteCommand('stat', {'file': path,
'logEnviron': self.logEnviron, },
abandonOnFailure=False,
evaluateCommand=commandComplete)
|
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block return_statement not_operator call attribute identifier identifier argument_list return_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 attribute identifier identifier keyword_argument identifier false keyword_argument identifier identifier
|
test whether path exists
|
def values(self):
values = []
for __, data in self.items():
values.append(data)
return values
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
return a list of all state values
|
def coth(x, context=None):
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_coth,
(BigFloat._implicit_convert(x),),
context,
)
|
module function_definition identifier parameters identifier default_parameter identifier none block return_statement call identifier argument_list identifier attribute identifier identifier tuple call attribute identifier identifier argument_list identifier identifier
|
Return the hyperbolic cotangent of x.
|
def cli(yamlfile, format, context):
print(JSONLDGenerator(yamlfile, format).serialize(context=context))
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list call attribute call identifier argument_list identifier identifier identifier argument_list keyword_argument identifier identifier
|
Generate JSONLD file from biolink schema
|
def printData(self, output = sys.stdout):
self.printDatum("Name : ", self.fileName, output)
self.printDatum("Author : ", self.author, output)
self.printDatum("Repository : ", self.repository, output)
self.printDatum("Category : ", self.category, output)
self.printDatum("Downloads : ", self.downloads, output)
self.printDatum("Date Uploaded : ", self.fileDate, output)
self.printDatum("File Size : ", self.fileSize, output)
self.printDatum("Documentation : ", self.documentation, output)
self.printDatum("Source Code : ", self.sourceCode, output)
self.printDatum("Description : ", self.description, output)
print >> output, "\n\n"
|
module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier print_statement chevron identifier string string_start string_content escape_sequence escape_sequence string_end
|
Output all the file data to be written to any writable output
|
def register(self, f, *args, **kwargs):
self._functions.append(lambda: f(*args, **kwargs))
|
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute attribute identifier identifier identifier argument_list lambda call identifier argument_list list_splat identifier dictionary_splat identifier
|
Register a function and arguments to be called later.
|
def usernameAvailable(self, username, domain):
if len(username) < 2:
return [False, u"Username too short"]
for char in u"[ ,:;<>@()!\"'%&\\|\t\b":
if char in username:
return [False,
u"Username contains invalid character: '%s'" % char]
try:
parseAddress("<%s@example.com>" % (username,))
except ArgumentError:
return [False, u"Username fails to parse"]
if domain not in self.getAvailableDomains():
return [False, u"Domain not allowed"]
query = self.store.query(userbase.LoginMethod,
AND(userbase.LoginMethod.localpart == username,
userbase.LoginMethod.domain == domain))
return [not bool(query.count()), u"Username already taken"]
|
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block return_statement list false string string_start string_content string_end for_statement identifier string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end block if_statement comparison_operator identifier identifier block return_statement list false binary_operator string string_start string_content string_end identifier try_statement block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier except_clause identifier block return_statement list false string string_start string_content string_end if_statement comparison_operator identifier call attribute identifier identifier argument_list block return_statement list false string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call identifier argument_list comparison_operator attribute attribute identifier identifier identifier identifier comparison_operator attribute attribute identifier identifier identifier identifier return_statement list not_operator call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end
|
Check to see if a username is available for the user to select.
|
def extern_create_exception(self, context_handle, msg_ptr, msg_len):
c = self._ffi.from_handle(context_handle)
msg = self.to_py_str(msg_ptr, msg_len)
return c.to_value(Exception(msg))
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list call identifier argument_list identifier
|
Given a utf8 message string, create an Exception object.
|
def detect_metadata_url_scheme(url):
scheme = None
url_lower = url.lower()
if any(x in url_lower for x in ['wms', 'service=wms']):
scheme = 'OGC:WMS'
if any(x in url_lower for x in ['wmts', 'service=wmts']):
scheme = 'OGC:WMTS'
elif all(x in url for x in ['/MapServer', 'f=json']):
scheme = 'ESRI:ArcGIS:MapServer'
elif all(x in url for x in ['/ImageServer', 'f=json']):
scheme = 'ESRI:ArcGIS:ImageServer'
return scheme
|
module function_definition identifier parameters identifier block expression_statement assignment identifier none expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call identifier generator_expression comparison_operator identifier identifier for_in_clause identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end if_statement call identifier generator_expression comparison_operator identifier identifier for_in_clause identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end elif_clause call identifier generator_expression comparison_operator identifier identifier for_in_clause identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end elif_clause call identifier generator_expression comparison_operator identifier identifier for_in_clause identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end return_statement identifier
|
detect whether a url is a Service type that HHypermap supports
|
def init_fundamental_types(self):
for _id in range(2, 25):
setattr(self, TypeKind.from_id(_id).name,
self._handle_fundamental_types)
|
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list integer integer block expression_statement call identifier argument_list identifier attribute call attribute identifier identifier argument_list identifier identifier attribute identifier identifier
|
Registers all fundamental typekind handlers
|
def fail(self, reason, obj, pointer=None):
pointer = pointer_join(pointer)
err = ValidationError(reason, obj, pointer)
if self.fail_fast:
raise err
else:
self.errors.append(err)
return err
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier if_statement attribute identifier identifier block raise_statement identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
|
Called when validation fails.
|
def map_wrap(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
return f(*args, **kwargs)
return wrapper
|
module function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier return_statement identifier
|
Wrap standard function to easily pass into 'map' processing.
|
def replace_cells(self, key, sorted_row_idxs):
row, col, tab = key
new_keys = {}
del_keys = []
selection = self.grid.actions.get_selection()
for __row, __col, __tab in self.grid.code_array:
if __tab == tab and \
(not selection or (__row, __col) in selection):
new_row = sorted_row_idxs.index(__row)
if __row != new_row:
new_keys[(new_row, __col, __tab)] = \
self.grid.code_array((__row, __col, __tab))
del_keys.append((__row, __col, __tab))
for key in del_keys:
self.grid.code_array.pop(key)
for key in new_keys:
CellActions.set_code(self, key, new_keys[key])
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier expression_statement assignment identifier dictionary expression_statement assignment identifier list expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list for_statement pattern_list identifier identifier identifier attribute attribute identifier identifier identifier block if_statement boolean_operator comparison_operator identifier identifier line_continuation parenthesized_expression boolean_operator not_operator identifier comparison_operator tuple identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier tuple identifier identifier identifier line_continuation call attribute attribute identifier identifier identifier argument_list tuple identifier identifier identifier expression_statement call attribute identifier identifier argument_list tuple identifier identifier identifier for_statement identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier subscript identifier identifier
|
Replaces cells in current selection so that they are sorted
|
def fwd_chunk(self):
raise NotImplementedError("%s not implemented for %s" % (self.fwd_chunk.__func__.__name__,
self.__class__.__name__))
|
module function_definition identifier parameters identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute attribute attribute identifier identifier identifier identifier attribute attribute identifier identifier identifier
|
Returns the chunk following this chunk in the list of free chunks.
|
def on_step_end(self, step, logs={}):
for callback in self.callbacks:
if callable(getattr(callback, 'on_step_end', None)):
callback.on_step_end(step, logs=logs)
else:
callback.on_batch_end(step, logs=logs)
|
module function_definition identifier parameters identifier identifier default_parameter identifier dictionary block for_statement identifier attribute identifier identifier block if_statement call identifier argument_list call identifier argument_list identifier string string_start string_content string_end none block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
|
Called at end of each step for each callback in callbackList
|
def show_image(kwargs, call=None):
if call != 'function':
raise SaltCloudSystemExit(
'The show_images function must be called with '
'-f or --function'
)
if not isinstance(kwargs, dict):
kwargs = {}
location = get_location()
if 'location' in kwargs:
location = kwargs['location']
params = {
'Action': 'DescribeImages',
'RegionId': location,
'ImageId': kwargs['image']
}
ret = {}
items = query(params=params)
if 'Code' in items or not items['Images']['Image']:
raise SaltCloudNotFound('The specified image could not be found.')
log.debug(
'Total %s image found in Region %s',
items['TotalCount'], location
)
for image in items['Images']['Image']:
ret[image['ImageId']] = {}
for item in image:
ret[image['ImageId']][item] = six.text_type(image[item])
return ret
|
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call identifier argument_list if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier pair string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier dictionary expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier if_statement boolean_operator comparison_operator string string_start string_content string_end identifier not_operator subscript subscript identifier string string_start string_content string_end string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end identifier for_statement identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier subscript identifier string string_start string_content string_end dictionary for_statement identifier identifier block expression_statement assignment subscript subscript identifier subscript identifier string string_start string_content string_end identifier call attribute identifier identifier argument_list subscript identifier identifier return_statement identifier
|
Show the details from aliyun image
|
def known(self, object):
try:
md = object.__metadata__
known = md.sxtype
return known
except:
pass
|
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier return_statement identifier except_clause block pass_statement
|
get the type specified in the object's metadata
|
def link_markdown_cells(cells, modules):
"Create documentation links for all cells in markdown with backticks."
for i, cell in enumerate(cells):
if cell['cell_type'] == 'markdown':
cell['source'] = link_docstring(modules, cell['source'])
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier subscript identifier string string_start string_content string_end
|
Create documentation links for all cells in markdown with backticks.
|
def character_span(self):
begin, end = self.token_span
return (self.sentence[begin].character_span[0], self.sentence[end-1].character_span[-1])
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier attribute identifier identifier return_statement tuple subscript attribute subscript attribute identifier identifier identifier identifier integer subscript attribute subscript attribute identifier identifier binary_operator identifier integer identifier unary_operator integer
|
Returns the character span of the token
|
def timeline(self, request, drip_id, into_past, into_future):
from django.shortcuts import render, get_object_or_404
drip = get_object_or_404(Drip, id=drip_id)
shifted_drips = []
seen_users = set()
for shifted_drip in drip.drip.walk(into_past=int(into_past), into_future=int(into_future)+1):
shifted_drip.prune()
shifted_drips.append({
'drip': shifted_drip,
'qs': shifted_drip.get_queryset().exclude(id__in=seen_users)
})
seen_users.update(shifted_drip.get_queryset().values_list('id', flat=True))
return render(request, 'drip/timeline.html', locals())
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block import_from_statement dotted_name identifier identifier dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier binary_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute call attribute identifier identifier argument_list identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end keyword_argument identifier true return_statement call identifier argument_list identifier string string_start string_content string_end call identifier argument_list
|
Return a list of people who should get emails.
|
def __default(self, ast_token):
if self.list_level == 1:
if self.list_entry is None:
self.list_entry = ast_token
elif not isinstance(ast_token, type(self.list_entry)):
self.final_ast_tokens.append(ast_token)
elif self.list_level == 0:
self.final_ast_tokens.append(ast_token)
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier integer block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier identifier elif_clause not_operator call identifier argument_list identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier elif_clause comparison_operator attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Handle tokens inside the list or outside the list.
|
def remove(self, key):
copydict = ImmutableDict()
copydict.tree = self.tree.remove(hash(key))
copydict._length = self._length - 1
return copydict
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier integer return_statement identifier
|
Returns a new ImmutableDict with the given key removed.
|
async def jsk_debug(self, ctx: commands.Context, *, command_string: str):
alt_ctx = await copy_context_with(ctx, content=ctx.prefix + command_string)
if alt_ctx.command is None:
return await ctx.send(f'Command "{alt_ctx.invoked_with}" is not found')
start = time.perf_counter()
async with ReplResponseReactor(ctx.message):
with self.submit(ctx):
await alt_ctx.command.invoke(alt_ctx)
end = time.perf_counter()
return await ctx.send(f"Command `{alt_ctx.command.qualified_name}` finished in {end - start:.3f}s.")
|
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier keyword_separator typed_parameter identifier type identifier block expression_statement assignment identifier await call identifier argument_list identifier keyword_argument identifier binary_operator attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier none block return_statement await call attribute identifier identifier argument_list string string_start string_content interpolation attribute identifier identifier string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list with_statement with_clause with_item call identifier argument_list attribute identifier identifier block with_statement with_clause with_item call attribute identifier identifier argument_list identifier block expression_statement await call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list return_statement await call attribute identifier identifier argument_list string string_start string_content interpolation attribute attribute identifier identifier identifier string_content interpolation binary_operator identifier identifier format_specifier string_content string_end
|
Run a command timing execution and catching exceptions.
|
def checkoutbranch(accountable, options):
issue = accountable.checkout_branch(options)
headers = sorted(['id', 'key', 'self'])
rows = [headers, [itemgetter(header)(issue) for header in headers]]
print_table(SingleTable(rows))
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier list identifier list_comprehension call call identifier argument_list identifier argument_list identifier for_in_clause identifier identifier expression_statement call identifier argument_list call identifier argument_list identifier
|
Create a new issue and checkout a branch named after it.
|
def delete_intf_router(self, tenant_id, tenant_name, router_id):
in_sub = self.get_in_subnet_id(tenant_id)
out_sub = self.get_out_subnet_id(tenant_id)
subnet_lst = set()
subnet_lst.add(in_sub)
subnet_lst.add(out_sub)
router_id = self.get_router_id(tenant_id, tenant_name)
if router_id:
ret = self.os_helper.delete_intf_router(tenant_name, tenant_id,
router_id, subnet_lst)
if not ret:
LOG.error("Failed to delete router intf id %(rtr)s, "
"tenant %(tenant)s",
{'rtr': router_id, 'tenant': tenant_id})
return ret
LOG.error("Invalid router ID, can't delete interface from "
"router")
|
module function_definition identifier parameters identifier identifier 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 identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier if_statement not_operator identifier 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 dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement identifier expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end
|
Routine to delete the router.
|
def add_cancel_button(self):
button_box = QDialogButtonBox(QDialogButtonBox.Cancel, self)
button_box.rejected.connect(self.reject)
self.layout.addWidget(button_box)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Add a cancel button at the bottom of the dialog window.
|
def reset(self):
paths = []
for filename in os.listdir(self.cached_repo):
if filename.startswith(".git"):
continue
path = os.path.join(self.cached_repo, filename)
if os.path.isfile(path):
paths.append(path)
elif os.path.isdir(path):
for model in os.listdir(path):
paths.append(os.path.join(path, model))
git.remove(self.cached_repo, paths)
self.contents = {"models": {}, "meta": {}}
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block continue_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause call attribute attribute identifier identifier identifier argument_list identifier block for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment attribute identifier identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary
|
Initialize the remote Git repository.
|
def load_config(config_file='~/.stancache.ini'):
if not os.path.exists(config_file):
logging.warning('Config file does not exist: {}. Using default settings.'.format(config_file))
return
config = configparser.ConfigParser()
config.read(config_file)
if not config.has_section('main'):
raise ValueError('Config file {} has no section "main"'.format(config_file))
for (key, val) in config.items('main'):
_set_value(key.upper(), val)
return
|
module function_definition identifier parameters default_parameter identifier string string_start string_content string_end block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier for_statement tuple_pattern identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier return_statement
|
Load config file into default settings
|
def syntax_check():
with fab_settings(warn_only=True):
for file_type in settings.SYNTAX_CHECK:
needs_to_abort = False
if 1 not in env.ok_ret_codes:
env.ok_ret_codes.append(1)
output = local(
'find -name "{}" -print'.format(file_type),
capture=True,
)
files = output.split()
for file in files:
if any(s in file for s in settings.SYNTAX_CHECK_EXCLUDES):
continue
result = local('egrep -i -n "{0}" {1}'.format(
settings.SYNTAX_CHECK[file_type], file), capture=True)
if result:
warn(red("Syntax check found in '{0}': {1}".format(
file, result)))
needs_to_abort = True
if needs_to_abort:
abort(red('There have been errors. Please fix them and run'
' the check again.'))
else:
puts(green('Syntax check found no errors. Very good!'))
|
module function_definition identifier parameters block with_statement with_clause with_item call identifier argument_list keyword_argument identifier true block for_statement identifier attribute identifier identifier block expression_statement assignment identifier false if_statement comparison_operator integer attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block if_statement call identifier generator_expression comparison_operator identifier identifier for_in_clause identifier attribute identifier identifier block continue_statement expression_statement assignment identifier call identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript attribute identifier identifier identifier identifier keyword_argument identifier true if_statement identifier block expression_statement call identifier argument_list call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier true if_statement identifier block expression_statement call identifier argument_list call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement call identifier argument_list call identifier argument_list string string_start string_content string_end
|
Runs flake8 against the codebase.
|
def server(self):
try:
tar = urllib2.urlopen(self.registry)
meta = tar.info()
return int(meta.getheaders("Content-Length")[0])
except (urllib2.URLError, IndexError):
return " "
|
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call identifier argument_list subscript call attribute identifier identifier argument_list string string_start string_content string_end integer except_clause tuple attribute identifier identifier identifier block return_statement string string_start string_content string_end
|
Returns the size of remote files
|
def view(self, cls=None):
result = self.copy()
result._id = self._id
return result
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement identifier
|
this is defined as a copy with the same identity
|
def timed(function):
@wraps(function)
def function_wrapper(obj, *args, **kwargs):
name = obj.__class__.__name__ + '.' + function.__name__
start = time.clock()
result = function(obj, *args, **kwargs)
print('{}: {:.4f} seconds'.format(name, time.clock() - start))
return result
return function_wrapper
|
module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier binary_operator binary_operator attribute attribute identifier identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier list_splat identifier dictionary_splat identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier binary_operator call attribute identifier identifier argument_list identifier return_statement identifier return_statement identifier
|
Decorator timing the method call and printing the result to `stdout`
|
def load_config_file(self, path, profile=None):
config_cls = self.get_config_reader()
return config_cls.load_config(self, path, profile=profile)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier
|
Load the standard config file.
|
def use_any_status_sequence_rule_enabler_view(self):
self._operable_views['sequence_rule_enabler'] = ANY_STATUS
for session in self._get_provider_sessions():
try:
session.use_any_status_sequence_rule_enabler_view()
except AttributeError:
pass
|
module function_definition identifier parameters identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement
|
Pass through to provider SequenceRuleEnablerLookupSession.use_any_status_sequence_rule_enabler_view
|
def _start_console(self):
class InputStream:
def __init__(self):
self._data = b""
def write(self, data):
self._data += data
@asyncio.coroutine
def drain(self):
if not self.ws.closed:
self.ws.send_bytes(self._data)
self._data = b""
output_stream = asyncio.StreamReader()
input_stream = InputStream()
telnet = AsyncioTelnetServer(reader=output_stream, writer=input_stream, echo=True)
self._telnet_servers.append((yield from asyncio.start_server(telnet.run, self._manager.port_manager.console_host, self.console)))
self._console_websocket = yield from self.manager.websocket_query("containers/{}/attach/ws?stream=1&stdin=1&stdout=1&stderr=1".format(self._cid))
input_stream.ws = self._console_websocket
output_stream.feed_data(self.name.encode() + b" console is now available... Press RETURN to get started.\r\n")
asyncio.async(self._read_console_output(self._console_websocket, output_stream))
|
module function_definition identifier parameters identifier block class_definition identifier block function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier string string_start string_end function_definition identifier parameters identifier identifier block expression_statement augmented_assignment attribute identifier identifier identifier decorated_definition decorator attribute identifier identifier function_definition identifier parameters identifier block if_statement not_operator attribute attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier true expression_statement call attribute attribute identifier identifier identifier argument_list parenthesized_expression yield call attribute identifier identifier argument_list attribute identifier identifier attribute attribute attribute identifier identifier identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier yield call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier
|
Start streaming the console via telnet
|
def _sincedb_init(self):
if not self._sincedb_path:
return
if not os.path.exists(self._sincedb_path):
self._log_debug('initializing sincedb sqlite schema')
conn = sqlite3.connect(self._sincedb_path, isolation_level=None)
conn.execute(
)
conn.close()
|
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier none expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
|
Initializes the sincedb schema in an sqlite db
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.