code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def standings(self):
headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain","User-Agent": user_agent}
req = self.session.get('http://'+self.domain+'/standings.phtml',headers=headers).content
soup = BeautifulSoup(req)
table = soup.find('table',{'id':'tablestandings'}).find_all('tr')
clasificacion = []
[clasificacion.append(('%s\t%s\t%s\t%s\t%s')%(tablas.find('td').text,tablas.find('div')['id'],tablas.a.text,tablas.find_all('td')[3].text,tablas.find_all('td')[4].text)) for tablas in table[1:]]
return clasificacion | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier expression_statement assignment identifier attribute call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end keyword_argument identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment identifier list expression_statement list_comprehension call attribute identifier identifier argument_list binary_operator parenthesized_expression string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end tuple attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute attribute identifier identifier identifier attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end integer identifier attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end integer identifier for_in_clause identifier subscript identifier slice integer return_statement identifier | Get standings from the community's account |
def uniquify_list(L):
return [e for i, e in enumerate(L) if L.index(e) == i] | module function_definition identifier parameters identifier block return_statement list_comprehension identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier if_clause comparison_operator call attribute identifier identifier argument_list identifier identifier | Same order unique list using only a list compression. |
def store(self, moments):
if len(self.storage) == self.nsave:
self.storage[-1].combine(moments, mean_free=self.remove_mean)
else:
self.storage.append(moments)
while self._can_merge_tail():
M = self.storage.pop()
self.storage[-1].combine(M, mean_free=self.remove_mean) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement call attribute subscript attribute identifier identifier unary_operator integer identifier argument_list identifier keyword_argument identifier attribute identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier while_statement call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute subscript attribute identifier identifier unary_operator integer identifier argument_list identifier keyword_argument identifier attribute identifier identifier | Store object X with weight w |
def _is_memory_usage_qualified(self):
def f(l):
return 'mixed' in l or 'string' in l or 'unicode' in l
return any(f(l) for l in self._inferred_type_levels) | module function_definition identifier parameters identifier block function_definition identifier parameters identifier block return_statement boolean_operator boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier return_statement call identifier generator_expression call identifier argument_list identifier for_in_clause identifier attribute identifier identifier | return a boolean if we need a qualified .info display |
def reset(self):
self.persisted_exists = False
self.persisted_nodes = []
self.persisted_streamers = []
self.persisted_constants = []
self.graph.clear()
self.streamer_status = {} | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier dictionary | Clear the sensorgraph from RAM and flash. |
def removeJob(self, jobBatchSystemID):
assert jobBatchSystemID in self.jobBatchSystemIDToIssuedJob
jobNode = self.jobBatchSystemIDToIssuedJob[jobBatchSystemID]
if jobNode.preemptable:
assert self.preemptableJobsIssued > 0
self.preemptableJobsIssued -= 1
del self.jobBatchSystemIDToIssuedJob[jobBatchSystemID]
if jobNode.jobStoreID in self.toilState.serviceJobStoreIDToPredecessorJob:
if jobNode.preemptable:
self.preemptableServiceJobsIssued -= 1
else:
self.serviceJobsIssued -= 1
return jobNode | module function_definition identifier parameters identifier identifier block assert_statement comparison_operator identifier attribute identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement attribute identifier identifier block assert_statement comparison_operator attribute identifier identifier integer expression_statement augmented_assignment attribute identifier identifier integer delete_statement subscript attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block if_statement attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier integer else_clause block expression_statement augmented_assignment attribute identifier identifier integer return_statement identifier | Removes a job from the system. |
def stopService(self):
super(_SiteScheduler, self).stopService()
if self.timer is not None:
self.timer.cancel()
self.timer = None | module function_definition identifier parameters identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none | Stop calling persistent timed events. |
def maximum_address(self):
maximum_address = self._segments.maximum_address
if maximum_address is not None:
maximum_address //= self.word_size_bytes
return maximum_address | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier attribute identifier identifier return_statement identifier | The maximum address of the data, or ``None`` if the file is empty. |
def cli(env):
mgr = SoftLayer.ObjectStorageManager(env.client)
accounts = mgr.list_accounts()
table = formatting.Table(['id', 'name', 'apiType'])
table.sortby = 'id'
api_type = None
for account in accounts:
if 'vendorName' in account and account['vendorName'] == 'Swift':
api_type = 'Swift'
elif 'Cleversafe' in account['serviceResource']['name']:
api_type = 'S3'
table.add_row([
account['id'],
account['username'],
api_type,
])
env.fout(table) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier none for_statement identifier identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator string string_start string_content string_end subscript subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier | List object storage accounts. |
def _get_last_snapshot(config='root'):
snapshot_list = sorted(list_snapshots(config), key=lambda x: x['id'])
return snapshot_list[-1] | module function_definition identifier parameters default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier subscript identifier string string_start string_content string_end return_statement subscript identifier unary_operator integer | Returns the last existing created snapshot |
def _send_ssh_pub(self, load, ssh_minions=False):
if self.opts['enable_ssh_minions'] is True and ssh_minions is True:
log.debug('Send payload to ssh minions')
threading.Thread(target=self.ssh_client.cmd, kwargs=load).start() | module function_definition identifier parameters identifier identifier default_parameter identifier false block if_statement boolean_operator comparison_operator subscript attribute identifier identifier string string_start string_content string_end true comparison_operator identifier true block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier identifier argument_list | Take a load and send it across the network to ssh minions |
def clear(self):
self._size = 0
self._level = 1
self._head = Node('HEAD', None,
[None]*SKIPLIST_MAXLEVEL,
[1]*SKIPLIST_MAXLEVEL) | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end none binary_operator list none identifier binary_operator list integer identifier | Clear the container from all data. |
def togglePopup(self):
if not self._popupWidget.isVisible():
self.showPopup()
elif self._popupWidget.currentMode() != self._popupWidget.Mode.Dialog:
self._popupWidget.close() | module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list elif_clause comparison_operator call attribute attribute identifier identifier identifier argument_list attribute attribute attribute identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list | Toggles whether or not the popup is visible. |
def rbac_policy_list(request, **kwargs):
policies = neutronclient(request).list_rbac_policies(
**kwargs).get('rbac_policies')
return [RBACPolicy(p) for p in policies] | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute call attribute call identifier argument_list identifier identifier argument_list dictionary_splat identifier identifier argument_list string string_start string_content string_end return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier | List of RBAC Policies. |
def _vpn_signal_handler(self, args):
active = "ActiveConnections"
if active in args.keys() and sorted(self.active) != sorted(args[active]):
self.active = args[active]
self.py3.update() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end if_statement boolean_operator comparison_operator identifier call attribute identifier identifier argument_list comparison_operator call identifier argument_list attribute identifier identifier call identifier argument_list subscript identifier identifier block expression_statement assignment attribute identifier identifier subscript identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list | Called on NetworkManager PropertiesChanged signal |
def _close_connection(self):
if (self._mode == PROP_MODE_SERIAL):
self._serial.close()
elif (self._mode == PROP_MODE_TCP):
self._socket.close()
elif (self._mode == PROP_MODE_FILE):
self._file.close() | module function_definition identifier parameters identifier block if_statement parenthesized_expression comparison_operator attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list elif_clause parenthesized_expression comparison_operator attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list elif_clause parenthesized_expression comparison_operator attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list | Close the connection to the easyfire unit. |
def acquire(self, resources, prop_name):
custom_prop = getattr(self.props, prop_name, None)
if custom_prop:
return custom_prop
for parent in self.parents(resources):
acquireds = parent.props.acquireds
if acquireds:
rtype_acquireds = acquireds.get(self.rtype)
if rtype_acquireds:
prop_acquired = rtype_acquireds.get(prop_name)
if prop_acquired:
return prop_acquired
all_acquireds = acquireds.get('all')
if all_acquireds:
prop_acquired = all_acquireds.get(prop_name)
if prop_acquired:
return prop_acquired
return | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier none if_statement identifier block return_statement identifier for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement identifier return_statement | Starting with self, walk until you find prop or None |
def read(source, channels, start=None, end=None, series_class=TimeSeries,
scaled=None):
if scaled is not None:
warnings.warn(
"the `scaled` keyword argument is not supported by lalframe, "
"if you require ADC scaling, please install "
"python-ldas-tools-framecpp",
)
stream = open_data_source(source)
epoch = lal.LIGOTimeGPS(stream.epoch.gpsSeconds,
stream.epoch.gpsNanoSeconds)
streamdur = get_stream_duration(stream)
if start is None:
start = epoch
else:
start = max(epoch, lalutils.to_lal_ligotimegps(start))
if end is None:
offset = float(start - epoch)
duration = streamdur - offset
else:
end = min(epoch + streamdur, lalutils.to_lal_ligotimegps(end))
duration = float(end - start)
out = series_class.DictClass()
for name in channels:
out[name] = series_class.from_lal(
_read_channel(stream, str(name), start=start, duration=duration),
copy=False)
lalframe.FrStreamSeek(stream, epoch)
return out | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list call identifier argument_list identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier false expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier | Read data from one or more GWF files using the LALFrame API |
def str_to_class(s):
lst = s.split(".")
klass = lst[-1]
mod_list = lst[:-1]
module = ".".join(mod_list)
try:
mod = __import__(module)
if hasattr(mod, klass):
return getattr(mod, klass)
else:
return None
except ImportError:
return None | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier unary_operator integer expression_statement assignment identifier subscript identifier slice unary_operator integer expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier identifier else_clause block return_statement none except_clause identifier block return_statement none | Alternate helper function to map string class names to module classes. |
def train(self, text, className):
self.data.increaseClass(className)
tokens = self.tokenizer.tokenize(text)
for token in tokens:
token = self.tokenizer.remove_stop_words(token)
token = self.tokenizer.remove_punctuation(token)
self.data.increaseToken(token, className) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier | enhances trained data using the given text and class |
def orient_import2(self, event):
pmag_menu_dialogs.ImportAzDipFile(self.parent, self.parent.WD) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier | initialize window to import an AzDip format file into the working directory |
def _GetCallingPrototypeAsString(self, flow_cls):
output = []
output.append("flow.StartAFF4Flow(client_id=client_id, ")
output.append("flow_name=\"%s\", " % flow_cls.__name__)
prototypes = []
if flow_cls.args_type:
for type_descriptor in flow_cls.args_type.type_infos:
if not type_descriptor.hidden:
prototypes.append("%s=%s" %
(type_descriptor.name, type_descriptor.name))
output.append(", ".join(prototypes))
output.append(")")
return "".join(output) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence string_end attribute identifier identifier expression_statement assignment identifier list if_statement attribute identifier identifier block for_statement identifier attribute attribute identifier identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute string string_start string_end identifier argument_list identifier | Get a description of the calling prototype for this flow class. |
def bbox_vflip(bbox, rows, cols):
x_min, y_min, x_max, y_max = bbox
return [x_min, 1 - y_max, x_max, 1 - y_min] | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier return_statement list identifier binary_operator integer identifier identifier binary_operator integer identifier | Flip a bounding box vertically around the x-axis. |
def line_range(self, line_number):
if line_number <= 0 or line_number > len(self.lines):
raise IndexError('NOTE: Python file line numbers are offset by 1.')
if line_number not in self.logical_lines:
return slice(line_number, line_number + 1)
else:
start, stop, _ = self.logical_lines[line_number]
return slice(start, stop) | module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier call identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block return_statement call identifier argument_list identifier binary_operator identifier integer else_clause block expression_statement assignment pattern_list identifier identifier identifier subscript attribute identifier identifier identifier return_statement call identifier argument_list identifier identifier | Return a slice for the given line number |
def RegisterLateBindingCallback(target_name, callback, **kwargs):
_LATE_BINDING_STORE.setdefault(target_name, []).append((callback, kwargs)) | module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement call attribute call attribute identifier identifier argument_list identifier list identifier argument_list tuple identifier identifier | Registers a callback to be invoked when the RDFValue named is declared. |
def output_to_terminal(sources):
results = OrderedDict()
for source in sources:
if source.get_is_available():
source.update()
results.update(source.get_summary())
for key, value in results.items():
sys.stdout.write(str(key) + ": " + str(value) + ", ")
sys.stdout.write("\n")
sys.exit() | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator binary_operator call identifier argument_list identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list | Print statistics to the terminal |
def _got_request_exception(self, sender, exception, **extra):
extra = self.summary_extra()
extra['errno'] = 500
self.summary_logger.error(str(exception), extra=extra)
g._has_exception = True | module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end integer expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment attribute identifier identifier true | The signal handler for the got_request_exception signal. |
def unsort_vector(data, indices_of_increasing):
return numpy.array([data[indices_of_increasing.index(i)] for i in range(len(data))]) | module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list list_comprehension subscript identifier call attribute identifier identifier argument_list identifier for_in_clause identifier call identifier argument_list call identifier argument_list identifier | Upermutate 1-D data that is sorted by indices_of_increasing. |
def update(self, async_=False, **kw):
async_ = kw.get('async', async_)
headers = {'Content-Type': 'application/xml'}
new_kw = dict()
if self.offline_model_name:
upload_keys = ('_parent', 'name', 'offline_model_name', 'offline_model_project', 'qos', 'instance_num')
else:
upload_keys = ('_parent', 'name', 'qos', '_model_resource', 'instance_num', 'predictor', 'runtime')
for k in upload_keys:
new_kw[k] = getattr(self, k)
new_kw.update(kw)
obj = type(self)(version='0', **new_kw)
data = obj.serialize()
self._client.put(self.resource(), data, headers=headers)
self.reload()
if not async_:
self.wait_for_service() | module function_definition identifier parameters identifier default_parameter identifier false dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list if_statement attribute identifier identifier block expression_statement assignment identifier 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 else_clause block expression_statement assignment identifier 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 string string_start string_content string_end for_statement identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call call identifier argument_list identifier argument_list keyword_argument identifier string string_start string_content string_end dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list | Update online model parameters to server. |
def _move_files_to_compute(compute, project_id, directory, files_path):
location = os.path.join(directory, files_path)
if os.path.exists(location):
for (dirpath, dirnames, filenames) in os.walk(location):
for filename in filenames:
path = os.path.join(dirpath, filename)
dst = os.path.relpath(path, directory)
yield from _upload_file(compute, project_id, path, dst)
shutil.rmtree(os.path.join(directory, files_path)) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block for_statement tuple_pattern identifier identifier identifier call attribute identifier identifier argument_list identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement yield call identifier argument_list identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier | Move the files to a remote compute |
def filter(self, sids):
dic = self.__class__(self.shape_y, self.shape_z)
for sid in sids:
try:
dic[sid] = self[sid]
except KeyError:
pass
return dic | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier for_statement identifier identifier block try_statement block expression_statement assignment subscript identifier identifier subscript identifier identifier except_clause identifier block pass_statement return_statement identifier | Extracs a submap of self for the given sids. |
def execution_environment():
context = {}
context['conf'] = config()
if relation_id():
context['reltype'] = relation_type()
context['relid'] = relation_id()
context['rel'] = relation_get()
context['unit'] = local_unit()
context['rels'] = relations()
context['env'] = os.environ
return context | module function_definition identifier parameters block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list if_statement call identifier argument_list block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement identifier | A convenient bundling of the current execution context |
def iter_fit_shifts(xy,uv,nclip=3,sigma=3.0):
fit = fit_shifts(xy,uv)
if nclip is None: nclip = 0
for n in range(nclip):
resids = compute_resids(xy,uv,fit)
resids1d = np.sqrt(np.power(resids[:,0],2)+np.power(resids[:,1],2))
sig = resids1d.std()
goodpix = resids1d < sigma*sig
xy = xy[goodpix]
uv = uv[goodpix]
fit = fit_shifts(xy,uv)
fit['img_coords'] = xy
fit['ref_coords'] = uv
return fit | module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier float block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier integer for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list subscript identifier slice integer integer call attribute identifier identifier argument_list subscript identifier slice integer integer expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier comparison_operator identifier binary_operator identifier identifier expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier | Perform an iterative-fit with 'nclip' iterations |
def cleanup(self):
if self.sock is not None:
self.sock.close()
if self.outfile is not None:
self.outfile.close()
if self.bar is not None:
self.update_progress(complete=True) | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list keyword_argument identifier true | Release resources used during memory capture |
def push(self, channel_id, data):
channel_path = self.channel_path(channel_id)
response = requests.post(channel_path, data)
return response.json() | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list | Push message with POST ``data`` for ``channel_id`` |
def piper(self, in_sock, out_sock, out_addr, onkill):
"Worker thread for data reading"
try:
while True:
written = in_sock.recv(32768)
if not written:
try:
out_sock.shutdown(socket.SHUT_WR)
except socket.error:
self.threads[onkill].kill()
break
try:
out_sock.sendall(written)
except socket.error:
pass
self.data_handled += len(written)
except greenlet.GreenletExit:
return | module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement string string_start string_content string_end try_statement block while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list integer if_statement not_operator identifier block try_statement block expression_statement call attribute identifier identifier argument_list attribute identifier identifier except_clause attribute identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list break_statement try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause attribute identifier identifier block pass_statement expression_statement augmented_assignment attribute identifier identifier call identifier argument_list identifier except_clause attribute identifier identifier block return_statement | Worker thread for data reading |
def ReadHashBlobReferences(self, hashes, cursor):
query = ("SELECT hash_id, blob_references FROM hash_blob_references WHERE "
"hash_id IN {}").format(mysql_utils.Placeholders(len(hashes)))
cursor.execute(query, [hash_id.AsBytes() for hash_id in hashes])
results = {hash_id: None for hash_id in hashes}
for hash_id, blob_references in cursor.fetchall():
sha_hash_id = rdf_objects.SHA256HashID.FromBytes(hash_id)
refs = rdf_objects.BlobReferences.FromSerializedString(blob_references)
results[sha_hash_id] = list(refs.items)
return results | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier identifier expression_statement assignment identifier dictionary_comprehension pair identifier none for_in_clause identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier call identifier argument_list attribute identifier identifier return_statement identifier | Reads blob references of a given set of hashes. |
def format(self, method, data):
if data is None:
if method == 'GET':
raise NotFound()
return ''
return self._meta.formatter.format(data) | module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier none block if_statement comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list return_statement string string_start string_end return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier | Calls format on list or detail |
def follow_fd(fd):
dump = Dump()
for line in fd:
if not line.strip():
continue
with flushing(sys.stdout, sys.stderr):
status = load(line)
if status:
dump(status) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement not_operator call attribute identifier identifier argument_list block continue_statement with_statement with_clause with_item call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement call identifier argument_list identifier | Dump each line of input to stdio. |
def _str_to_datetime(self, str_value):
try:
ldt = [int(f) for f in str_value.split('-')]
dt = datetime.datetime(*ldt)
except (ValueError, TypeError):
return None
return dt | module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list list_splat identifier except_clause tuple identifier identifier block return_statement none return_statement identifier | Parses a `YYYY-MM-DD` string into a datetime object. |
def delete_cloud_obj(self, cloud_obj):
self._connection.delete_object(
container=self.container_name,
obj=cloud_obj,
) | module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier | Deletes an object from the container. |
def example_rgb_to_xyz():
print("=== RGB Example: RGB->XYZ ===")
rgb = sRGBColor(120, 130, 140)
print(rgb)
xyz = convert_color(rgb, XYZColor, target_illuminant='D50')
print(xyz)
print("=== End Example ===\n") | module function_definition identifier parameters block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list integer integer integer expression_statement call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content escape_sequence string_end | The reverse is similar. |
def _prepare_graph_terms(self, default_screen):
columns = self.columns.copy()
screen = self.screen
if screen is None:
screen = default_screen
columns[SCREEN_NAME] = screen
return columns | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier | Helper for to_graph and to_execution_plan. |
def copy_figure(self):
if self.fmt in ['image/png', 'image/jpeg']:
qpixmap = QPixmap()
qpixmap.loadFromData(self.fig, self.fmt.upper())
QApplication.clipboard().setImage(qpixmap.toImage())
elif self.fmt == 'image/svg+xml':
svg_to_clipboard(self.fig)
else:
return
self.blink_figure() | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list call attribute identifier identifier argument_list elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call identifier argument_list attribute identifier identifier else_clause block return_statement expression_statement call attribute identifier identifier argument_list | Copy figure to clipboard. |
def create(self, repo_name, scm='git', private=True, **kwargs):
url = self.bitbucket.url('CREATE_REPO')
return self.bitbucket.dispatch('POST', url, auth=self.bitbucket.auth, name=repo_name, scm=scm, is_private=private, **kwargs) | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier true dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier dictionary_splat identifier | Creates a new repository on own Bitbucket account and return it. |
def _set_package_directory():
package_directory = os.path.normpath(os.path.join(os.path.dirname(__file__), "../"))
package_directory not in sys.path and sys.path.append(package_directory) | module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement boolean_operator comparison_operator identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier | Sets the Application package directory in the path. |
def unhexlify(blob):
lines = blob.split('\n')[1:]
output = []
for line in lines:
output.append(binascii.unhexlify(line[9:-2]))
if (output[0][0:2].decode('utf-8') != u'MP'):
return ''
output[0] = output[0][4:]
output[-1] = output[-1].strip(b'\x00')
script = b''.join(output)
try:
result = script.decode('utf-8')
return result
except UnicodeDecodeError:
return '' | module function_definition identifier parameters identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end slice integer expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list subscript identifier slice integer unary_operator integer if_statement parenthesized_expression comparison_operator call attribute subscript subscript identifier integer slice integer integer identifier argument_list string string_start string_content string_end string string_start string_content string_end block return_statement string string_start string_end expression_statement assignment subscript identifier integer subscript subscript identifier integer slice integer expression_statement assignment subscript identifier unary_operator integer call attribute subscript identifier unary_operator integer identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment identifier call attribute string string_start string_end identifier argument_list identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier except_clause identifier block return_statement string string_start string_end | Takes a hexlified script and turns it back into a string of Python code. |
def _grid_widgets(self):
self._canvas.grid(sticky="nswe")
self.header_label.grid(row=1, column=1, sticky="nswe", pady=5, padx=5)
self.text_label.grid(row=3, column=1, sticky="nswe", pady=6, padx=5) | module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier integer | Place the widgets in the Toplevel. |
def init_celery(project_name):
os.environ.setdefault('DJANGO_SETTINGS_MODULE', '%s.settings' % project_name)
app = Celery(project_name)
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(settings.INSTALLED_APPS, related_name='tasks')
return app | module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier string string_start string_content string_end return_statement identifier | init celery app without the need of redundant code |
def ConvertFromWireFormat(self, value, container=None):
result = self.type()
ReadIntoObject(value[2], 0, result)
return result | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list subscript identifier integer integer identifier return_statement identifier | The wire format is simply a string. |
def indent(txt, spacing=4):
return prefix(str(txt), ''.join([' ' for _ in range(spacing)])) | module function_definition identifier parameters identifier default_parameter identifier integer block return_statement call identifier argument_list call identifier argument_list identifier call attribute string string_start string_end identifier argument_list list_comprehension string string_start string_content string_end for_in_clause identifier call identifier argument_list identifier | Indent given text using custom spacing, default is set to 4. |
def hex2bin(hexstr):
num_of_bits = len(hexstr) * 4
binstr = bin(int(hexstr, 16))[2:].zfill(int(num_of_bits))
return binstr | module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator call identifier argument_list identifier integer expression_statement assignment identifier call attribute subscript call identifier argument_list call identifier argument_list identifier integer slice integer identifier argument_list call identifier argument_list identifier return_statement identifier | Convert a hexdecimal string to binary string, with zero fillings. |
def tco_return_handle(tokens):
internal_assert(len(tokens) == 2, "invalid tail-call-optimizable return statement tokens", tokens)
if tokens[1].startswith("()"):
return "return _coconut_tail_call(" + tokens[0] + ")" + tokens[1][2:]
else:
return "return _coconut_tail_call(" + tokens[0] + ", " + tokens[1][1:] | module function_definition identifier parameters identifier block expression_statement call identifier argument_list comparison_operator call identifier argument_list identifier integer string string_start string_content string_end identifier if_statement call attribute subscript identifier integer identifier argument_list string string_start string_content string_end block return_statement binary_operator binary_operator binary_operator string string_start string_content string_end subscript identifier integer string string_start string_content string_end subscript subscript identifier integer slice integer else_clause block return_statement binary_operator binary_operator binary_operator string string_start string_content string_end subscript identifier integer string string_start string_content string_end subscript subscript identifier integer slice integer | Process tail-call-optimizable return statements. |
def build_base_parameters(request):
getParameters = {}
postParameters = {}
files = {}
for v in request.GET:
if v[:6] != 'ebuio_':
val = request.GET.getlist(v)
if len(val) == 1:
getParameters[v] = val[0]
else:
getParameters[v] = val
if request.method == 'POST':
for v in request.POST:
if v[:6] != 'ebuio_':
val = request.POST.getlist(v)
if len(val) == 1:
postParameters[v] = val[0]
else:
postParameters[v] = val
for v in request.FILES:
if v[:6] != 'ebuio_':
files[v] = request.FILES[v]
return (getParameters, postParameters, files) | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block if_statement comparison_operator subscript identifier slice integer string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment subscript identifier identifier subscript identifier integer else_clause block expression_statement assignment subscript identifier identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block for_statement identifier attribute identifier identifier block if_statement comparison_operator subscript identifier slice integer string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment subscript identifier identifier subscript identifier integer else_clause block expression_statement assignment subscript identifier identifier identifier for_statement identifier attribute identifier identifier block if_statement comparison_operator subscript identifier slice integer string string_start string_content string_end block expression_statement assignment subscript identifier identifier subscript attribute identifier identifier identifier return_statement tuple identifier identifier identifier | Build the list of parameters to forward from the post and get parameters |
def list_devices(self, project_id, conditions=None, params=None):
default_params = {'per_page': 1000}
if params:
default_params.update(params)
data = self.api('projects/%s/devices' % project_id, params=default_params)
devices = []
for device in self.filter(conditions, data['devices']):
devices.append(packet.Device(device, self.manager))
return devices | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier dictionary pair string string_start string_content string_end integer if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier keyword_argument identifier identifier expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier attribute identifier identifier return_statement identifier | Retrieve list of devices in a project by one of more conditions. |
def connected(self, node_id):
conn = self._conns.get(node_id)
if conn is None:
return False
return conn.connected() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement false return_statement call attribute identifier identifier argument_list | Return True iff the node_id is connected. |
def csv2yaml(in_file, out_file=None):
if out_file is None:
out_file = "%s.yaml" % os.path.splitext(in_file)[0]
barcode_ids = _generate_barcode_ids(_read_input_csv(in_file))
lanes = _organize_lanes(_read_input_csv(in_file), barcode_ids)
with open(out_file, "w") as out_handle:
out_handle.write(yaml.safe_dump(lanes, default_flow_style=False))
return out_file | module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end subscript call attribute attribute identifier identifier identifier argument_list identifier integer expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier false return_statement identifier | Convert a CSV SampleSheet to YAML run_info format. |
def _get_persist_command(self):
for command in [_SETSID_COMMAND, _NOHUP_COMMAND]:
try:
if command in self._adb.shell(['which',
command]).decode('utf-8'):
return command
except adb.AdbError:
continue
self.log.warning(
'No %s and %s commands available to launch instrument '
'persistently, tests that depend on UiAutomator and '
'at the same time performs USB disconnection may fail',
_SETSID_COMMAND, _NOHUP_COMMAND)
return '' | module function_definition identifier parameters identifier block for_statement identifier list identifier identifier block try_statement block if_statement comparison_operator identifier call attribute call attribute attribute identifier identifier identifier argument_list list string string_start string_content string_end identifier identifier argument_list string string_start string_content string_end block return_statement identifier except_clause attribute identifier identifier block continue_statement expression_statement call attribute attribute identifier identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier identifier return_statement string string_start string_end | Check availability and return path of command if available. |
def peer_ips(peer_relation='cluster', addr_key='private-address'):
peers = {}
for r_id in relation_ids(peer_relation):
for unit in relation_list(r_id):
peers[unit] = relation_get(addr_key, rid=r_id, unit=unit)
return peers | module function_definition identifier parameters default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier dictionary for_statement identifier call identifier argument_list identifier block for_statement identifier call identifier argument_list identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier | Return a dict of peers and their private-address |
def update(self, data):
if data is None:
return
for key, value in sorted(data.items()):
if key.startswith('/'):
name = key.lstrip('/')
match = re.search("([^/]+)(/.*)", name)
if match:
name = match.groups()[0]
value = {match.groups()[1]: value}
self.child(name, value)
else:
self.data[key] = value
log.debug("Data for '{0}' updated.".format(self))
log.data(pretty(self.data)) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block return_statement for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block 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 string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer expression_statement assignment identifier dictionary pair subscript call attribute identifier identifier argument_list integer identifier expression_statement call attribute identifier identifier argument_list identifier identifier else_clause block expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier | Update metadata, handle virtual hierarchy |
def add_scanner_param(self, name, scanner_param):
assert name
assert scanner_param
self.scanner_params[name] = scanner_param
command = self.commands.get('start_scan')
command['elements'] = {
'scanner_params':
{k: v['name'] for k, v in self.scanner_params.items()}} | module function_definition identifier parameters identifier identifier identifier block assert_statement identifier assert_statement identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary_comprehension pair identifier subscript identifier string string_start string_content string_end for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list | Add a scanner parameter. |
def zone_schedules_backup(self, filename):
_LOGGER.info("Backing up schedules from ControlSystem: %s (%s)...",
self.systemId, self.location.name)
schedules = {}
if self.hotwater:
_LOGGER.info("Retrieving DHW schedule: %s...",
self.hotwater.zoneId)
schedule = self.hotwater.schedule()
schedules[self.hotwater.zoneId] = {
'name': 'Domestic Hot Water',
'schedule': schedule}
for zone in self._zones:
zone_id = zone.zoneId
name = zone.name
_LOGGER.info("Retrieving Zone schedule: %s - %s", zone_id, name)
schedule = zone.schedule()
schedules[zone_id] = {'name': name, 'schedule': schedule}
schedule_db = json.dumps(schedules, indent=4)
_LOGGER.info("Writing to backup file: %s...", filename)
with open(filename, 'w') as file_output:
file_output.write(schedule_db)
_LOGGER.info("Backup completed.") | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute attribute identifier identifier identifier expression_statement assignment identifier dictionary if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier attribute attribute identifier identifier identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute 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 identifier identifier argument_list expression_statement assignment subscript identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | Backup all zones on control system to the given file. |
def set(self, key, value):
key = "{0}{1}".format(self.prefix, key)
value = json.dumps(value, cls=NumpyEncoder)
self.redis.set(key, value) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier | Set a key, value pair. |
def ToolMatches(tools=None, version='HEAD'):
matches = []
if tools:
for tool in tools:
match_version = version
if tool[1] != '':
match_version = tool[1]
match = ''
if tool[0].endswith('/'):
match = tool[0][:-1]
elif tool[0] != '.':
match = tool[0]
if not match.startswith('/') and match != '':
match = '/'+match
matches.append((match, match_version))
return matches | module function_definition identifier parameters default_parameter identifier none default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier list if_statement identifier block for_statement identifier identifier block expression_statement assignment identifier identifier if_statement comparison_operator subscript identifier integer string string_start string_end block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier string string_start string_end if_statement call attribute subscript identifier integer identifier argument_list string string_start string_content string_end block expression_statement assignment identifier subscript subscript identifier integer slice unary_operator integer elif_clause comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment identifier subscript identifier integer if_statement boolean_operator not_operator call attribute identifier identifier argument_list string string_start string_content string_end comparison_operator identifier string string_start string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list tuple identifier identifier return_statement identifier | Get the tools paths and versions that were specified |
def abstracts(soup):
abstracts = []
abstract_tags = raw_parser.abstract(soup)
for tag in abstract_tags:
abstract = {}
abstract["abstract_type"] = tag.get("abstract-type")
title_tag = raw_parser.title(tag)
if title_tag:
abstract["title"] = node_text(title_tag)
abstract["content"] = None
if raw_parser.paragraph(tag):
abstract["content"] = ""
abstract["full_content"] = ""
good_paragraphs = remove_doi_paragraph(raw_parser.paragraph(tag))
glue = ""
for p_tag in good_paragraphs:
abstract["content"] += glue + node_text(p_tag)
glue = " "
for p_tag in good_paragraphs:
abstract["full_content"] += '<p>' + node_contents_str(p_tag) + '</p>'
abstracts.append(abstract)
return abstracts | module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end none if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_end expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_end for_statement identifier identifier block expression_statement augmented_assignment subscript identifier string string_start string_content string_end binary_operator identifier call identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end for_statement identifier identifier block expression_statement augmented_assignment subscript identifier string string_start string_content string_end binary_operator binary_operator string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Find the article abstract and format it |
def parse_csv_response(data, unit_handler):
return squish([parse_csv_dataset(d, unit_handler) for d in data.split(b'\n\n')]) | module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list list_comprehension call identifier argument_list identifier identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end | Handle CSV-formatted HTTP responses. |
def create_content(self, cli, width, height):
complete_state = cli.current_buffer.complete_state
if complete_state:
completions = complete_state.current_completions
index = complete_state.complete_index
menu_width = self._get_menu_width(width, complete_state)
menu_meta_width = self._get_menu_meta_width(width - menu_width, complete_state)
show_meta = self._show_meta(complete_state)
def get_line(i):
c = completions[i]
is_current_completion = (i == index)
result = self._get_menu_item_tokens(c, is_current_completion, menu_width)
if show_meta:
result += self._get_menu_item_meta_tokens(c, is_current_completion, menu_meta_width)
return result
return UIContent(get_line=get_line,
cursor_position=Point(x=0, y=index or 0),
line_count=len(completions),
default_char=Char(' ', self.token))
return UIContent() | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier parenthesized_expression comparison_operator identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier if_statement identifier block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier identifier identifier return_statement identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier call identifier argument_list keyword_argument identifier integer keyword_argument identifier boolean_operator identifier integer keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list | Create a UIContent object for this control. |
def remove_update_callback(self, group, name=None, cb=None):
if not cb:
return
if not name:
if group in self.group_update_callbacks:
self.group_update_callbacks[group].remove_callback(cb)
else:
paramname = '{}.{}'.format(group, name)
if paramname in self.param_update_callbacks:
self.param_update_callbacks[paramname].remove_callback(cb) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block if_statement not_operator identifier block return_statement if_statement not_operator identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier | Remove the supplied callback for a group or a group.name |
def update(self, pointvol):
if self.use_kdtree:
kdtree = spatial.KDTree(self.live_u)
else:
kdtree = None
if self.use_pool_update:
pool = self.pool
else:
pool = None
self.radfriends.update(self.live_u, pointvol=pointvol,
rstate=self.rstate, bootstrap=self.bootstrap,
pool=pool, kdtree=kdtree)
if self.enlarge != 1.:
self.radfriends.scale_to_vol(self.radfriends.vol_ball *
self.enlarge)
return copy.deepcopy(self.radfriends) | module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier none if_statement attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier none expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement comparison_operator attribute identifier identifier float block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator attribute attribute identifier identifier identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier | Update the N-sphere radii using the current set of live points. |
def service_list():
r = salt.utils.http.query(DETAILS['url']+'service/list', decode_type='json', decode=True)
return r['dict'] | module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list binary_operator subscript identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier true return_statement subscript identifier string string_start string_content string_end | List "services" on the REST server |
def _c_base_var(self):
if self.opts.no_structs:
return self.name
return 'windll->{}.{}'.format(
self.name, self.opts.base
) | module function_definition identifier parameters identifier block if_statement attribute attribute identifier identifier identifier block return_statement attribute identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier | Return the name of the module base variable. |
def increase_weight(self, proxy):
new_weight = proxy.weight * self.inc_ratio
if new_weight < 1.0:
proxy.weight = new_weight
else:
proxy.weight = 1.0 | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier if_statement comparison_operator identifier float block expression_statement assignment attribute identifier identifier identifier else_clause block expression_statement assignment attribute identifier identifier float | Increase the weight of a proxy by multiplying inc_ratio |
def instruction_LSR_register(self, opcode, register):
a = register.value
r = self.LSR(a)
register.set(r) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier | Logical shift right accumulator |
def from_int(value):
if not isinstance(value, int):
raise PyVLXException("value_has_to_be_int")
if not Parameter.is_valid_int(value):
raise PyVLXException("value_out_of_range")
return bytes([value >> 8 & 255, value & 255]) | module function_definition identifier parameters 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 if_statement not_operator call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list list binary_operator binary_operator identifier integer integer binary_operator identifier integer | Create raw out of position vlaue. |
def removeZeroLenPadding(str, blocksize=AES_blocksize):
'Remove Padding with zeroes + last byte equal to the number of padding bytes'
try:
pad_len = ord(str[-1])
except TypeError:
pad_len = str[-1]
assert pad_len < blocksize, 'padding error'
assert pad_len < len(str), 'padding error'
return str[:-pad_len] | module function_definition identifier parameters identifier default_parameter identifier identifier block expression_statement string string_start string_content string_end try_statement block expression_statement assignment identifier call identifier argument_list subscript identifier unary_operator integer except_clause identifier block expression_statement assignment identifier subscript identifier unary_operator integer assert_statement comparison_operator identifier identifier string string_start string_content string_end assert_statement comparison_operator identifier call identifier argument_list identifier string string_start string_content string_end return_statement subscript identifier slice unary_operator identifier | Remove Padding with zeroes + last byte equal to the number of padding bytes |
def load_ssl_context(cert_file, pkey_file):
from OpenSSL import SSL
ctx = SSL.Context(SSL.SSLv23_METHOD)
ctx.use_certificate_file(cert_file)
ctx.use_privatekey_file(pkey_file)
return ctx | module function_definition identifier parameters identifier identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Loads an SSL context from a certificate and private key file. |
def execute_transaction(conn, statements: Iterable):
with conn:
with conn.cursor() as cursor:
for statement in statements:
cursor.execute(statement)
conn.commit() | module function_definition identifier parameters identifier typed_parameter identifier type identifier block with_statement with_clause with_item identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list | Execute several statements in single DB transaction. |
def vt_ip_check(ip, vt_api):
if not is_IPv4Address(ip):
return None
url = 'https://www.virustotal.com/vtapi/v2/ip-address/report'
parameters = {'ip': ip, 'apikey': vt_api}
response = requests.get(url, params=parameters)
try:
return response.json()
except ValueError:
return None | module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier block return_statement none expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier try_statement block return_statement call attribute identifier identifier argument_list except_clause identifier block return_statement none | Checks VirusTotal for occurrences of an IP address |
def do_rm(self, path):
path = path[0]
self.n.delete(self.current_path + path)
self.dirs = self.dir_complete()
self.files = self.file_complete() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list | delete a file or directory |
def modeldeclarations(self):
lines = Lines()
lines.add(0, '@cython.final')
lines.add(0, 'cdef class Model(object):')
lines.add(1, 'cdef public int idx_sim')
lines.add(1, 'cdef public Parameters parameters')
lines.add(1, 'cdef public Sequences sequences')
if hasattr(self.model, 'numconsts'):
lines.add(1, 'cdef public NumConsts numconsts')
if hasattr(self.model, 'numvars'):
lines.add(1, 'cdef public NumVars numvars')
return lines | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer string string_start string_content string_end if_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list integer string string_start string_content string_end if_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list integer string string_start string_content string_end return_statement identifier | Attribute declarations of the model class. |
def _generate_relative_positions_matrix(length_q, length_k,
max_relative_position,
cache=False):
if not cache:
if length_q == length_k:
range_vec_q = range_vec_k = tf.range(length_q)
else:
range_vec_k = tf.range(length_k)
range_vec_q = range_vec_k[-length_q:]
distance_mat = range_vec_k[None, :] - range_vec_q[:, None]
else:
distance_mat = tf.expand_dims(tf.range(-length_k+1, 1, 1), 0)
distance_mat_clipped = tf.clip_by_value(distance_mat, -max_relative_position,
max_relative_position)
final_mat = distance_mat_clipped + max_relative_position
return final_mat | module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block if_statement not_operator identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier slice unary_operator identifier expression_statement assignment identifier binary_operator subscript identifier none slice subscript identifier slice none else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list binary_operator unary_operator identifier integer integer integer integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier unary_operator identifier identifier expression_statement assignment identifier binary_operator identifier identifier return_statement identifier | Generates matrix of relative positions between inputs. |
def digraph_walker_backwards(graph, element, call_back):
call_back(graph, element)
for predecessor in graph.predecessors(element):
call_back(graph, predecessor)
for predecessor in graph.predecessors(element):
digraph_walker_backwards(graph, predecessor, call_back) | module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list identifier identifier for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement call identifier argument_list identifier identifier for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement call identifier argument_list identifier identifier identifier | Visits every element guaranteeing that the previous elements have been visited before |
def package_assets(example_path):
examples(example_path, force=True, root=__file__)
for root, dirs, files in os.walk(example_path):
walker(root, dirs+files)
setup_args['packages'] += packages
for p, exts in extensions.items():
if exts:
setup_args['package_data'][p] = exts | module function_definition identifier parameters identifier block expression_statement call identifier argument_list identifier keyword_argument identifier true keyword_argument identifier identifier for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier block expression_statement call identifier argument_list identifier binary_operator identifier identifier expression_statement augmented_assignment subscript identifier string string_start string_content string_end identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement identifier block expression_statement assignment subscript subscript identifier string string_start string_content string_end identifier identifier | Generates pseudo-packages for the examples directory. |
def normalized_messages(self, no_field_name='_entity'):
if isinstance(self.messages, dict):
return self.messages
if not self.field_names:
return {no_field_name: self.messages}
return dict((name, self.messages) for name in self.field_names) | module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block if_statement call identifier argument_list attribute identifier identifier identifier block return_statement attribute identifier identifier if_statement not_operator attribute identifier identifier block return_statement dictionary pair identifier attribute identifier identifier return_statement call identifier generator_expression tuple identifier attribute identifier identifier for_in_clause identifier attribute identifier identifier | Return all the error messages as a dictionary |
def pawns_at(self, x, y):
for pawn in self.pawn.values():
if pawn.collide_point(x, y):
yield pawn | module function_definition identifier parameters identifier identifier identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement call attribute identifier identifier argument_list identifier identifier block expression_statement yield identifier | Iterate over pawns that collide the given point. |
def showBindingsForActionSet(self, unSizeOfVRSelectedActionSet_t, unSetCount, originToHighlight):
fn = self.function_table.showBindingsForActionSet
pSets = VRActiveActionSet_t()
result = fn(byref(pSets), unSizeOfVRSelectedActionSet_t, unSetCount, originToHighlight)
return result, pSets | module function_definition identifier parameters identifier identifier 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 call identifier argument_list identifier identifier identifier identifier return_statement expression_list identifier identifier | Shows the current binding all the actions in the specified action sets |
def connect(self, region):
if self.eucalyptus:
conn = boto.connect_euca(host=self.eucalyptus_host)
conn.APIVersion = '2010-08-31'
else:
conn = self.connect_to_aws(ec2, region)
return conn | module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier | create connection to api server |
def show(self, ax:plt.Axes=None, figsize:tuple=(3,3), title:Optional[str]=None, hide_axis:bool=True, **kwargs):
"Show the `ImagePoints` on `ax`."
if ax is None: _,ax = plt.subplots(figsize=figsize)
pnt = scale_flow(FlowField(self.size, self.data), to_unit=False).flow.flip(1)
params = {'s': 10, 'marker': '.', 'c': 'r', **kwargs}
ax.scatter(pnt[:, 0], pnt[:, 1], **params)
if hide_axis: ax.axis('off')
if title: ax.set_title(title) | module function_definition identifier parameters identifier typed_default_parameter identifier type attribute identifier identifier none typed_default_parameter identifier type identifier tuple integer integer typed_default_parameter identifier type generic_type identifier type_parameter type identifier none typed_default_parameter identifier type identifier true dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute attribute call identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier false identifier identifier argument_list integer expression_statement assignment identifier dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end dictionary_splat identifier expression_statement call attribute identifier identifier argument_list subscript identifier slice integer subscript identifier slice integer dictionary_splat identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier | Show the `ImagePoints` on `ax`. |
def create(cls, user, **kwargs):
parent_id = kwargs.get(cls.parent_resource.resource_type + '_id')
try:
parent = yield cls.parent_resource.get(parent_id)
except couch.NotFound:
msg = 'Parent {} with id {} not found'.format(
cls.parent_resource.resource_type,
parent_id)
raise exceptions.ValidationError(msg)
if not parent.editable:
err = 'Cannot create child of {} resource'.format(parent.state.name)
raise exceptions.Unauthorized(err)
resource = yield super(SubResource, cls).create(user, **kwargs)
resource._parent = parent
raise Return(resource) | module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator attribute attribute identifier identifier identifier string string_start string_content string_end try_statement block expression_statement assignment identifier yield call attribute attribute identifier identifier identifier argument_list identifier except_clause attribute identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier identifier raise_statement call attribute identifier identifier argument_list identifier if_statement not_operator attribute identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier raise_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier yield call attribute call identifier argument_list identifier identifier identifier argument_list identifier dictionary_splat identifier expression_statement assignment attribute identifier identifier identifier raise_statement call identifier argument_list identifier | If parent resource is not an editable state, should not be able to create. |
def mix_wave(src, dst):
if len(src) > len(dst):
dst, src = src, dst
for i, sv in enumerate(src):
dv = dst[i]
if sv < 128 and dv < 128:
dst[i] = int(sv * dv / 128)
else:
dst[i] = int(2 * (sv + dv) - sv * dv / 128 - 256)
return dst | module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier expression_list identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier subscript identifier identifier if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier integer block expression_statement assignment subscript identifier identifier call identifier argument_list binary_operator binary_operator identifier identifier integer else_clause block expression_statement assignment subscript identifier identifier call identifier argument_list binary_operator binary_operator binary_operator integer parenthesized_expression binary_operator identifier identifier binary_operator binary_operator identifier identifier integer integer return_statement identifier | Mix two wave body into one. |
def _compile_and_collapse(self):
self._real_regex = self._real_re_compile(*self._regex_args,
**self._regex_kwargs)
for attr in self._regex_attributes_to_copy:
setattr(self, attr, getattr(self._real_regex, attr)) | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list list_splat attribute identifier identifier dictionary_splat attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list identifier identifier call identifier argument_list attribute identifier identifier identifier | Actually compile the requested regex |
def to_internal_value(self, data):
if not data:
return None
request = self._get_request()
user = request.user
try:
obj = core_utils.instance_from_url(data, user=user)
model = obj.__class__
except ValueError:
raise serializers.ValidationError(_('URL is invalid: %s.') % data)
except (Resolver404, AttributeError, MultipleObjectsReturned, ObjectDoesNotExist):
raise serializers.ValidationError(_("Can't restore object from url: %s") % data)
if model not in self.related_models:
raise serializers.ValidationError(_('%s object does not support such relationship.') % six.text_type(obj))
return obj | module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement none expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier attribute identifier identifier except_clause identifier block raise_statement call attribute identifier identifier argument_list binary_operator call identifier argument_list string string_start string_content string_end identifier except_clause tuple identifier identifier identifier identifier block raise_statement call attribute identifier identifier argument_list binary_operator call identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier attribute identifier identifier block raise_statement call attribute identifier identifier argument_list binary_operator call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier return_statement identifier | Restores model instance from its url |
def secured_apps_copy(self, apps):
return [[app_name, path] for app_name, path in apps if
app_name not in (self.LETSENCRYPT_VERIFY_APP_NAME,)] | module function_definition identifier parameters identifier identifier block return_statement list_comprehension list identifier identifier for_in_clause pattern_list identifier identifier identifier if_clause comparison_operator identifier tuple attribute identifier identifier | Given the http app list of a website, return what should be in the secure version |
def any_text_to_fernet_key(self, text):
md5 = fingerprint.fingerprint.of_text(text)
fernet_key = base64.b64encode(md5.encode("utf-8"))
return fernet_key | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier | Convert any text to a fernet key for encryption. |
def main_view(request, ident, stateless=False, cache_id=None, **kwargs):
'Main view for a dash app'
_, app = DashApp.locate_item(ident, stateless, cache_id=cache_id)
view_func = app.locate_endpoint_function()
resp = view_func()
return HttpResponse(resp) | module function_definition identifier parameters identifier identifier default_parameter identifier false default_parameter identifier none dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list return_statement call identifier argument_list identifier | Main view for a dash app |
def _get_file_list(load):
if 'env' in load:
load.pop('env')
if 'saltenv' not in load or load['saltenv'] not in envs():
return []
ret = set()
for repo in init():
repo['repo'].open()
ref = _get_ref(repo, load['saltenv'])
if ref:
manifest = repo['repo'].manifest(rev=ref[1])
for tup in manifest:
relpath = os.path.relpath(tup[4], repo['root'])
if not relpath.startswith('../'):
ret.add(os.path.join(repo['mountpoint'], relpath))
repo['repo'].close()
return sorted(ret) | module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end call identifier argument_list block return_statement list expression_statement assignment identifier call identifier argument_list for_statement identifier call identifier argument_list block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call identifier argument_list identifier subscript identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list keyword_argument identifier subscript identifier integer for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier integer subscript identifier string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end identifier expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list return_statement call identifier argument_list identifier | Get a list of all files on the file server in a specified environment |
def _dirdiffandupdate(self, dir1, dir2):
self._dowork(dir1, dir2, None, self._update) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier none attribute identifier identifier | Private function which does directory diff & update |
def _get_session(region, key, keyid, profile):
if profile:
if isinstance(profile, six.string_types):
_profile = __salt__['config.option'](profile)
elif isinstance(profile, dict):
_profile = profile
key = _profile.get('key', None)
keyid = _profile.get('keyid', None)
region = _profile.get('region', None)
if not region and __salt__['config.option']('datapipeline.region'):
region = __salt__['config.option']('datapipeline.region')
if not region:
region = 'us-east-1'
return boto3.session.Session(
region_name=region,
aws_secret_access_key=key,
aws_access_key_id=keyid,
) | module function_definition identifier parameters identifier identifier identifier identifier block if_statement identifier block if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none if_statement boolean_operator not_operator identifier call subscript identifier string string_start string_content string_end argument_list string string_start string_content string_end block expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list string string_start string_content string_end if_statement not_operator identifier block expression_statement assignment identifier string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | Get a boto3 session |
def _CollectSignedData(self, extent):
start, length = extent
self.file.seek(start, os.SEEK_SET)
buf = self.file.read(length)
signed_data = []
while len(buf) >= 8:
dw_length, w_revision, w_cert_type = struct.unpack('<IHH', buf[:8])
if dw_length < 8:
return signed_data
b_cert = buf[8:dw_length]
buf = buf[(dw_length + 7) & 0x7ffffff8:]
signed_data.append((w_revision, w_cert_type, b_cert))
return signed_data | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier list while_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier slice integer if_statement comparison_operator identifier integer block return_statement identifier expression_statement assignment identifier subscript identifier slice integer identifier expression_statement assignment identifier subscript identifier slice binary_operator parenthesized_expression binary_operator identifier integer integer expression_statement call attribute identifier identifier argument_list tuple identifier identifier identifier return_statement identifier | Extracts signedData blob from PECOFF binary and parses first layer. |
def make_vel(self):
"Make a set of velocities to be randomly chosen for emitted particles"
self.vel = random.normal(self.vel_mu, self.vel_sigma, 16)
for i, vel in enumerate(self.vel):
if abs(vel) < 0.125 / self._size:
if vel < 0:
self.vel[i] = -0.125 / self._size
else:
self.vel[i] = 0.125 / self._size | module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier integer for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block if_statement comparison_operator call identifier argument_list identifier binary_operator float attribute identifier identifier block if_statement comparison_operator identifier integer block expression_statement assignment subscript attribute identifier identifier identifier binary_operator unary_operator float attribute identifier identifier else_clause block expression_statement assignment subscript attribute identifier identifier identifier binary_operator float attribute identifier identifier | Make a set of velocities to be randomly chosen for emitted particles |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.