code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def _add_auth(self):
if not self.auth:
return
if self.auth and not self.definition_body:
raise InvalidResourceException(self.logical_id,
"Auth works only with inline Swagger specified in "
"'DefinitionBody' property")
if not all(key in AuthProperties._fields for key in self.auth.keys()):
raise InvalidResourceException(
self.logical_id, "Invalid value for 'Auth' property")
if not SwaggerEditor.is_valid(self.definition_body):
raise InvalidResourceException(self.logical_id, "Unable to add Auth configuration because "
"'DefinitionBody' does not contain a valid Swagger")
swagger_editor = SwaggerEditor(self.definition_body)
auth_properties = AuthProperties(**self.auth)
authorizers = self._get_authorizers(auth_properties.Authorizers, auth_properties.DefaultAuthorizer)
if authorizers:
swagger_editor.add_authorizers(authorizers)
self._set_default_authorizer(swagger_editor, authorizers, auth_properties.DefaultAuthorizer)
self.definition_body = swagger_editor.swagger
|
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement if_statement boolean_operator attribute identifier identifier not_operator attribute identifier identifier block raise_statement call identifier argument_list attribute identifier identifier concatenated_string string string_start string_content string_end string string_start string_content string_end if_statement not_operator call identifier generator_expression comparison_operator identifier attribute identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list block raise_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list attribute identifier identifier concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list dictionary_splat attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier
|
Add Auth configuration to the Swagger file, if necessary
|
def run(self):
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.setsockopt(zmq.LINGER, 100)
socket.bind('ipc://' + self.timer_sock)
count = 0
log.debug('ConCache-Timer started')
while not self.stopped.wait(1):
socket.send(self.serial.dumps(count))
count += 1
if count >= 60:
count = 0
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end while_statement not_operator call attribute attribute identifier identifier identifier argument_list integer block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier integer block expression_statement assignment identifier integer
|
main loop that fires the event every second
|
def load(file):
with open(file, 'r') as f:
contents = f.read()
lambder.load_events(contents)
|
module function_definition identifier parameters identifier block 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 assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier
|
Load events from a json file
|
def push_to_server(self, data):
output = add_profile(self.customer.pk, data, data)
output['response'].raise_if_error()
self.profile_id = output['profile_id']
self.payment_profile_ids = output['payment_profile_ids']
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier identifier identifier expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end
|
Create customer profile for given ``customer`` on Authorize.NET
|
def xml(self, value):
self._xml = value
self._root = s2t(value)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier
|
Set new XML string
|
def _process_json_resp_data(resp, no_custom_fields=False):
bridge_users = []
while True:
resp_data = json.loads(resp)
link_url = None
if "meta" in resp_data and\
"next" in resp_data["meta"]:
link_url = resp_data["meta"]["next"]
bridge_users = _process_apage(resp_data, bridge_users,
no_custom_fields)
if link_url is None:
break
resp = get_resource(link_url)
return bridge_users
|
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier list while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier none if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier identifier if_statement comparison_operator identifier none block break_statement expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
|
process the response and return a list of BridgeUser
|
def project_data_source_path(cls, project, data_source):
return google.api_core.path_template.expand(
"projects/{project}/dataSources/{data_source}",
project=project,
data_source=data_source,
)
|
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier
|
Return a fully-qualified project_data_source string.
|
def revision_number(self):
revision = self.revision
if revision is None:
return 0
revision_str = revision.text
try:
revision = int(revision_str)
except ValueError:
revision = 0
if revision < 0:
revision = 0
return revision
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block return_statement integer expression_statement assignment identifier attribute identifier identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block expression_statement assignment identifier integer if_statement comparison_operator identifier integer block expression_statement assignment identifier integer return_statement identifier
|
Integer value of revision property.
|
def _nodedev_event_update_cb(conn, dev, opaque):
_salt_send_event(opaque, conn, {
'nodedev': {
'name': dev.name()
},
'event': opaque['event']
})
|
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list identifier identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end subscript identifier string string_start string_content string_end
|
Node device update events handler
|
def name(self):
if self.chosen_name:
return self.chosen_name
else:
name = self.process.get_name()
if name:
return os.path.basename(name)
return ''
|
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement attribute identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement string string_start string_end
|
The name for the window as displayed in the title bar and status bar.
|
def listener(self):
channels = ['ql:w:' + self.client.worker_name]
listener = Listener(self.client.redis, channels)
thread = threading.Thread(target=self.listen, args=(listener,))
thread.start()
try:
yield
finally:
listener.unlisten()
thread.join()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier tuple identifier expression_statement call attribute identifier identifier argument_list try_statement block expression_statement yield finally_clause block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
|
Listen for pubsub messages relevant to this worker in a thread
|
def _findLocation(self, reference_name, start, end):
try:
return self._locationMap['hg19'][reference_name][start][end]
except:
return None
|
module function_definition identifier parameters identifier identifier identifier identifier block try_statement block return_statement subscript subscript subscript subscript attribute identifier identifier string string_start string_content string_end identifier identifier identifier except_clause block return_statement none
|
return a location key form the locationMap
|
def figure_buffer(figs):
assert len(figs) > 0, 'No figure buffers given. Forgot to return from draw call?'
buffers = []
w, h = figs[0].canvas.get_width_height()
for f in figs:
wf, hf = f.canvas.get_width_height()
assert wf == w and hf == h, 'All canvas objects need to have same size'
buffers.append(np.fromstring(f.canvas.tostring_rgb(), dtype=np.uint8).reshape(h, w, 3))
return np.stack(buffers)
|
module function_definition identifier parameters identifier block assert_statement comparison_operator call identifier argument_list identifier integer string string_start string_content string_end expression_statement assignment identifier list expression_statement assignment pattern_list identifier identifier call attribute attribute subscript identifier integer identifier identifier argument_list for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list assert_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier identifier argument_list identifier identifier integer return_statement call attribute identifier identifier argument_list identifier
|
Extract raw image buffer from matplotlib figure shaped as 1xHxWx3.
|
def stdout_display():
if sys.version_info[0] == 2:
yield SmartBuffer(sys.stdout)
else:
yield SmartBuffer(sys.stdout.buffer)
|
module function_definition identifier parameters block if_statement comparison_operator subscript attribute identifier identifier integer integer block expression_statement yield call identifier argument_list attribute identifier identifier else_clause block expression_statement yield call identifier argument_list attribute attribute identifier identifier identifier
|
Print results straight to stdout
|
def item(self):
url = self._contentURL
return Item(url=self._contentURL,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initalize=True)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true
|
returns the Item class of an Item
|
def run_has_samplesheet(fc_dir, config, require_single=True):
fc_name, _ = flowcell.parse_dirname(fc_dir)
sheet_dirs = config.get("samplesheet_directories", [])
fcid_sheet = {}
for ss_dir in (s for s in sheet_dirs if os.path.exists(s)):
with utils.chdir(ss_dir):
for ss in glob.glob("*.csv"):
fc_ids = _get_flowcell_id(ss, require_single)
for fcid in fc_ids:
if fcid:
fcid_sheet[fcid] = os.path.join(ss_dir, ss)
potential_fcids = difflib.get_close_matches(fc_name, fcid_sheet.keys(), 1, 0.85)
if len(potential_fcids) > 0 and potential_fcids[0] in fcid_sheet:
return fcid_sheet[potential_fcids[0]]
else:
return None
|
module function_definition identifier parameters identifier identifier default_parameter identifier true block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list expression_statement assignment identifier dictionary for_statement identifier generator_expression identifier for_in_clause identifier identifier if_clause call attribute attribute identifier identifier identifier argument_list identifier block with_statement with_clause with_item call attribute identifier identifier argument_list identifier block for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier identifier for_statement identifier identifier block if_statement identifier block expression_statement assignment subscript identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list integer float if_statement boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator subscript identifier integer identifier block return_statement subscript identifier subscript identifier integer else_clause block return_statement none
|
Checks if there's a suitable SampleSheet.csv present for the run
|
def read(self):
resp = self.sqs_client.receive_message(
QueueUrl=self.queue_url,
MaxNumberOfMessages=1,
AttributeNames=('SentTimestamp',),
WaitTimeSeconds=self.recv_wait_time_seconds,
)
if resp['ResponseMetadata']['HTTPStatusCode'] != 200:
raise Exception('Invalid status code from sqs: %s' %
resp['ResponseMetadata']['HTTPStatusCode'])
msgs = resp.get('Messages')
if not msgs:
return None
assert len(msgs) == 1
msg = msgs[0]
payload = msg['Body']
handle = msg['ReceiptHandle']
timestamp = msg['Attributes']['SentTimestamp']
metadata = dict(timestamp=timestamp)
msg_handle = MessageHandle(handle, payload, metadata)
return msg_handle
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier integer keyword_argument identifier tuple string string_start string_content string_end keyword_argument identifier attribute identifier identifier if_statement comparison_operator subscript subscript identifier string string_start string_content string_end string string_start string_content string_end integer block raise_statement call identifier argument_list binary_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 expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block return_statement none assert_statement comparison_operator call identifier argument_list identifier integer expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement identifier
|
read a single message from the queue
|
def remove_nopairs(in_bam, out_dir, config):
runner = broad.runner_from_config(config)
out_bam = os.path.join(out_dir, "{}-safepair{}".format(*os.path.splitext(os.path.basename(in_bam))))
if not utils.file_exists(out_bam):
read_counts = collections.defaultdict(int)
with pysam.Samfile(in_bam, "rb") as in_pysam:
for read in in_pysam:
if read.is_paired:
read_counts[read.qname] += 1
with pysam.Samfile(in_bam, "rb") as in_pysam:
with file_transaction(out_bam) as tx_out_bam:
with pysam.Samfile(tx_out_bam, "wb", template=in_pysam) as out_pysam:
for read in in_pysam:
if read_counts[read.qname] == 2:
out_pysam.write(read)
return runner.run_fn("picard_sort", out_bam, "queryname")
|
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 attribute identifier identifier identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list list_splat call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier identifier block if_statement attribute identifier identifier block expression_statement augmented_assignment subscript identifier attribute identifier identifier integer with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier identifier as_pattern_target identifier block for_statement identifier identifier block if_statement comparison_operator subscript identifier attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier string string_start string_content string_end
|
Remove any reads without both pairs present in the file.
|
def captures_directory(self):
path = os.path.join(self._path, "project-files", "captures")
os.makedirs(path, exist_ok=True)
return path
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true return_statement identifier
|
Location of the captures files
|
def make_sudo_cmd(sudo_user, executable, cmd):
randbits = ''.join(chr(random.randint(ord('a'), ord('z'))) for x in xrange(32))
prompt = '[sudo via ansible, key=%s] password: ' % randbits
sudocmd = '%s -k && %s %s -S -p "%s" -u %s %s -c %s' % (
C.DEFAULT_SUDO_EXE, C.DEFAULT_SUDO_EXE, C.DEFAULT_SUDO_FLAGS,
prompt, sudo_user, executable or '$SHELL', pipes.quote(cmd))
return ('/bin/sh -c ' + pipes.quote(sudocmd), prompt)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute string string_start string_end identifier generator_expression call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end for_in_clause identifier call identifier argument_list integer expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier identifier boolean_operator identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier return_statement tuple binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier identifier
|
helper function for connection plugins to create sudo commands
|
def tseitin(self, auxvarname='aux'):
if self.is_cnf():
return self
_, constraints = _tseitin(self.to_nnf(), auxvarname)
fst = constraints[-1][1]
rst = [Equal(v, ex).to_cnf() for v, ex in constraints[:-1]]
return And(fst, *rst)
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block if_statement call attribute identifier identifier argument_list block return_statement identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript subscript identifier unary_operator integer integer expression_statement assignment identifier list_comprehension call attribute call identifier argument_list identifier identifier identifier argument_list for_in_clause pattern_list identifier identifier subscript identifier slice unary_operator integer return_statement call identifier argument_list identifier list_splat identifier
|
Convert the expression to Tseitin's encoding.
|
def accel_move_tab_right(self, *args):
pos = self.get_notebook().get_current_page()
if pos != self.get_notebook().get_n_pages() - 1:
self.move_tab(pos, pos + 1)
return True
|
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_statement comparison_operator identifier binary_operator call attribute call attribute identifier identifier argument_list identifier argument_list integer block expression_statement call attribute identifier identifier argument_list identifier binary_operator identifier integer return_statement true
|
Callback to move a tab to the right
|
def add_dependency(id=None, name=None, dependency_id=None, dependency_name=None):
data = add_dependency_raw(id, name, dependency_id, dependency_name)
if data:
return utils.format_json_list(data)
|
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier if_statement identifier block return_statement call attribute identifier identifier argument_list identifier
|
Add an existing BuildConfiguration as a dependency to another BuildConfiguration.
|
def cells(self) -> Generator[Tuple[int, int], None, None]:
yield from itertools.product(
range(self.row_start, self.row_end),
range(self.column_start, self.column_end)
)
|
module function_definition identifier parameters identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type identifier type identifier type none type none block expression_statement yield call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier
|
Generate cells in span.
|
def _copy_replace(src, dst, replacements):
with src.open() as infile, dst.open('w') as outfile:
outfile.write(re.sub(
'|'.join(re.escape(k) for k in replacements),
lambda m: str(replacements[m.group(0)]),
infile.read()
))
|
module function_definition identifier parameters identifier identifier identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier with_item as_pattern call attribute identifier identifier argument_list 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 call attribute string string_start string_content string_end identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier identifier lambda lambda_parameters identifier call identifier argument_list subscript identifier call attribute identifier identifier argument_list integer call attribute identifier identifier argument_list
|
Copies the src file into dst applying the replacements dict
|
def list_cubes(self):
for file_name in os.listdir(self.directory):
if '.' in file_name:
name, ext = file_name.rsplit('.', 1)
if ext.lower() == 'json':
yield name
|
module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement yield identifier
|
List all available JSON files.
|
def save_relationship(self, relationship_form, *args, **kwargs):
if relationship_form.is_for_update():
return self.update_relationship(relationship_form, *args, **kwargs)
else:
return self.create_relationship(relationship_form, *args, **kwargs)
|
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement call attribute identifier identifier argument_list block return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier else_clause block return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier
|
Pass through to provider RelationshipAdminSession.update_relationship
|
def stationary_distribution(P, C=None, mincount_connectivity=0):
from msmtools.analysis.dense.stationary_vector import stationary_distribution as msmstatdist
if C is None:
if is_connected(P, strong=True):
return msmstatdist(P)
else:
raise ValueError('Computing stationary distribution for disconnected matrix. Need count matrix.')
n = np.shape(C)[0]
ctot = np.sum(C)
pi = np.zeros(n)
sets = connected_sets(C, mincount_connectivity=mincount_connectivity, strong=False)
for s in sets:
w = np.sum(C[s, :]) / ctot
pi[s] = w * msmstatdist(P[s, :][:, s])
pi /= np.sum(pi)
return pi
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier integer block import_from_statement dotted_name identifier identifier identifier identifier aliased_import dotted_name identifier identifier if_statement comparison_operator identifier none block if_statement call identifier argument_list identifier keyword_argument identifier true block return_statement call identifier argument_list identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier false for_statement identifier identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list subscript identifier identifier slice identifier expression_statement assignment subscript identifier identifier binary_operator identifier call identifier argument_list subscript subscript identifier identifier slice slice identifier expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
|
Simple estimator for stationary distribution for multiple strongly connected sets
|
def applyIndex(self, lst, right):
if len(right) != 1:
raise exceptions.EvaluationError('%r can only be applied to one argument, got %r' % (self.left, self.right))
right = right[0]
if isinstance(right, int):
return lst[right]
raise exceptions.EvaluationError("Can't apply %r to argument (%r): integer expected, got %r" % (self.left, self.right, right))
|
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block raise_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 assignment identifier subscript identifier integer if_statement call identifier argument_list identifier identifier block return_statement subscript identifier identifier raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier identifier
|
Apply a list to something else.
|
def stream(self):
if not hasattr(self, '_stream'):
self._stream = zmq.eventloop.zmqstream.ZMQStream(self._socket, io_loop=self.io_loop)
return self._stream
|
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier return_statement attribute identifier identifier
|
Return the current zmqstream, creating one if necessary
|
def from_country(cls, country):
result = cls.list({'sort_by': 'id ASC'})
dc_countries = {}
for dc in result:
if dc['country'] not in dc_countries:
dc_countries[dc['country']] = dc['id']
return dc_countries.get(country)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier dictionary for_statement identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement assignment subscript identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier
|
Retrieve the first datacenter id associated to a country.
|
def package_has_version_file(package_name):
version_file_path = helpers.package_file_path('_version.py', package_name)
return os.path.isfile(version_file_path)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Check to make sure _version.py is contained in the package
|
def Printer(open_file=sys.stdout, closing=False):
try:
while True:
logstr = (yield)
open_file.write(logstr)
open_file.write('\n')
except GeneratorExit:
if closing:
try: open_file.close()
except: pass
|
module function_definition identifier parameters default_parameter identifier attribute identifier identifier default_parameter identifier false block try_statement block while_statement true block expression_statement assignment identifier parenthesized_expression yield expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end except_clause identifier block if_statement identifier block try_statement block expression_statement call attribute identifier identifier argument_list except_clause block pass_statement
|
Prints items with a timestamp.
|
def unpack_rgb_image(plane):
assert plane.bits_per_pixel == 24, "{} != 24".format(plane.bits_per_pixel)
size = point.Point.build(plane.size)
data = np.frombuffer(plane.data, dtype=np.uint8)
return data.reshape(size.y, size.x, 3)
|
module function_definition identifier parameters identifier block assert_statement comparison_operator attribute identifier identifier integer call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier integer
|
Return a correctly shaped numpy array given the image bytes.
|
def timelines(fig, y, xstart, xstop, color='b'):
fig.hlines(y, xstart, xstop, color, lw=4)
fig.vlines(xstart, y+0.03, y-0.03, color, lw=2)
fig.vlines(xstop, y+0.03, y-0.03, color, lw=2)
|
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list identifier binary_operator identifier float binary_operator identifier float identifier keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list identifier binary_operator identifier float binary_operator identifier float identifier keyword_argument identifier integer
|
Plot timelines at y from xstart to xstop with given color.
|
def read(self, start_position: int, size: int) -> memoryview:
return memoryview(self._bytes)[start_position:start_position + size]
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block return_statement subscript call identifier argument_list attribute identifier identifier slice identifier binary_operator identifier identifier
|
Return a view into the memory
|
def die(msg, errlvl=1, prefix="Error: "):
stderr("%s%s\n" % (prefix, msg))
sys.exit(errlvl)
|
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier string string_start string_content string_end block expression_statement call identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple identifier identifier expression_statement call attribute identifier identifier argument_list identifier
|
Convenience function to write short message to stderr and quit.
|
def _traverse_report(data):
if 'items' not in data:
return {}
out = {}
for item in data['items']:
skip = (item['severity'] == 'NonDisplay' or
item['itemKey'] == 'categoryDesc' or
item['value'] in [None, 'Null', 'N/A', 'NULL'])
if skip:
continue
value = 'Ok' if item['value'] == '0.0' else item['value']
out[item['itemKey']] = value
out.update(_traverse_report(item))
return out
|
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end identifier block return_statement dictionary expression_statement assignment identifier dictionary for_statement identifier subscript identifier string string_start string_content string_end block expression_statement assignment identifier parenthesized_expression boolean_operator boolean_operator comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end list none string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement identifier block continue_statement expression_statement assignment identifier conditional_expression string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement identifier
|
Recursively traverse vehicle health report.
|
def clipper(self):
for sample in self.runmetadata:
replacementresults = dict()
try:
if self.analysistype != 'sixteens_full' and self.analysistype != 'resfinder':
for gene in sample[self.analysistype].faidict:
try:
percentidentity = sample[self.analysistype].results[gene]
try:
passingfeature = list()
for location, feature in sample[self.analysistype].features[gene].items():
if len(feature) < int(float(sample[self.analysistype].avgdepth[gene])) * 0.3:
passingfeature.append(True)
else:
passingfeature.append(False)
if all(passingfeature):
replacementresults[gene] = percentidentity
except KeyError:
replacementresults[gene] = percentidentity
except KeyError:
pass
sample[self.analysistype].results = replacementresults
except AttributeError:
pass
|
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list try_statement block if_statement boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end comparison_operator attribute identifier identifier string string_start string_content string_end block for_statement identifier attribute subscript identifier attribute identifier identifier identifier block try_statement block expression_statement assignment identifier subscript attribute subscript identifier attribute identifier identifier identifier identifier try_statement block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute subscript attribute subscript identifier attribute identifier identifier identifier identifier identifier argument_list block if_statement comparison_operator call identifier argument_list identifier binary_operator call identifier argument_list call identifier argument_list subscript attribute subscript identifier attribute identifier identifier identifier identifier float block expression_statement call attribute identifier identifier argument_list true else_clause block expression_statement call attribute identifier identifier argument_list false if_statement call identifier argument_list identifier block expression_statement assignment subscript identifier identifier identifier except_clause identifier block expression_statement assignment subscript identifier identifier identifier except_clause identifier block pass_statement expression_statement assignment attribute subscript identifier attribute identifier identifier identifier identifier except_clause identifier block pass_statement
|
Filter out results based on the presence of cigar features such as internal soft-clipping
|
def fromints(cls, ints):
return cls.frombitsets(map(cls.BitSet.fromint, ints))
|
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list call identifier argument_list attribute attribute identifier identifier identifier identifier
|
Series from integer rank arguments.
|
def _build_row(self, row, parent, align, border):
tr = etree.SubElement(parent, 'tr')
tag = 'td'
if parent.tag == 'thead':
tag = 'th'
cells = self._split_row(row, border)
for i, a in enumerate(align):
c = etree.SubElement(tr, tag)
try:
c.text = cells[i].strip()
except IndexError:
c.text = ""
if a:
c.set('align', a)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier try_statement block expression_statement assignment attribute identifier identifier call attribute subscript identifier identifier identifier argument_list except_clause identifier block expression_statement assignment attribute identifier identifier string string_start string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
|
Given a row of text, build table cells.
|
def addPort(n: LNode, intf: Interface):
d = PortTypeFromDir(intf._direction)
ext_p = LayoutExternalPort(
n, name=intf._name, direction=d, node2lnode=n._node2lnode)
ext_p.originObj = originObjOfPort(intf)
n.children.append(ext_p)
addPortToLNode(ext_p, intf, reverseDirection=True)
return ext_p
|
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call identifier argument_list identifier identifier keyword_argument identifier true return_statement identifier
|
Add LayoutExternalPort for interface
|
def total_volume_per_neurite(neurites, neurite_type=NeuriteType.all):
return list(sum(s.volume for s in n.iter_sections())
for n in iter_neurites(neurites, filt=is_type(neurite_type)))
|
module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier block return_statement call identifier generator_expression call identifier generator_expression attribute identifier identifier for_in_clause identifier call attribute identifier identifier argument_list for_in_clause identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier
|
Get the volume per neurite in a collection
|
def _parse_summary_frames(self, file_obj):
for _ in range(self.n_summary_frames):
dom_id = unpack('<i', file_obj.read(4))[0]
dq_status = file_obj.read(4)
dom_status = unpack('<iiii', file_obj.read(16))
raw_rates = unpack('b' * 31, file_obj.read(31))
pmt_rates = [self._get_rate(value) for value in raw_rates]
self.summary_frames[dom_id] = pmt_rates
self.dq_status[dom_id] = dq_status
self.dom_status[dom_id] = dom_status
self.dom_rates[dom_id] = np.sum(pmt_rates)
|
module function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier subscript call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list integer integer expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end integer call attribute identifier identifier argument_list integer expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list identifier
|
Iterate through the byte data and fill the summary_frames
|
def neighbors(self, distance=2.0):
dgrid = self.distance_grid.reshape(self.num_neurons, self.num_neurons)
for x, y in zip(*np.nonzero(dgrid <= distance)):
if x != y:
yield x, y
|
module function_definition identifier parameters identifier default_parameter identifier float block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list list_splat call attribute identifier identifier argument_list comparison_operator identifier identifier block if_statement comparison_operator identifier identifier block expression_statement yield expression_list identifier identifier
|
Get all neighbors for all neurons.
|
def set(self, shape):
self.bottom, self.left = shape.bottom, shape.left
self.width, self.height = shape.width, shape.height
return self
|
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier expression_list attribute identifier identifier attribute identifier identifier expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier expression_list attribute identifier identifier attribute identifier identifier return_statement identifier
|
Fill this rectangle with the dimensions of the given shape.
|
def extract_causal_relations(self):
relations = [e for e in self.doc.extractions if
'DirectedRelation' in e['labels'] and
'Causal' in e['labels']]
for relation in relations:
stmt = self.get_causal_relation(relation)
if stmt is not None:
self.statements.append(stmt)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier attribute attribute identifier identifier identifier if_clause boolean_operator comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Extract causal relations as Statements.
|
def cli(yamlfile, directory, out, classname, format):
DotGenerator(yamlfile, format).serialize(classname=classname, dirname=directory, filename=out)
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Generate graphviz representations of the biolink model
|
def read_only_s3_bucket_policy_statements(buckets, folder="*"):
list_buckets = [s3_arn(b) for b in buckets]
object_buckets = [s3_objects_arn(b, folder) for b in buckets]
bucket_resources = list_buckets + object_buckets
return [
Statement(
Effect=Allow,
Resource=[s3_arn("*")],
Action=[s3.ListAllMyBuckets]
),
Statement(
Effect=Allow,
Resource=bucket_resources,
Action=[Action('s3', 'Get*'), Action('s3', 'List*')]
)
]
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier list_comprehension call identifier argument_list identifier identifier for_in_clause identifier identifier expression_statement assignment identifier binary_operator identifier identifier return_statement list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier list call identifier argument_list string string_start string_content string_end keyword_argument identifier list attribute identifier identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier list call identifier argument_list string string_start string_content string_end string string_start string_content string_end call identifier argument_list string string_start string_content string_end string string_start string_content string_end
|
Read only policy an s3 bucket.
|
def build_default_filepath(self):
return os.path.join(
self.app_config.name,
'scripts',
self.template_relpath + '.js',
)
|
module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end binary_operator attribute identifier identifier string string_start string_content string_end
|
Called when 'filepath' is not defined in the settings
|
def to_dict(cls, acl):
return {
"perms": acl.perms,
"id": {
"scheme": acl.id.scheme,
"id": acl.id.id
}
}
|
module function_definition identifier parameters identifier identifier block return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end attribute attribute identifier identifier identifier
|
transform an ACL to a dict
|
def asyncStarCmap(asyncCallable, iterable):
results = []
yield coopStar(asyncCallable, results.append, iterable)
returnValue(results)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement yield call identifier argument_list identifier attribute identifier identifier identifier expression_statement call identifier argument_list identifier
|
itertools.starmap for deferred callables using cooperative multitasking
|
def team_accessLogs(self, **kwargs) -> SlackResponse:
self._validate_xoxp_token()
return self.api_call("team.accessLogs", http_verb="GET", params=kwargs)
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier type identifier block expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier
|
Gets the access logs for the current team.
|
def Query(self, sql_query):
results = {}
try:
self._connection = sqlite.connect(self.name)
self._connection.execute("PRAGMA journal_mode=%s" % self.journal_mode)
self._cursor = self._connection.cursor()
results = self._cursor.execute(sql_query).fetchall()
except sqlite.Error as error_string:
logging.warning("SQLite error %s", error_string)
return results
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary try_statement block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier
|
Query the database file.
|
def translate(self):
varnames = set()
ident = self.ident
funcnames = set([ident])
arg_exprs = []
for arg in self.args:
subexprs, subvars, subfuncs = arg.translate()
varnames.update(subvars)
funcnames.update(subfuncs)
arg_exprs.append(ex_call(
ast.Attribute(ex_literal(u''), 'join', ast.Load()),
[ex_call(
'map',
[
ex_rvalue(str.__name__),
ast.List(subexprs, ast.Load()),
]
)],
))
subexpr_call = ex_call(
FUNCTION_PREFIX + ident,
arg_exprs
)
return [subexpr_call], varnames, funcnames
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list list identifier expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list string string_start string_end string string_start string_content string_end call attribute identifier identifier argument_list list call identifier argument_list string string_start string_content string_end list call identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier identifier return_statement expression_list list identifier identifier identifier
|
Compile the function call.
|
def install_toolset(self, toolset):
info = toolset_info[toolset]
if sys.platform.startswith('linux'):
os.chdir(self.work_dir)
if 'ppa' in info:
for ppa in info['ppa']:
utils.check_call(
'sudo','add-apt-repository','--yes',ppa)
if 'deb' in info:
utils.make_file('sources.list',
"deb %s"%(' '.join(info['deb'])),
"deb-src %s"%(' '.join(info['deb'])))
utils.check_call('sudo','bash','-c','cat sources.list >> /etc/apt/sources.list')
if 'apt-key' in info:
for key in info['apt-key']:
utils.check_call('wget',key,'-O','apt.key')
utils.check_call('sudo','apt-key','add','apt.key')
utils.check_call(
'sudo','apt-get','update','-qq')
utils.check_call(
'sudo','apt-get','install','-qq',info['package'])
if 'debugpackage' in info and info['debugpackage']:
utils.check_call(
'sudo','apt-get','install','-qq',info['debugpackage'])
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block for_statement identifier subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier 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 binary_operator string string_start string_content string_end parenthesized_expression call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end binary_operator string string_start string_content string_end parenthesized_expression call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block for_statement identifier subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement boolean_operator comparison_operator string string_start string_content string_end identifier subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end
|
Installs specific toolset on CI system.
|
def _get_default_router(self, routers, router_name=None):
if router_name is None:
for router in routers:
if router['id'] is not None:
return router['id']
else:
for router in routers:
if router['hostname'] == router_name:
return router['id']
raise SoftLayer.SoftLayerError("Could not find valid default router")
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block for_statement identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end none block return_statement subscript identifier string string_start string_content string_end else_clause block for_statement identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block return_statement subscript identifier string string_start string_content string_end raise_statement call attribute identifier identifier argument_list string string_start string_content string_end
|
Returns the default router for ordering a dedicated host.
|
def isInside(self, point, tol=0.0001):
poly = self.polydata(True)
points = vtk.vtkPoints()
points.InsertNextPoint(point)
pointsPolydata = vtk.vtkPolyData()
pointsPolydata.SetPoints(points)
sep = vtk.vtkSelectEnclosedPoints()
sep.SetTolerance(tol)
sep.CheckSurfaceOff()
sep.SetInputData(pointsPolydata)
sep.SetSurfaceData(poly)
sep.Update()
return sep.IsInside(0)
|
module function_definition identifier parameters identifier identifier default_parameter identifier float block expression_statement assignment identifier call attribute identifier identifier argument_list true expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list integer
|
Return True if point is inside a polydata closed surface.
|
def _create_table_xml_file(self, data, fname=None):
content = self._xml_pretty_print(data)
if not fname:
fname = self.name
with open(fname+".xml", 'w') as f:
f.write(content)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list binary_operator identifier string string_start string_content string_end string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Creates a xml file of the table
|
def _include_term_list(self, termlist):
ref_needed = False
for term in termlist:
ref_needed = ref_needed or self._include_term(term)
return ref_needed
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier false for_statement identifier identifier block expression_statement assignment identifier boolean_operator identifier call attribute identifier identifier argument_list identifier return_statement identifier
|
Add terms from a TermList to the ontology.
|
def setup_apiv2():
if sys.version_info[0] == 2:
logging.getLogger(__name__).debug(
'setting up SIP API to version 2')
import sip
try:
sip.setapi("QString", 2)
sip.setapi("QVariant", 2)
except ValueError:
logging.getLogger(__name__).critical(
"failed to set up sip api to version 2 for PyQt4")
raise ImportError('PyQt4')
|
module function_definition identifier parameters block if_statement comparison_operator subscript attribute identifier identifier integer integer block expression_statement call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end import_statement dotted_name identifier try_statement block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer except_clause identifier block expression_statement call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end raise_statement call identifier argument_list string string_start string_content string_end
|
Setup apiv2 when using PyQt4 and Python2.
|
def move_up(self):
self.at(ardrone.at.pcmd, True, 0, 0, self.speed, 0)
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier true integer integer attribute identifier identifier integer
|
Make the drone rise upwards.
|
def config(self):
if self.__config is None:
config_path = self.locate_config()
if config_path:
self.__config = self.read_file(config_path)
self.__config_path = config_path
return self.__config
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier return_statement attribute identifier identifier
|
Read config automatically if required
|
def _update_wikidata(self):
claims = self.data['claims']
for ent in claims:
plabel = self.data['labels'].get(ent)
if plabel:
plabel = "%s (%s)" % (plabel, ent)
claim = []
for item in claims[ent]:
ilabel = item
if utils.is_text(item) and re.match(r'^Q\d+$', item):
ilabel = self.data['labels'].get(item)
if ilabel:
ilabel = "%s (%s)" % (ilabel, item)
if len(claims[ent]) == 1:
claim = ilabel
else:
claim.append(ilabel)
if plabel and ilabel:
self.data['wikidata'][plabel] = claim
|
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list identifier if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier list for_statement identifier subscript identifier identifier block expression_statement assignment identifier identifier if_statement boolean_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier block expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list identifier if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier if_statement comparison_operator call identifier argument_list subscript identifier identifier integer block expression_statement assignment identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier if_statement boolean_operator identifier identifier block expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end identifier identifier
|
set wikidata from claims and labels
|
def callback(self):
try:
return self._callback()
except:
s = straceback()
self.exceptions.append(s)
self.shutdown(msg="Exception raised in callback!\n" + s)
|
module function_definition identifier parameters identifier block try_statement block return_statement call attribute identifier identifier argument_list except_clause block expression_statement assignment identifier call identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier binary_operator string string_start string_content escape_sequence string_end identifier
|
The function that will be executed by the scheduler.
|
def start(self):
if self.mode == MODE_PRIMARY:
i = self._start()
else:
i = self._connect()
self.manager = i
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier
|
Starts or connects to the manager.
|
def sync_sources(self, force=False):
from ambry.orm.file import File
self.dstate = self.STATES.BUILDING
synced = 0
for fc in [File.BSFILE.SOURCES]:
bsf = self.build_source_files.file(fc)
if bsf.fs_is_newer or force:
self.log('Syncing {}'.format(bsf.file_name))
bsf.fs_to_objects()
synced += 1
return synced
|
module function_definition identifier parameters identifier default_parameter identifier false block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier expression_statement assignment identifier integer for_statement identifier list attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement boolean_operator attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement augmented_assignment identifier integer return_statement identifier
|
Sync in only the sources.csv file
|
def _init_lazy_fields(self):
self.gtf_path = None
self._protein_sequences = None
self._transcript_sequences = None
self._db = None
self.protein_fasta_paths = None
self.transcript_fasta_paths = None
self._genes = {}
self._transcripts = {}
self._exons = {}
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier dictionary expression_statement assignment attribute identifier identifier dictionary expression_statement assignment attribute identifier identifier dictionary
|
Member data that gets loaded or constructed on demand
|
def create_app_from_yml(path):
try:
with open(path, "rt", encoding="UTF-8") as f:
try:
interpolated = io.StringIO(f.read() % {
"here": os.path.abspath(os.path.dirname(path))})
interpolated.name = f.name
conf = yaml.safe_load(interpolated)
except yaml.YAMLError as exc:
raise RuntimeError(
"Cannot parse a configuration file. Context: " + str(exc))
except FileNotFoundError:
conf = {"metadata": None, "pipes": {}}
return core.create_app(conf["metadata"], pipes=conf["pipes"])
|
module function_definition identifier parameters identifier block try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier except_clause identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end none pair string string_start string_content string_end dictionary return_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end
|
Return an application instance created from YAML.
|
def freeze(obj):
if isinstance(obj, dict):
return ImmutableDict(obj)
if isinstance(obj, list):
return ImmutableList(obj)
if isinstance(obj, set):
return ImmutableSet(obj)
return obj
|
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier return_statement identifier
|
Freeze python types by turning them into immutable structures.
|
def _notify_subnet_create(resource, event, trigger, **kwargs):
context = kwargs['context']
subnet = kwargs['subnet']
l3plugin = bc.get_plugin(L3_ROUTER_NAT)
for router in l3plugin.get_routers(context):
if (router['external_gateway_info'] and
(router['external_gateway_info']['network_id'] ==
subnet['network_id'])):
router_data = {'router': router}
l3plugin.update_router(context, router['id'], router_data)
|
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list identifier block if_statement parenthesized_expression boolean_operator subscript identifier string string_start string_content string_end parenthesized_expression comparison_operator subscript subscript identifier string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end identifier
|
Called when a new subnet is created in the external network
|
def _get_tags_and_content(self, content: str) -> typing.Tuple[str, str]:
content_lines = content.split('\n')
tag_lines = []
if content_lines[0] != '---':
return '', content
content_lines.pop(0)
for line in content_lines:
if line in ('---', '...'):
content_starts_at = content_lines.index(line) + 1
content_lines = content_lines[content_starts_at:]
break
tag_lines.append(line)
return '\n'.join(tag_lines), '\n'.join(content_lines)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier type subscript attribute identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment identifier list if_statement comparison_operator subscript identifier integer string string_start string_content string_end block return_statement expression_list string string_start string_end identifier expression_statement call attribute identifier identifier argument_list integer for_statement identifier identifier block if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier integer expression_statement assignment identifier subscript identifier slice identifier break_statement expression_statement call attribute identifier identifier argument_list identifier return_statement expression_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier
|
Splits content into two string - tags part and another content.
|
def copy_attr(f1, f2):
copyit = lambda x: not hasattr(f2, x) and x[:10] == 'PACKAGING_'
if f1._tags:
pattrs = [tag for tag in f1._tags if copyit(tag)]
for attr in pattrs:
f2.Tag(attr, f1.GetTag(attr))
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier lambda lambda_parameters identifier boolean_operator not_operator call identifier argument_list identifier identifier comparison_operator subscript identifier slice integer string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause call identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier
|
copies the special packaging file attributes from f1 to f2.
|
async def _receive(self, stream_id, pp_id, data):
await self._data_channel_receive(stream_id, pp_id, data)
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement await call attribute identifier identifier argument_list identifier identifier identifier
|
Receive data stream -> ULP.
|
def exec_then_eval(code, namespace=None):
namespace = namespace or {}
block = ast.parse(code, mode='exec')
last = ast.Expression(block.body.pop().value)
exec(compile(block, '<string>', mode='exec'), namespace)
return eval(compile(last, '<string>', mode='eval'), namespace)
|
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list attribute call attribute attribute identifier identifier identifier argument_list identifier expression_statement call identifier argument_list call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end identifier return_statement call identifier argument_list call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end identifier
|
Exec a code block & return evaluation of the last line
|
def generate_words(numberofwords, wordlist, secure=None):
if not secure:
chooser = random.choice
else:
chooser = random.SystemRandom().choice
return [chooser(wordlist) for _ in range(numberofwords)]
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier
|
Generate a list of random words from wordlist.
|
def standardize(score):
score = asarray_ndim(score, 1)
return (score - np.nanmean(score)) / np.nanstd(score)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier integer return_statement binary_operator parenthesized_expression binary_operator identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier
|
Centre and scale to unit variance.
|
def addUnderlineAnnot(self, rect):
CheckParent(self)
val = _fitz.Page_addUnderlineAnnot(self, rect)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = val
return val
|
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement not_operator identifier block return_statement expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier call identifier argument_list identifier identifier return_statement identifier
|
Underline content in a rectangle or quadrilateral.
|
def _import_module(module_path, classnames):
try:
imported_module = __import__(module_path, fromlist=classnames)
return imported_module
except ImportError:
__, __, exc_traceback = sys.exc_info()
frames = traceback.extract_tb(exc_traceback)
if len(frames) > 1:
raise
|
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier return_statement identifier except_clause identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block raise_statement
|
Tries to import the given Python module path.
|
def use_isolated_book_view(self):
self._book_view = ISOLATED
for session in self._get_provider_sessions():
try:
session.use_isolated_book_view()
except AttributeError:
pass
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement
|
Pass through to provider CommentLookupSession.use_isolated_book_view
|
def _pre_delete_hook(cls, key):
if cls.searching_enabled:
doc_id = cls.search_get_document_id(key)
index = cls.search_get_index()
index.delete(doc_id)
|
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier
|
Removes instance from index.
|
def disassociate_public_ip(self, public_ip_id):
floating_ip = self.client.floating_ips.get(public_ip_id)
floating_ip = floating_ip.to_dict()
instance_id = floating_ip.get('instance_id')
address = floating_ip.get('ip')
self.client.servers.remove_floating_ip(instance_id, address)
return True
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier return_statement true
|
Disassociate a external IP
|
def save(self, *args, **kwargs):
valid = map(str, settings.RATINGS_RANGE)
if str(self.value) not in valid:
raise ValueError("Invalid rating. %s is not in %s" % (self.value,
", ".join(valid)))
super(Rating, self).save(*args, **kwargs)
|
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier
|
Validate that the rating falls between the min and max values.
|
def _config(self):
config = 0
if self.mode == MODE_NORMAL:
config += (self._t_standby << 5)
if self._iir_filter:
config += (self._iir_filter << 2)
return config
|
module function_definition identifier parameters identifier block expression_statement assignment identifier integer if_statement comparison_operator attribute identifier identifier identifier block expression_statement augmented_assignment identifier parenthesized_expression binary_operator attribute identifier identifier integer if_statement attribute identifier identifier block expression_statement augmented_assignment identifier parenthesized_expression binary_operator attribute identifier identifier integer return_statement identifier
|
Value to be written to the device's config register
|
def delete_issue_link_type(self, issue_link_type_id):
url = 'rest/api/2/issueLinkType/{issueLinkTypeId}'.format(issueLinkTypeId=issue_link_type_id)
return self.delete(url)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list identifier
|
Delete the specified issue link type.
|
def check_file(self):
try:
image_type = ".{0}".format(self.image.split(".")[1])
if image_type not in self.file_format:
print("Format: '{0}' not recognized. Use one of "
"them:\n{1}".format(self.image.split(".")[1],
", ".join(self.file_format)))
raise SystemExit()
except IndexError:
print("slpkg: Error: Image file suffix missing")
raise SystemExit()
|
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer if_statement comparison_operator identifier attribute identifier identifier block expression_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content escape_sequence string_end identifier argument_list subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier raise_statement call identifier argument_list except_clause identifier block expression_statement call identifier argument_list string string_start string_content string_end raise_statement call identifier argument_list
|
Check for file format and type
|
def loadFile(self, fileName):
self.file = QtCore.QFile(fileName)
if self.file.exists():
self.qteText.append(open(fileName).read())
else:
msg = "File <b>{}</b> does not exist".format(self.qteAppletID())
self.qteLogger.info(msg)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier if_statement call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute call identifier argument_list identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier
|
Display the file associated with the appletID.
|
def relative_path(self, absolute_path, output_filename):
absolute_path = posixpath.join(settings.PIPELINE_ROOT, absolute_path)
output_path = posixpath.join(settings.PIPELINE_ROOT, posixpath.dirname(output_filename))
return relpath(absolute_path, output_path)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier identifier
|
Rewrite paths relative to the output stylesheet path
|
def extract_bits(self, val):
thisval = self.high >> 4
thisval = thisval ^ val
self.high = (self.high << 4) | (self.low >> 4)
self.high = self.high & constants.BYTEMASK
self.low = self.low << 4
self.low = self.low & constants.BYTEMASK
self.high = self.high ^ self.LookupHigh[thisval]
self.high = self.high & constants.BYTEMASK
self.low = self.low ^ self.LookupLow[thisval]
self.low = self.low & constants.BYTEMASK
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier integer expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment attribute identifier identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier integer parenthesized_expression binary_operator attribute identifier identifier integer expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier integer expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier subscript attribute identifier identifier identifier expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier subscript attribute identifier identifier identifier expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier
|
Extras the 4 bits, XORS the message data, and does table lookups.
|
def interface(iface):
iface_info, error = _get_iface_info(iface)
if error is False:
return iface_info.get(iface, {}).get('inet', '')
else:
return error
|
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement comparison_operator identifier false block return_statement call attribute call attribute identifier identifier argument_list identifier dictionary identifier argument_list string string_start string_content string_end string string_start string_end else_clause block return_statement identifier
|
Return the details of `iface` or an error if it does not exist
|
def enable_reporting(self):
self.reporting = True
msg = bytearray([REPORT_DIGITAL + self.port_number, 1])
self.board.sp.write(msg)
for pin in self.pins:
if pin.mode == INPUT:
pin.reporting = True
|
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier true expression_statement assignment identifier call identifier argument_list list binary_operator identifier attribute identifier identifier integer expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier true
|
Enable reporting of values for the whole port.
|
def htmlCreateMemoryParserCtxt(buffer, size):
ret = libxml2mod.htmlCreateMemoryParserCtxt(buffer, size)
if ret is None:raise parserError('htmlCreateMemoryParserCtxt() failed')
return parserCtxt(_obj=ret)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list keyword_argument identifier identifier
|
Create a parser context for an HTML in-memory document.
|
def pid(self):
try:
os.remove(self.pidfile)
except IOError:
if not os.path.isfile(self.pidfile):
return None
LOG.exception("Failed to clear pidfile {0}).".format(self.pidfile))
sys.exit(exit.PIDFILE_INACCESSIBLE)
|
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute identifier identifier argument_list attribute identifier identifier except_clause identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block return_statement none expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier
|
Stop managing the current pid.
|
def add_metadata_to_archive(self, metadata, meta_path):
archive_path = self.get_full_archive_path(meta_path.lstrip('/'))
write_data_to_file(metadata, archive_path)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier identifier
|
Add metadata to archive
|
def render_secretfile(opt):
LOG.debug("Using Secretfile %s", opt.secretfile)
secretfile_path = abspath(opt.secretfile)
obj = load_vars(opt)
return render(secretfile_path, obj)
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list identifier identifier
|
Renders and returns the Secretfile construct
|
def delete_edge_by_nodes(self, node_a, node_b):
node = self.get_node(node_a)
edge_ids = []
for e_id in node['edges']:
edge = self.get_edge(e_id)
if edge['vertices'][1] == node_b:
edge_ids.append(e_id)
for e in edge_ids:
self.delete_edge_by_id(e)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list for_statement identifier subscript identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator subscript subscript identifier string string_start string_content string_end integer identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
|
Removes all the edges from node_a to node_b from the graph.
|
def publish(self, topic, payload, qos=0, retain=False):
return self._client.publish(topic, payload, qos, retain)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer default_parameter identifier false block return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier
|
Publishes an MQTT message
|
def clean(self):
super().clean()
if self.poster is None and self.anonymous_key is None:
raise ValidationError(
_('A user id or an anonymous key must be associated with a post.'),
)
if self.poster and self.anonymous_key:
raise ValidationError(
_('A user id or an anonymous key must be associated with a post, but not both.'),
)
if self.anonymous_key and not self.username:
raise ValidationError(_('A username must be specified if the poster is anonymous'))
|
module function_definition identifier parameters identifier block expression_statement call attribute call identifier argument_list identifier argument_list if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list call identifier argument_list string string_start string_content string_end if_statement boolean_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list call identifier argument_list string string_start string_content string_end if_statement boolean_operator attribute identifier identifier not_operator attribute identifier identifier block raise_statement call identifier argument_list call identifier argument_list string string_start string_content string_end
|
Validates the post instance.
|
def from_dict(raw_data):
url = None
width = None
height = None
try:
url = raw_data['url']
width = raw_data['width']
height = raw_data['height']
except KeyError:
raise ValueError('Unexpected image json structure')
except TypeError:
pass
return Image(url, width, height)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier none expression_statement assignment identifier none expression_statement assignment identifier none try_statement block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end except_clause identifier block pass_statement return_statement call identifier argument_list identifier identifier identifier
|
Create Image from raw dictionary data.
|
def find_info(name=None):
if not name:
return list(servers.keys())
name = name.lower()
if name in servers:
info = servers[name]
else:
raise CityNotFound("Could not find the specified city: %s" % name)
return info
|
module function_definition identifier parameters default_parameter identifier none block if_statement not_operator identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement identifier
|
Find the needed city server information.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.