code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def _message(self):
filepath = self._record.file_path
try:
return load_message(filepath)
except FileNotFoundError:
expire_file(filepath)
empty = email.message.Message()
empty.set_payload('')
return empty
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier try_statement block return_statement call identifier argument_list identifier except_clause identifier block expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_end return_statement identifier
|
get the message payload
|
def _Register(self, conditions, callback):
for condition in conditions:
registered = self._registry.setdefault(condition, [])
if callback and callback not in registered:
registered.append(callback)
|
module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier list if_statement boolean_operator identifier comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Map functions that should be called if the condition applies.
|
def _random(cls):
pid = os.getpid()
if pid != cls._pid:
cls._pid = pid
cls.__random = _random_bytes()
return cls.__random
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list return_statement attribute identifier identifier
|
Generate a 5-byte random number once per process.
|
def demographics(self):
body = {
"audience_definition": self.audience_definition,
"targeting_inputs": self.targeting_inputs
}
resource = self.RESOURCE_DEMOGRAPHICS.format(account_id=self.account.id)
response = Request(
self.account.client, self.METHOD,
resource, headers=self.HEADERS, body=json.dumps(body)).perform()
return response.body['data']
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute call identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list identifier identifier argument_list return_statement subscript attribute identifier identifier string string_start string_content string_end
|
Get the demographic breakdown for an input targeting criteria
|
def augment_cells_no_span(self, rows, source):
return [
[(0, 0, 0, StringList(str(cell).splitlines(), source=source)) for cell in row]
for row in rows
]
|
module function_definition identifier parameters identifier identifier identifier block return_statement list_comprehension list_comprehension tuple integer integer integer call identifier argument_list call attribute call identifier argument_list identifier identifier argument_list keyword_argument identifier identifier for_in_clause identifier identifier for_in_clause identifier identifier
|
Convert each cell into a tuple suitable for consumption by build_table.
|
def reset(self):
self.current_table = None
self.tables = []
self.data = [{}]
self.additional_data = {}
self.lines = []
self.set_state('document')
self.current_file = None
self.set_of_energies = set()
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier list dictionary expression_statement assignment attribute identifier identifier dictionary expression_statement assignment attribute identifier identifier list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier call identifier argument_list
|
Clean any processing data, and prepare object for reuse
|
def _scale_cores_to_memory(cores, mem_per_core, sysinfo, system_memory):
total_mem = "%.2f" % (cores * mem_per_core + system_memory)
if "cores" not in sysinfo:
return cores, total_mem, 1.0
total_mem = min(float(total_mem), float(sysinfo["memory"]) - system_memory)
cores = min(cores, int(sysinfo["cores"]))
mem_cores = int(math.floor(float(total_mem) / mem_per_core))
if mem_cores < 1:
out_cores = 1
elif mem_cores < cores:
out_cores = mem_cores
else:
out_cores = cores
mem_pct = float(out_cores) / float(cores)
return out_cores, total_mem, mem_pct
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end parenthesized_expression binary_operator binary_operator identifier identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block return_statement expression_list identifier identifier float expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier binary_operator call identifier argument_list subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list binary_operator call identifier argument_list identifier identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier integer elif_clause comparison_operator identifier identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier binary_operator call identifier argument_list identifier call identifier argument_list identifier return_statement expression_list identifier identifier identifier
|
Scale multicore usage to avoid excessive memory usage based on system information.
|
def do_read(self, args):
if not self.current:
print('There are no resources in use. Use the command "open".')
return
try:
print(self.current.read())
except Exception as e:
print(e)
|
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end return_statement try_statement block expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier
|
Receive from the resource in use.
|
def sync_entities_watching(instance):
for entity_model, entity_model_getter in entity_registry.entity_watching[instance.__class__]:
model_objs = list(entity_model_getter(instance))
if model_objs:
sync_entities(*model_objs)
|
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier subscript attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier if_statement identifier block expression_statement call identifier argument_list list_splat identifier
|
Syncs entities watching changes of a model instance.
|
def _do_report(self, report, in_port, msg):
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
if ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
size = 65535
else:
size = ofproto.OFPCML_MAX
update = False
self._mcast.setdefault(report.address, {})
if in_port not in self._mcast[report.address]:
update = True
self._mcast[report.address][in_port] = True
if update:
actions = []
for port in self._mcast[report.address]:
actions.append(parser.OFPActionOutput(port))
self._set_flow_entry(
datapath, actions, self.server_port, report.address)
self._set_flow_entry(
datapath,
[parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, size)],
in_port, report.address)
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier integer else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier false expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier dictionary if_statement comparison_operator identifier subscript attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier true expression_statement assignment subscript subscript attribute identifier identifier attribute identifier identifier identifier true if_statement identifier block expression_statement assignment identifier list for_statement identifier subscript attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier list call attribute identifier identifier argument_list attribute identifier identifier identifier identifier attribute identifier identifier
|
the process when the querier received a REPORT message.
|
def execute_ls(host_list, remote_user, remote_pass):
runner = spam.ansirunner.AnsibleRunner()
result, failed_hosts = runner.ansible_perform_operation(
host_list=host_list,
remote_user=remote_user,
remote_pass=remote_pass,
module="command",
module_args="ls -1")
print "Result: ", result
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end print_statement string string_start string_content string_end identifier
|
Execute any adhoc command on the hosts.
|
def transform(self, X):
if not self.is_fit:
raise ValueError("The scaler has not been fit yet.")
return (X-self.mean) / (self.std + 10e-7)
|
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement binary_operator parenthesized_expression binary_operator identifier attribute identifier identifier parenthesized_expression binary_operator attribute identifier identifier float
|
Transform your data to zero mean unit variance.
|
def apply_substitutions(monomial, monomial_substitutions, pure=False):
if is_number_type(monomial):
return monomial
original_monomial = monomial
changed = True
if not pure:
substitutions = monomial_substitutions
else:
substitutions = {}
for lhs, rhs in monomial_substitutions.items():
irrelevant = False
for atom in lhs.atoms():
if atom.is_Number:
continue
if not monomial.has(atom):
irrelevant = True
break
if not irrelevant:
substitutions[lhs] = rhs
while changed:
for lhs, rhs in substitutions.items():
monomial = fast_substitute(monomial, lhs, rhs)
if original_monomial == monomial:
changed = False
original_monomial = monomial
return monomial
|
module function_definition identifier parameters identifier identifier default_parameter identifier false block if_statement call identifier argument_list identifier block return_statement identifier expression_statement assignment identifier identifier expression_statement assignment identifier true if_statement not_operator identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier false for_statement identifier call attribute identifier identifier argument_list block if_statement attribute identifier identifier block continue_statement if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment identifier true break_statement if_statement not_operator identifier block expression_statement assignment subscript identifier identifier identifier while_statement identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier false expression_statement assignment identifier identifier return_statement identifier
|
Helper function to remove monomials from the basis.
|
def put_value(self, value, timeout=None):
self._context.put(self._data.path + ["value"], value, timeout=timeout)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator attribute attribute identifier identifier identifier list string string_start string_content string_end identifier keyword_argument identifier identifier
|
Put a value to the Attribute and wait for completion
|
def ast_from_module(self, module, modname=None):
modname = modname or module.__name__
if modname in self.astroid_cache:
return self.astroid_cache[modname]
try:
filepath = module.__file__
if modutils.is_python_source(filepath):
return self.ast_from_file(filepath, modname)
except AttributeError:
pass
from astroid.builder import AstroidBuilder
return AstroidBuilder(self).module_build(module, modname)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block return_statement subscript attribute identifier identifier identifier try_statement block expression_statement assignment identifier attribute identifier identifier if_statement call attribute identifier identifier argument_list identifier block return_statement call attribute identifier identifier argument_list identifier identifier except_clause identifier block pass_statement import_from_statement dotted_name identifier identifier dotted_name identifier return_statement call attribute call identifier argument_list identifier identifier argument_list identifier identifier
|
given an imported module, return the astroid object
|
def update(self):
vehicle = self.api.vehicles(vid=self.vid)['vehicle']
newbus = self.fromapi(self.api, vehicle)
self.__dict__ = newbus.__dict__
del newbus
|
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier delete_statement identifier
|
Update this bus by creating a new one and transplanting dictionaries.
|
def parse_value(self, sn: "DataNode") -> ScalarValue:
res = sn.type.parse_value(self.value)
if res is None:
raise InvalidKeyValue(self.value)
return res
|
module function_definition identifier parameters identifier typed_parameter identifier type string string_start string_content string_end type identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list attribute identifier identifier return_statement identifier
|
Let schema node's type parse the receiver's value.
|
def Preprocess(self, data):
data = data.replace(":\\", ": \\")
data = SudoersFieldParser.COMMENTS_RE.sub("", data)
return data
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_end identifier return_statement identifier
|
Preprocess the given data, ready for parsing.
|
def post(self, url, body=None):
response = self.http.post(url,
headers=self.headers,
data=body,
**self.requests_params)
return self.process(response)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier dictionary_splat attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier
|
Executes an HTTP POST request for the given URL.
|
def show_network(self, network, **_params):
return self.get(self.network_path % (network), params=_params)
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier parenthesized_expression identifier keyword_argument identifier identifier
|
Fetches information of a certain network.
|
def _read_interleaved_numpy(self, f, data_objects):
log.debug("Reading interleaved data all at once")
all_channel_bytes = data_objects[0].raw_data_width
if all_channel_bytes == 0:
all_channel_bytes = sum((o.data_type.size for o in data_objects))
log.debug("all_channel_bytes: %d", all_channel_bytes)
number_bytes = int(all_channel_bytes * data_objects[0].number_values)
combined_data = fromfile(f, dtype=np.uint8, count=number_bytes)
combined_data = combined_data.reshape(-1, all_channel_bytes)
data_pos = 0
for (i, obj) in enumerate(data_objects):
byte_columns = tuple(
range(data_pos, obj.data_type.size + data_pos))
log.debug("Byte columns for channel %d: %s", i, byte_columns)
object_data = combined_data[:, byte_columns].ravel()
object_data.dtype = (
np.dtype(obj.data_type.nptype).newbyteorder(self.endianness))
obj.tdms_object._update_data(object_data)
data_pos += obj.data_type.size
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier attribute subscript identifier integer identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list generator_expression attribute attribute identifier identifier identifier for_in_clause identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier attribute subscript identifier integer identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list unary_operator integer identifier expression_statement assignment identifier integer for_statement tuple_pattern identifier identifier call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier binary_operator attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier call attribute subscript identifier slice identifier identifier argument_list expression_statement assignment attribute identifier identifier parenthesized_expression call attribute call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement augmented_assignment identifier attribute attribute identifier identifier identifier
|
Read interleaved data where all channels have a numpy type
|
def exvp(pos_x, pos_y):
pos_x = numpy.asarray(pos_x)
pos_y = numpy.asarray(pos_y)
center = [1024.5, 1024.5]
cf = EMIR_PLATESCALE_RADS
pos_base_x = pos_x - center[0]
pos_base_y = pos_y - center[1]
ra = numpy.hypot(pos_base_x, pos_base_y)
thet = numpy.arctan2(pos_base_y, pos_base_x)
r = cf * ra
rr1 = 1 + 14606.7 * r**2 + 1739716115.1 * r**4
nx1 = rr1 * ra * numpy.cos(thet) + center[0]
ny1 = rr1 * ra * numpy.sin(thet) + center[1]
return nx1, ny1
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list float float expression_statement assignment identifier identifier expression_statement assignment identifier binary_operator identifier subscript identifier integer expression_statement assignment identifier binary_operator identifier subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator binary_operator integer binary_operator float binary_operator identifier integer binary_operator float binary_operator identifier integer expression_statement assignment identifier binary_operator binary_operator binary_operator identifier identifier call attribute identifier identifier argument_list identifier subscript identifier integer expression_statement assignment identifier binary_operator binary_operator binary_operator identifier identifier call attribute identifier identifier argument_list identifier subscript identifier integer return_statement expression_list identifier identifier
|
Convert virtual pixel to real pixel
|
def parse(self, filename: str, language: str = None, contents: str = None,
timeout: float = None) -> CompatParseResponse:
return self._parse(filename, language, contents, timeout,
Mode.Value('ANNOTATED'))
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier none typed_default_parameter identifier type identifier none typed_default_parameter identifier type identifier none type identifier block return_statement call attribute identifier identifier argument_list identifier identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end
|
Parse the specified filename or contents and return a CompatParseResponse.
|
def do_OPTIONS(self):
thread_local.clock_start = get_time()
thread_local.status_code = 200
thread_local.message = None
thread_local.headers = []
thread_local.end_headers = []
thread_local.size = -1
thread_local.method = 'OPTIONS'
self.send_response(200)
if self.is_cross_origin():
no_caching = self.cross_origin_headers()
self.send_header("Access-Control-Max-Age",
0 if no_caching else 10*60)
self.send_header("Content-Length", 0)
self.end_headers()
thread_local.size = 0
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier unary_operator integer expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer if_statement 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 string string_start string_content string_end conditional_expression integer identifier binary_operator integer integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier integer
|
Handles an OPTIONS request.
|
def startElement(self, node):
if node is None:
return
if self.__filter_location is not None:
if node.location.file is None:
return
elif node.location.file.name not in self.__filter_location:
return
log.debug(
'%s:%d: Found a %s|%s|%s',
node.location.file,
node.location.line,
node.kind.name,
node.displayname,
node.spelling)
try:
stop_recurse = self.parse_cursor(node)
if stop_recurse is not False:
return
for child in node.get_children():
self.startElement(child)
except InvalidDefinitionError:
pass
return None
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block return_statement if_statement comparison_operator attribute identifier identifier none block if_statement comparison_operator attribute attribute identifier identifier identifier none block return_statement elif_clause comparison_operator attribute attribute attribute identifier identifier identifier identifier attribute identifier identifier block return_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier false block return_statement for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement return_statement none
|
Recurses in children of this node
|
def atlasdb_load_peer_table( con=None, path=None ):
peer_table = {}
with AtlasDBOpen(con=con, path=path) as dbcon:
sql = "SELECT * FROM peers;"
args = ()
cur = dbcon.cursor()
res = atlasdb_query_execute( cur, sql, args )
count = 0
for row in res:
if count > 0 and count % 100 == 0:
log.debug("Loaded %s peers..." % count)
atlas_init_peer_info( peer_table, row['peer_hostport'] )
count += 1
return peer_table
|
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier dictionary 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 string string_start string_content string_end expression_statement assignment identifier tuple expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier integer for_statement identifier identifier block if_statement boolean_operator comparison_operator identifier integer comparison_operator binary_operator identifier integer integer block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call identifier argument_list identifier subscript identifier string string_start string_content string_end expression_statement augmented_assignment identifier integer return_statement identifier
|
Create a peer table from the peer DB
|
def channels(self):
if self.mf.mode() == mad.MODE_SINGLE_CHANNEL:
return 1
elif self.mf.mode() in (mad.MODE_DUAL_CHANNEL,
mad.MODE_JOINT_STEREO,
mad.MODE_STEREO):
return 2
else:
return 2
|
module function_definition identifier parameters identifier block if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block return_statement integer elif_clause comparison_operator call attribute attribute identifier identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier block return_statement integer else_clause block return_statement integer
|
The number of channels.
|
def display_paths(instances, type_str):
print('%ss: count=%s' % (type_str, len(instances),))
for path in [instance.path for instance in instances]:
print('%s: %s' % (type_str, path))
if len(instances):
print('')
|
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier call identifier argument_list identifier for_statement identifier list_comprehension attribute identifier identifier for_in_clause identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier if_statement call identifier argument_list identifier block expression_statement call identifier argument_list string string_start string_end
|
Display the count and paths for the list of instances in instances.
|
def full_installation(self, location=None):
url = ("https://tccna.honeywell.com/WebAPI/emea/api/v1/location"
"/%s/installationInfo?includeTemperatureControlSystems=True"
% self._get_location(location))
response = requests.get(url, headers=self._headers())
response.raise_for_status()
return response.json()
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier parenthesized_expression binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list
|
Return the full details of the installation.
|
def remove_external_references_from_roles(self):
for node_role in self.node.findall('role'):
role = Crole(node_role)
role.remove_external_references()
|
module function_definition identifier parameters identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
Removes any external references on any of the roles from the predicate
|
def _infer_dict(obj):
for ats in (('__len__', 'get', 'has_key', 'items', 'keys', 'values'),
('__len__', 'get', 'has_key', 'iteritems', 'iterkeys', 'itervalues')):
for a in ats:
if not _callable(getattr(obj, a, None)):
break
else:
return True
return False
|
module function_definition identifier parameters identifier block for_statement identifier tuple tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block for_statement identifier identifier block if_statement not_operator call identifier argument_list call identifier argument_list identifier identifier none block break_statement else_clause block return_statement true return_statement false
|
Return True for likely dict object.
|
def getEyeOutputViewport(self, eEye):
fn = self.function_table.getEyeOutputViewport
pnX = c_uint32()
pnY = c_uint32()
pnWidth = c_uint32()
pnHeight = c_uint32()
fn(eEye, byref(pnX), byref(pnY), byref(pnWidth), byref(pnHeight))
return pnX.value, pnY.value, pnWidth.value, pnHeight.value
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier return_statement expression_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
|
Gets the viewport in the frame buffer to draw the output of the distortion into
|
def open_submission(self):
url = self.get_selected_item().get('submission_permalink')
if url:
self.selected_page = self.open_submission_page(url)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier
|
Open the full submission and comment tree for the selected comment.
|
def _parse_scram_response(response):
return dict(item.split(b"=", 1) for item in response.split(b","))
|
module function_definition identifier parameters identifier block return_statement call identifier generator_expression call attribute identifier identifier argument_list string string_start string_content string_end integer for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end
|
Split a scram response into key, value pairs.
|
def parse_headers_link(headers):
header = CaseInsensitiveDict(headers).get('link')
l = {}
if header:
links = parse_link(header)
for link in links:
key = link.get('rel') or link.get('url')
l[key] = link
return l
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier identifier identifier return_statement identifier
|
Returns the parsed header links of the response, if any.
|
def write(settings_path, settings_data, **kwargs):
for key, value in settings_data.items():
dotenv_cli.set_key(str(settings_path), key.upper(), str(value))
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier call attribute identifier identifier argument_list call identifier argument_list identifier
|
Write data to .env file
|
def delete_untagged(collector, **kwargs):
configuration = collector.configuration
docker_api = configuration["harpoon"].docker_api
images = docker_api.images()
found = False
for image in images:
if image["RepoTags"] == ["<none>:<none>"]:
found = True
image_id = image["Id"]
log.info("Deleting untagged image\thash=%s", image_id)
try:
docker_api.remove_image(image["Id"])
except DockerAPIError as error:
log.error("Failed to delete image\thash=%s\terror=%s", image_id, error)
if not found:
log.info("Didn't find any untagged images to delete!")
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier false for_statement identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end list string string_start string_content string_end block expression_statement assignment identifier true expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end identifier try_statement block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end identifier identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
|
Find the untagged images and remove them
|
def keep_only_sticked_and_selected_tabs(self):
if not global_gui_config.get_config_value('KEEP_ONLY_STICKY_STATES_OPEN', True):
return
page_id = self.view.notebook.get_current_page()
if page_id == -1:
return
page = self.view.notebook.get_nth_page(page_id)
current_state_identifier = self.get_state_identifier_for_page(page)
states_to_be_closed = []
for state_identifier, tab_info in list(self.tabs.items()):
if current_state_identifier == state_identifier:
continue
if tab_info['is_sticky']:
continue
states_to_be_closed.append(state_identifier)
for state_identifier in states_to_be_closed:
self.close_page(state_identifier, delete=False)
|
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end true block return_statement expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list if_statement comparison_operator identifier unary_operator integer block return_statement expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier identifier block continue_statement if_statement subscript identifier string string_start string_content string_end block continue_statement expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier false
|
Close all tabs, except the currently active one and all sticked ones
|
def request(self, method, url, **kwargs):
self._check_auth()
return super(OAuthAPIClient, self).request(method, url, **kwargs)
|
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier dictionary_splat identifier
|
Overrides Session.request to ensure that the session is authenticated
|
def bitop_and(self, dest, key, *keys):
return self.execute(b'BITOP', b'AND', dest, key, *keys)
|
module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier identifier list_splat identifier
|
Perform bitwise AND operations between strings.
|
def update_ports(self) -> None:
self.update(path=URL_GET + GROUP.format(group=INPUT))
self.update(path=URL_GET + GROUP.format(group=IOPORT))
self.update(path=URL_GET + GROUP.format(group=OUTPUT))
|
module function_definition identifier parameters identifier type none block expression_statement call attribute identifier identifier argument_list keyword_argument identifier binary_operator identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier binary_operator identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier binary_operator identifier call attribute identifier identifier argument_list keyword_argument identifier identifier
|
Update port groups of parameters.
|
def run_selected_clicked(self):
rows = sorted(set(index.row() for index in
self.table.selectedIndexes()))
self.enable_busy_cursor()
for row in rows:
current_row = row
item = self.table.item(current_row, 0)
status_item = self.table.item(current_row, 1)
self.run_task(item, status_item)
self.disable_busy_cursor()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call identifier generator_expression call attribute identifier identifier argument_list for_in_clause identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier integer expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list
|
Run the selected scenario.
|
def _get_extension_by_field(self, name):
if name is None:
raise TypeError("Expected field name")
tr_model = self.get_model_by_field(name)
for meta in self._extensions:
if meta.model == tr_model:
return meta
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block return_statement identifier
|
Find the ParlerOptions object that corresponds with the given translated field.
|
def calculate_extents(labels, indexes):
fix = fixup_scipy_ndimage_result
areas = fix(scind.sum(np.ones(labels.shape),labels,np.array(indexes, dtype=np.int32)))
y,x = np.mgrid[0:labels.shape[0],0:labels.shape[1]]
xmin = fix(scind.minimum(x, labels, indexes))
xmax = fix(scind.maximum(x, labels, indexes))
ymin = fix(scind.minimum(y, labels, indexes))
ymax = fix(scind.maximum(y, labels, indexes))
bbareas = (xmax-xmin+1)*(ymax-ymin+1)
return areas / bbareas
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier subscript attribute identifier identifier slice integer subscript attribute identifier identifier integer slice integer subscript attribute identifier identifier integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator identifier identifier integer parenthesized_expression binary_operator binary_operator identifier identifier integer return_statement binary_operator identifier identifier
|
Return the area of each object divided by the area of its bounding box
|
def prevPlot(self):
if self.stacker.currentIndex() > 0:
self.stacker.setCurrentIndex(self.stacker.currentIndex()-1)
|
module function_definition identifier parameters identifier block if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list integer block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator call attribute attribute identifier identifier identifier argument_list integer
|
Moves the displayed plot to the previous one
|
def on_batch_end(self, last_target, train, **kwargs):
"Update the metrics if not `train`"
if train: return
bs = last_target.size(0)
for name in self.names:
self.metrics[name] += bs * self.learn.loss_func.metrics[name].detach().cpu()
self.nums += bs
|
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end if_statement identifier block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list integer for_statement identifier attribute identifier identifier block expression_statement augmented_assignment subscript attribute identifier identifier identifier binary_operator identifier call attribute call attribute subscript attribute attribute attribute identifier identifier identifier identifier identifier identifier argument_list identifier argument_list expression_statement augmented_assignment attribute identifier identifier identifier
|
Update the metrics if not `train`
|
def render_to_string(self, template_file, context):
context = context if context else {}
if self.object:
context['object'] = self.object
context[self.object.__class__.__name__.lower()] = self.object
return render_to_string(template_file, context, self.request)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier conditional_expression identifier identifier dictionary if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list attribute identifier identifier return_statement call identifier argument_list identifier identifier attribute identifier identifier
|
Render given template to string and add object to context
|
def param_apropos(self, args):
if len(args) == 0:
print("Usage: param apropos keyword")
return
htree = self.param_help_tree()
if htree is None:
return
contains = {}
for keyword in args:
for param in htree.keys():
if str(htree[param]).find(keyword) != -1:
contains[param] = True
for param in contains.keys():
print("%s" % (param,))
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call identifier argument_list string string_start string_content string_end return_statement expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block return_statement expression_statement assignment identifier dictionary for_statement identifier identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator call attribute call identifier argument_list subscript identifier identifier identifier argument_list identifier unary_operator integer block expression_statement assignment subscript identifier identifier true for_statement identifier call attribute identifier identifier argument_list block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier
|
search parameter help for a keyword, list those parameters
|
def _write(self, session, openFile, replaceParamFile):
timeSeries = self.timeSeries
numTS = len(timeSeries)
valList = []
for tsNum, ts in enumerate(timeSeries):
values = ts.values
for value in values:
valDict = {'time': value.simTime,
'tsNum': tsNum,
'value': value.value}
valList.append(valDict)
result = pivot(valList, ('time',), ('tsNum',), 'value')
for line in result:
valString = ''
for n in range(0, numTS):
val = '%.6f' % line[(n,)]
valString = '%s%s%s' % (
valString,
' ' * (13 - len(str(val))),
val)
openFile.write(' %.8f%s\n' % (line['time'], valString))
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier attribute identifier identifier for_statement identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier tuple string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier string string_start string_end for_statement identifier call identifier argument_list integer identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end subscript identifier tuple identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier binary_operator string string_start string_content string_end parenthesized_expression binary_operator integer call identifier argument_list call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple subscript identifier string string_start string_content string_end identifier
|
Generic Time Series Write to File Method
|
async def destroy_unit(self, *unit_names):
connection = self.connection()
app_facade = client.ApplicationFacade.from_connection(connection)
log.debug(
'Destroying unit%s %s',
's' if len(unit_names) == 1 else '',
' '.join(unit_names))
return await app_facade.DestroyUnits(list(unit_names))
|
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end conditional_expression string string_start string_content string_end comparison_operator call identifier argument_list identifier integer string string_start string_end call attribute string string_start string_content string_end identifier argument_list identifier return_statement await call attribute identifier identifier argument_list call identifier argument_list identifier
|
Destroy units by name.
|
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
if self.url:
iframe_html = '<iframe src="{}" frameborder="0" title="{}" allowfullscreen></iframe>'
self.html = iframe_html.format(
self.get_embed_url(),
self.title
)
return super().save(force_insert, force_update, using, update_fields)
|
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier false default_parameter identifier none default_parameter identifier none block if_statement attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute call identifier argument_list identifier argument_list identifier identifier identifier identifier
|
Set html field with correct iframe.
|
def generate_docker_compose(self):
example = {}
example['app'] = {}
example['app']['environment'] = []
for key in sorted(list(self.spec.keys())):
if self.spec[key]['type'] in (dict, list):
value = f"\'{json.dumps(self.spec[key].get('example', ''))}\'"
else:
value = f"{self.spec[key].get('example', '')}"
example['app']['environment'].append(f"{self.env_prefix}_{key.upper()}={value}")
print(yaml.dump(example, default_flow_style=False))
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end dictionary expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end list for_statement identifier call identifier argument_list call identifier argument_list call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator subscript subscript attribute identifier identifier identifier string string_start string_content string_end tuple identifier identifier block expression_statement assignment identifier string string_start string_content escape_sequence interpolation call attribute identifier identifier argument_list call attribute subscript attribute identifier identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end string_content escape_sequence string_end else_clause block expression_statement assignment identifier string string_start interpolation call attribute subscript attribute identifier identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end string_end expression_statement call attribute subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list string string_start interpolation attribute identifier identifier string_content interpolation call attribute identifier identifier argument_list string_content interpolation identifier string_end expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier false
|
Generate a sample docker compose
|
def stop(self) -> None:
if self._stop and not self._posted_kork:
self._stop()
self._stop = None
|
module function_definition identifier parameters identifier type none block if_statement boolean_operator attribute identifier identifier not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier none
|
Stops the analysis as soon as possible.
|
def estimate_max_mapq(in_bam, nreads=1e6):
with pysam.Samfile(in_bam, "rb") as work_bam:
reads = tz.take(int(nreads), work_bam)
return max([x.mapq for x in reads if not x.is_unmapped])
|
module function_definition identifier parameters identifier default_parameter identifier float block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier identifier return_statement call identifier argument_list list_comprehension attribute identifier identifier for_in_clause identifier identifier if_clause not_operator attribute identifier identifier
|
Guess maximum MAPQ in a BAM file of reads with alignments
|
def compute_distances_dict(egg):
pres, rec, features, dist_funcs = parse_egg(egg)
pres_list = list(pres)
features_list = list(features)
distances = {}
for idx1, item1 in enumerate(pres_list):
distances[item1]={}
for idx2, item2 in enumerate(pres_list):
distances[item1][item2]={}
for feature in dist_funcs:
distances[item1][item2][feature] = builtin_dist_funcs[dist_funcs[feature]](features_list[idx1][feature],features_list[idx2][feature])
return distances
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment subscript identifier identifier dictionary for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment subscript subscript identifier identifier identifier dictionary for_statement identifier identifier block expression_statement assignment subscript subscript subscript identifier identifier identifier identifier call subscript identifier subscript identifier identifier argument_list subscript subscript identifier identifier identifier subscript subscript identifier identifier identifier return_statement identifier
|
Creates a nested dict of distances
|
def write(self, frame):
if not isinstance(frame, FrameBase):
raise PyVLXException("Frame not of type FrameBase", frame_type=type(frame))
PYVLXLOG.debug("SEND: %s", frame)
self.transport.write(slip_pack(bytes(frame)))
|
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list call identifier argument_list identifier
|
Write frame to Bus.
|
def load_lists(keys=[], values=[], name='NT'):
mapping = dict(zip(keys, values))
return mapper(mapping, _nt_name=name)
|
module function_definition identifier parameters default_parameter identifier list default_parameter identifier list default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier return_statement call identifier argument_list identifier keyword_argument identifier identifier
|
Map namedtuples given a pair of key, value lists.
|
def radlToSimple(radl_data):
aspects = (radl_data.ansible_hosts + radl_data.networks + radl_data.systems +
radl_data.configures + radl_data.deploys)
if radl_data.contextualize.items is not None:
aspects.append(radl_data.contextualize)
return [aspectToSimple(a) for a in aspects]
|
module function_definition identifier parameters identifier block expression_statement assignment identifier parenthesized_expression binary_operator binary_operator binary_operator binary_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute attribute identifier identifier identifier none block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier
|
Return a list of maps whose values are only other maps or lists.
|
def pass_community(f):
@wraps(f)
def inner(community_id, *args, **kwargs):
c = Community.get(community_id)
if c is None:
abort(404)
return f(c, *args, **kwargs)
return inner
|
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 call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call identifier argument_list integer return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier
|
Decorator to pass community.
|
def preview_filter_from_query(query, id_field="id", field_map={}):
f = groups_filter_from_query(query, field_map=field_map)
included_ids = query.get("included_ids")
if included_ids:
if f:
f |= Terms(pk=included_ids)
else:
f = Terms(pk=included_ids)
return f
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier dictionary block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block if_statement identifier block expression_statement augmented_assignment identifier call identifier argument_list keyword_argument identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier return_statement identifier
|
This filter includes the "excluded_ids" so they still show up in the editor.
|
def get(self, nb=0):
return {i: self.stats_history[i].history_raw(nb=nb) for i in self.stats_history}
|
module function_definition identifier parameters identifier default_parameter identifier integer block return_statement dictionary_comprehension pair identifier call attribute subscript attribute identifier identifier identifier identifier argument_list keyword_argument identifier identifier for_in_clause identifier attribute identifier identifier
|
Get the history as a dict of list
|
def atlas_peer_is_whitelisted( peer_hostport, peer_table=None ):
ret = None
with AtlasPeerTableLocked(peer_table) as ptbl:
if peer_hostport not in ptbl.keys():
return None
ret = ptbl[peer_hostport].get("whitelisted", False)
return ret
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier none with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block if_statement comparison_operator identifier call attribute identifier identifier argument_list block return_statement none expression_statement assignment identifier call attribute subscript identifier identifier identifier argument_list string string_start string_content string_end false return_statement identifier
|
Is a peer whitelisted
|
def graft(coll, branch, index):
pre = coll[:index]
post = coll[index:]
ret = pre + branch + post
return ret
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript identifier slice identifier expression_statement assignment identifier subscript identifier slice identifier expression_statement assignment identifier binary_operator binary_operator identifier identifier identifier return_statement identifier
|
Graft list branch into coll at index
|
def color(self):
color = idc.GetColor(self.ea, idc.CIC_ITEM)
if color == 0xFFFFFFFF:
return None
return color
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier if_statement comparison_operator identifier integer block return_statement none return_statement identifier
|
Line color in IDA View
|
def _convert_point(cls, feature):
lon, lat = feature['geometry']['coordinates']
popup = feature['properties'].get('name', '')
return cls(lat, lon)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end string string_start string_end return_statement call identifier argument_list identifier identifier
|
Convert a GeoJSON point to a Marker.
|
def reconstruct(self, t:Tensor, x:Tensor=None):
"Reconstruct one of the underlying item for its data `t`."
return self[0].reconstruct(t,x) if has_arg(self[0].reconstruct, 'x') else self[0].reconstruct(t)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier none block expression_statement string string_start string_content string_end return_statement conditional_expression call attribute subscript identifier integer identifier argument_list identifier identifier call identifier argument_list attribute subscript identifier integer identifier string string_start string_content string_end call attribute subscript identifier integer identifier argument_list identifier
|
Reconstruct one of the underlying item for its data `t`.
|
def geojson(self, feature_id):
if self._geojson.get('id', feature_id) == feature_id:
return self._geojson
else:
geo = self._geojson.copy()
geo['id'] = feature_id
return geo
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier identifier block return_statement attribute identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier
|
Return GeoJSON with ID substituted.
|
def invoked(self, ctx):
if not ctx.ansi.is_enabled:
print("You need color support to use this demo")
else:
print(ctx.ansi.cmd('erase_display'))
self._demo_fg_color(ctx)
self._demo_bg_color(ctx)
self._demo_bg_indexed(ctx)
self._demo_rgb(ctx)
self._demo_style(ctx)
|
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute attribute identifier identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end else_clause block expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
|
Method called when the command is invoked.
|
def remove(self, experiment):
try:
project_path = self.projects[self[experiment]['project']]['root']
except KeyError:
return
config_path = osp.join(project_path, '.project', experiment + '.yml')
for f in [config_path, config_path + '~', config_path + '.lck']:
if os.path.exists(f):
os.remove(f)
del self[experiment]
|
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier subscript subscript attribute identifier identifier subscript subscript identifier identifier string string_start string_content string_end string string_start string_content string_end except_clause identifier block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end binary_operator identifier string string_start string_content string_end for_statement identifier list identifier binary_operator identifier string string_start string_content string_end binary_operator identifier string string_start string_content string_end block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier delete_statement subscript identifier identifier
|
Remove the configuration of an experiment
|
def run(self, graminit_h, graminit_c):
self.parse_graminit_h(graminit_h)
self.parse_graminit_c(graminit_c)
self.finish_off()
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
Load the grammar tables from the text files written by pgen.
|
def create_migration_ctx(**kwargs):
env = EnvironmentContext(Config(), None)
env.configure(
connection=db.engine.connect(),
sqlalchemy_module_prefix='db.',
**kwargs
)
return env.get_context()
|
module function_definition identifier parameters dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list none expression_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end dictionary_splat identifier return_statement call attribute identifier identifier argument_list
|
Create an alembic migration context.
|
def keep_only_current_window(self):
self.tab_pages = [TabPage(self.active_tab.active_window)]
self.active_tab_index = 0
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier list call identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier integer
|
Close all other windows, except the current one.
|
def keyPressEvent(self, event):
ctrl = event.modifiers() & Qt.ControlModifier
shift = event.modifiers() & Qt.ShiftModifier
if event.key() in (Qt.Key_Enter, Qt.Key_Return):
self.find.emit()
elif event.key() == Qt.Key_F and ctrl and shift:
self.parent().toggle_visibility.emit(not self.isVisible())
else:
QWidget.keyPressEvent(self, event)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator call attribute identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list elif_clause boolean_operator boolean_operator comparison_operator call attribute identifier identifier argument_list attribute identifier identifier identifier identifier block expression_statement call attribute attribute call attribute identifier identifier argument_list identifier identifier argument_list not_operator call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier
|
Reimplemented to handle key events
|
def _notify_thing_lid_change(self, from_lid, to_lid):
try:
with self.__private_things:
self.__private_things[to_lid] = self.__private_things.pop(from_lid)
except KeyError:
logger.warning('Thing %s renamed (to %s), but not in private lookup table', from_lid, to_lid)
else:
try:
with self.__new_things:
self.__new_things[to_lid] = self.__new_things.pop(from_lid)
except KeyError:
pass
|
module function_definition identifier parameters identifier identifier identifier block try_statement block with_statement with_clause with_item attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier else_clause block try_statement block with_statement with_clause with_item attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block pass_statement
|
Used by Thing instances to indicate that a rename operation has happened
|
def from_json(cls, json_info):
if json_info is None:
return None
return TrialRecord(
trial_id=json_info["trial_id"],
job_id=json_info["job_id"],
trial_status=json_info["status"],
start_time=json_info["start_time"],
params=json_info["params"])
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block return_statement none return_statement call identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end
|
Build a Trial instance from a json string.
|
def interpolate(text, global_dict=None, local_dict=None):
try:
return eval(as_fstring(text), global_dict, local_dict)
except Exception as e:
raise ValueError(f'Failed to interpolate {text}: {e}')
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block try_statement block return_statement call identifier argument_list call identifier argument_list identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list string string_start string_content interpolation identifier string_content interpolation identifier string_end
|
Evaluate expressions in `text`
|
def run_reducer(self, stdin=sys.stdin, stdout=sys.stdout):
self.init_hadoop()
self.init_reducer()
outputs = self._reduce_input(self.internal_reader((line[:-1] for line in stdin)), self.reducer, self.final_reducer)
self.writer(outputs, stdout)
|
module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier default_parameter identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list generator_expression subscript identifier slice unary_operator integer for_in_clause identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier
|
Run the reducer on the hadoop node.
|
def print_version(ctx, value):
if not value:
return
import pkg_resources
version = None
try:
version = pkg_resources.get_distribution('sandman').version
finally:
del pkg_resources
click.echo(version)
ctx.exit()
|
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement import_statement dotted_name identifier expression_statement assignment identifier none try_statement block expression_statement assignment identifier attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier finally_clause block delete_statement identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
Print the current version of sandman and exit.
|
def validate_uses_tls_for_glance(audit_options):
section = _config_section(audit_options, 'glance')
assert section is not None, "Missing section 'glance'"
assert not section.get('insecure') and \
"https://" in section.get("api_servers"), \
"TLS is not used for Glance"
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end assert_statement comparison_operator identifier none string string_start string_content string_end assert_statement boolean_operator not_operator call attribute identifier identifier argument_list string string_start string_content string_end comparison_operator string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end
|
Verify that TLS is used to communicate with Glance.
|
def _server_loop(self, client, client_addr):
while not self._stopped and not _shutting_down:
try:
with self._unlock():
request = mock_server_receive_request(client, self)
self._requests_count += 1
self._log('%d\t%r' % (request.client_port, request))
for responder in reversed(self._autoresponders):
if responder.handle(request):
self._log('\t(autoresponse)')
break
else:
self._request_q.put(request)
except socket.error as error:
if error.errno in (errno.ECONNRESET, errno.EBADF):
break
raise
except select.error as error:
if error.args[0] == errno.EBADF:
break
else:
raise
except AssertionError:
traceback.print_exc()
break
self._log('disconnected: %s' % format_addr(client_addr))
client.close()
|
module function_definition identifier parameters identifier identifier identifier block while_statement boolean_operator not_operator attribute identifier identifier not_operator identifier block try_statement block with_statement with_clause with_item call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple attribute identifier identifier identifier for_statement identifier call identifier argument_list attribute identifier identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end break_statement else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier tuple attribute identifier identifier attribute identifier identifier block break_statement raise_statement except_clause as_pattern attribute identifier identifier as_pattern_target identifier block if_statement comparison_operator subscript attribute identifier identifier integer attribute identifier identifier block break_statement else_clause block raise_statement except_clause identifier block expression_statement call attribute identifier identifier argument_list break_statement expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
|
Read requests from one client socket, 'client'.
|
def clear(self):
if os.path.exists(self.path):
os.remove(self.path)
|
module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier
|
Remove all existing done markers and the file used to store the dones.
|
def _set_relative_pythonpath(self, value):
self.pythonpath = [osp.abspath(osp.join(self.root_path, path))
for path in value]
|
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier list_comprehension call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier for_in_clause identifier identifier
|
Set PYTHONPATH list relative paths
|
def reverse_name_server(self, query, limit=None, **kwargs):
return self._results('reverse-name-server', '/v1/{0}/name-server-domains'.format(query),
items_path=('primary_domains', ), limit=limit, **kwargs)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier tuple string string_start string_content string_end keyword_argument identifier identifier dictionary_splat identifier
|
Pass in a domain name or a name server.
|
def lpop(self, key, *, encoding=_NOTSET):
return self.execute(b'LPOP', key, encoding=encoding)
|
module function_definition identifier parameters identifier identifier keyword_separator default_parameter identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier identifier
|
Removes and returns the first element of the list stored at key.
|
def zipline_magic(line, cell=None):
load_extensions(
default=True,
extensions=[],
strict=True,
environ=os.environ,
)
try:
return run.main(
[
'--algotext', cell,
'--output', os.devnull,
] + ([
'--algotext', '',
'--local-namespace',
] if cell is None else []) + line.split(),
'%s%%zipline' % ((cell or '') and '%'),
standalone_mode=False,
)
except SystemExit as e:
if e.code:
raise ValueError('main returned non-zero status code: %d' % e.code)
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement call identifier argument_list keyword_argument identifier true keyword_argument identifier list keyword_argument identifier true keyword_argument identifier attribute identifier identifier try_statement block return_statement call attribute identifier identifier argument_list binary_operator binary_operator list string string_start string_content string_end identifier string string_start string_content string_end attribute identifier identifier parenthesized_expression conditional_expression list string string_start string_content string_end string string_start string_end string string_start string_content string_end comparison_operator identifier none list call attribute identifier identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression boolean_operator parenthesized_expression boolean_operator identifier string string_start string_end string string_start string_content string_end keyword_argument identifier false except_clause as_pattern identifier as_pattern_target identifier block if_statement attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier
|
The zipline IPython cell magic.
|
def _stopLeader(cls):
with cls.lock:
assert cls.initialized > 0
cls.initialized -= 1
if cls.initialized == 0:
if cls.loggingServer:
log.info('Stopping real-time logging server.')
cls.loggingServer.shutdown()
cls.loggingServer = None
if cls.serverThread:
log.info('Joining real-time logging server thread.')
cls.serverThread.join()
cls.serverThread = None
for k in list(os.environ.keys()):
if k.startswith(cls.envPrefix):
os.environ.pop(k)
|
module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block assert_statement comparison_operator attribute identifier identifier integer expression_statement augmented_assignment attribute identifier identifier integer if_statement comparison_operator attribute identifier identifier integer block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none for_statement identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block if_statement call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Stop the server on the leader.
|
def router_deleted(self, context, routers):
LOG.debug('Got router deleted notification for %s', routers)
self._update_removed_routers_cache(routers)
|
module function_definition identifier parameters identifier 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 identifier
|
Deal with router deletion RPC message.
|
def html(self):
output = self.html_preamble
output += self._repr_html_()
output += self.html_post
return output
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement augmented_assignment identifier call attribute identifier identifier argument_list expression_statement augmented_assignment identifier attribute identifier identifier return_statement identifier
|
Gives an html representation of the assessment.
|
def GetValue(self, row, col, table=None):
if table is None:
table = self.grid.current_table
try:
cell_code = self.code_array((row, col, table))
except IndexError:
cell_code = None
maxlength = int(config["max_textctrl_length"])
if cell_code is not None and len(cell_code) > maxlength:
chunk = 80
cell_code = "\n".join(cell_code[i:i + chunk]
for i in xrange(0, len(cell_code), chunk))
return cell_code
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute attribute identifier identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier identifier identifier except_clause identifier block expression_statement assignment identifier none expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end if_statement boolean_operator comparison_operator identifier none comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier integer expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier generator_expression subscript identifier slice identifier binary_operator identifier identifier for_in_clause identifier call identifier argument_list integer call identifier argument_list identifier identifier return_statement identifier
|
Return the result value of a cell, line split if too much data
|
def data_recognise(self, data=None):
data = data or self.data
data_lower = data.lower()
if data_lower.startswith(u"http://") or data_lower.startswith(u"https://"):
return u'url'
elif data_lower.startswith(u"mailto:"):
return u'email'
elif data_lower.startswith(u"matmsg:to:"):
return u'emailmessage'
elif data_lower.startswith(u"tel:"):
return u'telephone'
elif data_lower.startswith(u"smsto:"):
return u'sms'
elif data_lower.startswith(u"mmsto:"):
return u'mms'
elif data_lower.startswith(u"geo:"):
return u'geo'
elif data_lower.startswith(u"mebkm:title:"):
return u'bookmark'
elif data_lower.startswith(u"mecard:"):
return u'phonebook'
else:
return u'text'
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end else_clause block return_statement string string_start string_content string_end
|
Returns an unicode string indicating the data type of the data paramater
|
def _freemem(conn):
mem = conn.getInfo()[1]
mem -= 256
for dom in _get_domain(conn, iterable=True):
if dom.ID() > 0:
mem -= dom.info()[2] / 1024
return mem
|
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer expression_statement augmented_assignment identifier integer for_statement identifier call identifier argument_list identifier keyword_argument identifier true block if_statement comparison_operator call attribute identifier identifier argument_list integer block expression_statement augmented_assignment identifier binary_operator subscript call attribute identifier identifier argument_list integer integer return_statement identifier
|
Internal variant of freemem taking a libvirt connection as parameter
|
def compare(operator,a,b):
"this could be replaced by overloading but I want == to return a bool for 'in' use"
f=({'=':lambda a,b:a==b,'!=':lambda a,b:a!=b,'>':lambda a,b:a>b,'<':lambda a,b:a<b}[operator])
return ThreeVL('u') if None in (a,b) else f(a,b)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier parenthesized_expression subscript dictionary pair string string_start string_content string_end lambda lambda_parameters identifier identifier comparison_operator identifier identifier pair string string_start string_content string_end lambda lambda_parameters identifier identifier comparison_operator identifier identifier pair string string_start string_content string_end lambda lambda_parameters identifier identifier comparison_operator identifier identifier pair string string_start string_content string_end lambda lambda_parameters identifier identifier comparison_operator identifier identifier identifier return_statement conditional_expression call identifier argument_list string string_start string_content string_end comparison_operator none tuple identifier identifier call identifier argument_list identifier identifier
|
this could be replaced by overloading but I want == to return a bool for 'in' use
|
def read(path, savedir):
" Read file from path "
if path.startswith('http://'):
name = op.basename(path)
save_path = op.join(savedir, name)
if not op.exists(save_path):
src = urllib2.urlopen(path).read()
try:
open(save_path, 'w').write(src)
except IOError:
return src
path = save_path
return open(path, 'r').read()
|
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end 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 identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list try_statement block expression_statement call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list identifier except_clause identifier block return_statement identifier expression_statement assignment identifier identifier return_statement call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list
|
Read file from path
|
def closed(self, user):
decision = False
for record in self.history:
if record["when"] < self.options.since.date:
continue
if not decision and record["when"] < self.options.until.date:
for change in record["changes"]:
if (change["field_name"] == "status"
and change["added"] == "CLOSED"
and record["who"] in [user.email, user.name]):
decision = True
else:
for change in record["changes"]:
if (change["field_name"] == "status"
and change["removed"] == "CLOSED"):
decision = False
return decision
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier false for_statement identifier attribute identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier block continue_statement if_statement boolean_operator not_operator identifier comparison_operator subscript identifier string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier block for_statement identifier subscript identifier string string_start string_content string_end block if_statement parenthesized_expression boolean_operator boolean_operator comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end list attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier true else_clause block for_statement identifier subscript identifier string string_start string_content string_end block if_statement parenthesized_expression boolean_operator comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier false return_statement identifier
|
Moved to CLOSED and not later moved to ASSIGNED
|
def _vertex_list_to_sframe(ls, id_column_name):
sf = SFrame()
if type(ls) == list:
cols = reduce(set.union, (set(v.attr.keys()) for v in ls))
sf[id_column_name] = [v.vid for v in ls]
for c in cols:
sf[c] = [v.attr.get(c) for v in ls]
elif type(ls) == Vertex:
sf[id_column_name] = [ls.vid]
for col, val in ls.attr.iteritems():
sf[col] = [val]
else:
raise TypeError('Vertices type {} is Not supported.'.format(type(ls)))
return sf
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier generator_expression call identifier argument_list call attribute attribute identifier identifier identifier argument_list for_in_clause identifier identifier expression_statement assignment subscript identifier identifier list_comprehension attribute identifier identifier for_in_clause identifier identifier for_statement identifier identifier block expression_statement assignment subscript identifier identifier list_comprehension call attribute attribute identifier identifier identifier argument_list identifier for_in_clause identifier identifier elif_clause comparison_operator call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier list attribute identifier identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier identifier list identifier else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier return_statement identifier
|
Convert a list of vertices into an SFrame.
|
def play_empty(self):
if self.vclient:
if self.streamer:
self.streamer.volume = 0
self.vclient.play_audio("\n".encode(), encode=False)
|
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block if_statement attribute identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list keyword_argument identifier false
|
Play blank audio to let Discord know we're still here
|
def SaveResourceUsage(self, status):
user_cpu = status.cpu_time_used.user_cpu_time
system_cpu = status.cpu_time_used.system_cpu_time
self.rdf_flow.cpu_time_used.user_cpu_time += user_cpu
self.rdf_flow.cpu_time_used.system_cpu_time += system_cpu
self.rdf_flow.network_bytes_sent += status.network_bytes_sent
if self.rdf_flow.cpu_limit:
user_cpu_total = self.rdf_flow.cpu_time_used.user_cpu_time
system_cpu_total = self.rdf_flow.cpu_time_used.system_cpu_time
if self.rdf_flow.cpu_limit < (user_cpu_total + system_cpu_total):
raise flow.FlowError("CPU limit exceeded for {} {}.".format(
self.rdf_flow.flow_class_name, self.rdf_flow.flow_id))
if (self.rdf_flow.network_bytes_limit and
self.rdf_flow.network_bytes_limit < self.rdf_flow.network_bytes_sent):
raise flow.FlowError("Network bytes limit exceeded {} {}.".format(
self.rdf_flow.flow_class_name, self.rdf_flow.flow_id))
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement augmented_assignment attribute attribute attribute identifier identifier identifier identifier identifier expression_statement augmented_assignment attribute attribute attribute identifier identifier identifier identifier identifier expression_statement augmented_assignment attribute attribute identifier identifier identifier attribute identifier identifier if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier if_statement comparison_operator attribute attribute identifier identifier identifier parenthesized_expression binary_operator identifier identifier block raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier if_statement parenthesized_expression boolean_operator attribute attribute identifier identifier identifier comparison_operator attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier block raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier
|
Method to tally resources.
|
def _path2point(path):
return {_VARS[node.root]: int(node.hi is path[i+1])
for i, node in enumerate(path[:-1])}
|
module function_definition identifier parameters identifier block return_statement dictionary_comprehension pair subscript identifier attribute identifier identifier call identifier argument_list comparison_operator attribute identifier identifier subscript identifier binary_operator identifier integer for_in_clause pattern_list identifier identifier call identifier argument_list subscript identifier slice unary_operator integer
|
Convert a BDD path to a BDD point.
|
def quaternion(vector, angle):
return N.cos(angle/2)+vector*N.sin(angle/2)
|
module function_definition identifier parameters identifier identifier block return_statement binary_operator call attribute identifier identifier argument_list binary_operator identifier integer binary_operator identifier call attribute identifier identifier argument_list binary_operator identifier integer
|
Unit quaternion for a vector and an angle
|
def download_file(self, url, filename):
self.print_message("Downloading to file '%s' from URL '%s'" % (filename, url))
try:
db_file = urllib2.urlopen(url)
with open(filename, 'wb') as output:
output.write(db_file.read())
db_file.close()
except Exception as e:
self.error(str(e))
self.print_message("File downloaded")
|
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 try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
|
Download file from url to filename.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.