code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def invert_dictset(d):
result = {}
for k, c in d.items():
for v in c:
keys = result.setdefault(v, [])
keys.append(k)
return result | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier list expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Invert a dictionary with keys matching a set of values, turned into lists. |
def show_dependencies(self):
from spyder.widgets.dependencies import DependenciesDialog
dlg = DependenciesDialog(self)
dlg.set_data(dependencies.DEPENDENCIES)
dlg.exec_() | module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list | Show Spyder's Dependencies dialog box |
def ensure_configured(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
if len(logging.root.handlers) == 0:
basicConfig()
return func(*args, **kwargs)
return wrapper | module function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement comparison_operator call identifier argument_list attribute attribute identifier identifier identifier integer block expression_statement call identifier argument_list return_statement call identifier argument_list list_splat identifier dictionary_splat identifier return_statement identifier | Modify a function to call ``basicConfig`` first if no handlers exist. |
def dovds(data):
vds, X = 0, []
for rec in data:
X.append(dir2cart(rec))
for k in range(len(X) - 1):
xdif = X[k + 1][0] - X[k][0]
ydif = X[k + 1][1] - X[k][1]
zdif = X[k + 1][2] - X[k][2]
vds += np.sqrt(xdif**2 + ydif**2 + zdif**2)
vds += np.sqrt(X[-1][0]**2 + X[-1][1]**2 + X[-1][2]**2)
return vds | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier expression_list integer list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier for_statement identifier call identifier argument_list binary_operator call identifier argument_list identifier integer block expression_statement assignment identifier binary_operator subscript subscript identifier binary_operator identifier integer integer subscript subscript identifier identifier integer expression_statement assignment identifier binary_operator subscript subscript identifier binary_operator identifier integer integer subscript subscript identifier identifier integer expression_statement assignment identifier binary_operator subscript subscript identifier binary_operator identifier integer integer subscript subscript identifier identifier integer expression_statement augmented_assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator binary_operator identifier integer binary_operator identifier integer binary_operator identifier integer expression_statement augmented_assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator binary_operator subscript subscript identifier unary_operator integer integer integer binary_operator subscript subscript identifier unary_operator integer integer integer binary_operator subscript subscript identifier unary_operator integer integer integer return_statement identifier | calculates vector difference sum for demagnetization data |
def execute_command_no_results(self, sock_info, generator):
full_result = {
"writeErrors": [],
"writeConcernErrors": [],
"nInserted": 0,
"nUpserted": 0,
"nMatched": 0,
"nModified": 0,
"nRemoved": 0,
"upserted": [],
}
write_concern = WriteConcern()
op_id = _randint()
try:
self._execute_command(
generator, write_concern, None,
sock_info, op_id, False, full_result)
except OperationFailure:
pass | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end list pair string string_start string_content string_end list pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier none identifier identifier false identifier except_clause identifier block pass_statement | Execute write commands with OP_MSG and w=0 WriteConcern, ordered. |
def temperature(self):
result = self.i2c_read(2)
value = struct.unpack('>H', result)[0]
if value < 32768:
return value / 256.0
else:
return (value - 65536) / 256.0 | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end identifier integer if_statement comparison_operator identifier integer block return_statement binary_operator identifier float else_clause block return_statement binary_operator parenthesized_expression binary_operator identifier integer float | Get the temperature in degree celcius |
def clone(gandi, name, vhost, directory, origin):
if vhost != 'default':
directory = vhost
else:
directory = name if not directory else directory
return gandi.paas.clone(name, vhost, directory, origin) | module function_definition identifier parameters identifier identifier identifier identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier conditional_expression identifier not_operator identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier | Clone a remote vhost in a local git repository. |
def current_rolenames():
jwt_data = get_jwt_data_from_app_context()
if 'rls' not in jwt_data:
return set(['non-empty-but-definitely-not-matching-subset'])
else:
return set(r.strip() for r in jwt_data['rls'].split(',')) | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator string string_start string_content string_end identifier block return_statement call identifier argument_list list string string_start string_content string_end else_clause block return_statement call identifier generator_expression call attribute identifier identifier argument_list for_in_clause identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end | This method returns the names of all roles associated with the current user |
def create(client, output_file, revision, paths):
graph = Graph(client)
outputs = graph.build(paths=paths, revision=revision)
output_file.write(
yaml.dump(
ascwl(
graph.ascwl(outputs=outputs),
filter=lambda _, x: x is not None and x != [],
basedir=os.path.dirname(getattr(output_file, 'name', '.')) or
'.',
),
default_flow_style=False
)
) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier lambda lambda_parameters identifier identifier boolean_operator comparison_operator identifier none comparison_operator identifier list keyword_argument identifier boolean_operator call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier false | Create a workflow description for a file. |
def _get_co_from_dump(data):
current = struct.calcsize(b'iiii')
metadata = struct.unpack(b'iiii', data[:current])
logging.info("Magic value: %x", metadata[0])
logging.info("Code bytes length: %d", metadata[3])
arcname = ''
while six.indexbytes(data, current) != 0:
arcname += chr(six.indexbytes(data, current))
current += 1
logging.info("Archive name: %s", arcname or '-')
code_bytes = data[current + 1:]
code_objects = marshal.loads(code_bytes)
return code_objects | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier slice identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier integer expression_statement assignment identifier string string_start string_end while_statement comparison_operator call attribute identifier identifier argument_list identifier identifier integer block expression_statement augmented_assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier identifier expression_statement augmented_assignment identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end boolean_operator identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier slice binary_operator identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier | Return the code objects from the dump. |
def error(self):
for item in self:
if isinstance(item, WorkItem) and item.error:
return item.error
return None | module function_definition identifier parameters identifier block for_statement identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier attribute identifier identifier block return_statement attribute identifier identifier return_statement none | Returns the error for this barrier and all work items, if any. |
def _compile_rules(self):
for state, table in self.RULES.items():
patterns = list()
actions = list()
nextstates = list()
for i, row in enumerate(table):
if len(row) == 2:
pattern, _action = row
nextstate = None
elif len(row) == 3:
pattern, _action, nextstate = row
else:
fstr = "invalid RULES: state {}, row {}"
raise CompileError(fstr.format(state, i))
patterns.append(pattern)
actions.append(_action)
nextstates.append(nextstate)
reobj = re.compile('|'.join("(" + p + ")" for p in patterns))
self._rules[state] = (reobj, actions, nextstates) | module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment pattern_list identifier identifier identifier expression_statement assignment identifier none elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement assignment pattern_list identifier identifier identifier identifier else_clause block expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier generator_expression binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end for_in_clause identifier identifier expression_statement assignment subscript attribute identifier identifier identifier tuple identifier identifier identifier | Compile the rules into the internal lexer state. |
def load_json(path: str, encoding: str = "utf-8") -> HistogramBase:
with open(path, "r", encoding=encoding) as f:
text = f.read()
return parse_json(text) | module function_definition identifier parameters typed_parameter identifier type identifier typed_default_parameter identifier type identifier string string_start string_content string_end type identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call identifier argument_list identifier | Load histogram from a JSON file. |
def _read_stderr(self):
output = self._decode(self._process.readAllStandardError().data())
if self._formatter:
self._formatter.append_message(output, output_format=OutputFormat.ErrorMessageFormat)
else:
self.insertPlainText(output) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier | Reads the child process' stderr and process it. |
def write(tsdict, outfile, start=None, end=None,
name='gwpy', run=0):
if not start:
start = list(tsdict.values())[0].xspan[0]
if not end:
end = list(tsdict.values())[0].xspan[1]
duration = end - start
detectors = 0
for series in tsdict.values():
try:
idx = list(lalutils.LAL_DETECTORS.keys()).index(series.channel.ifo)
detectors |= 1 << 2*idx
except (KeyError, AttributeError):
continue
frame = lalframe.FrameNew(start, duration, name, run, 0, detectors)
for series in tsdict.values():
lalseries = series.to_lal()
add_ = lalutils.find_typed_function(
series.dtype, 'FrameAdd', 'TimeSeriesProcData', module=lalframe)
add_(frame, lalseries)
lalframe.FrameWrite(frame, outfile) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier integer block if_statement not_operator identifier block expression_statement assignment identifier subscript attribute subscript call identifier argument_list call attribute identifier identifier argument_list integer identifier integer if_statement not_operator identifier block expression_statement assignment identifier subscript attribute subscript call identifier argument_list call attribute identifier identifier argument_list integer identifier integer expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier integer for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement assignment identifier call attribute call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier argument_list attribute attribute identifier identifier identifier expression_statement augmented_assignment identifier binary_operator integer binary_operator integer identifier except_clause tuple identifier identifier block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier integer identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier expression_statement call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier | Write data to a GWF file using the LALFrame API |
def _unpickle_method(func_name, obj, cls):
if obj is None:
return cls.__dict__[func_name].__get__(obj, cls)
for cls in cls.__mro__:
try:
func = cls.__dict__[func_name]
except KeyError:
pass
else:
break
return func.__get__(obj, cls) | module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier none block return_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier identifier for_statement identifier attribute identifier identifier block try_statement block expression_statement assignment identifier subscript attribute identifier identifier identifier except_clause identifier block pass_statement else_clause block break_statement return_statement call attribute identifier identifier argument_list identifier identifier | Unpickle methods properly, including class methods. |
def ensure_cfn_bucket(self):
if self.bucket_name:
ensure_s3_bucket(self.s3_conn,
self.bucket_name,
self.bucket_region) | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier | The CloudFormation bucket where templates will be stored. |
def _update(collection_name, upsert, multi, spec, doc, check_keys, opts):
flags = 0
if upsert:
flags += 1
if multi:
flags += 2
encode = _dict_to_bson
encoded_update = encode(doc, check_keys, opts)
return b"".join([
_ZERO_32,
_make_c_string(collection_name),
_pack_int(flags),
encode(spec, False, opts),
encoded_update]), len(encoded_update) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier integer if_statement identifier block expression_statement augmented_assignment identifier integer if_statement identifier block expression_statement augmented_assignment identifier integer expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement expression_list call attribute string string_start string_end identifier argument_list list identifier call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier false identifier identifier call identifier argument_list identifier | Get an OP_UPDATE message. |
def run_job(args):
jm = setup(args)
job_id = int(os.environ['JOB_ID'])
array_id = int(os.environ['SGE_TASK_ID']) if os.environ['SGE_TASK_ID'] != 'undefined' else None
jm.run_job(job_id, array_id) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier conditional_expression call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end comparison_operator subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end none expression_statement call attribute identifier identifier argument_list identifier identifier | Starts the wrapper script to execute a job, interpreting the JOB_ID and SGE_TASK_ID keywords that are set by the grid or by us. |
def invalidate(self):
super(RedisTransport, self).invalidate()
for server in self._servers:
server['redis'].connection_pool.disconnect()
return False | module function_definition identifier parameters identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list for_statement identifier attribute identifier identifier block expression_statement call attribute attribute subscript identifier string string_start string_content string_end identifier identifier argument_list return_statement false | Invalidates the current transport and disconnects all redis connections |
def handle_write(self):
num_sent = self.send(self.write_buffer)
if self.debug:
if self.state is not STATE_NOT_STARTED or options.password is None:
self.print_debug(b'<== ' + self.write_buffer[:num_sent])
self.write_buffer = self.write_buffer[num_sent:] | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier identifier comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end subscript attribute identifier identifier slice identifier expression_statement assignment attribute identifier identifier subscript attribute identifier identifier slice identifier | Let's write as much as we can |
def mark_address(self, addr, size):
i = 0
while i < size:
self._register_map[addr] = True
i += 1 | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier integer while_statement comparison_operator identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier true expression_statement augmented_assignment identifier integer | Marks address as being used in simulator |
def anonymous_required(func=None, url=None):
url = url or "/"
def _dec(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if request.user.is_authenticated():
return redirect(url)
else:
return view_func(request, *args, **kwargs)
return _wrapped_view
if func is None:
return _dec
else:
return _dec(func) | module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier string string_start string_content string_end function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement call attribute attribute identifier identifier identifier argument_list block return_statement call identifier argument_list identifier else_clause block return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier if_statement comparison_operator identifier none block return_statement identifier else_clause block return_statement call identifier argument_list identifier | Required that the user is not logged in. |
def prepare(cls):
if cls._ask_openapi():
napp_path = Path()
tpl_path = SKEL_PATH / 'napp-structure/username/napp'
OpenAPI(napp_path, tpl_path).render_template()
print('Please, update your openapi.yml file.')
sys.exit() | module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier binary_operator identifier string string_start string_content string_end expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list | Prepare NApp to be uploaded by creating openAPI skeleton. |
def word(self, position):
if 0 <= position < len(self.wordlist):
return self.wordlist[position]
else:
log.warn('position "{}" is not in sentence of length "{}"!'.format(position, len(self.wordlist)))
raise IndexError() | module function_definition identifier parameters identifier identifier block if_statement comparison_operator integer identifier call identifier argument_list attribute identifier identifier block return_statement subscript attribute identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call identifier argument_list attribute identifier identifier raise_statement call identifier argument_list | Returns the word instance at the given position in the sentence, None if not found. |
def p2th_wif(self) -> Optional[str]:
if self.id:
return Kutil(network=self.network,
privkey=bytearray.fromhex(self.id)).wif
else:
return None | module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block if_statement attribute identifier identifier block return_statement attribute call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list attribute identifier identifier identifier else_clause block return_statement none | P2TH privkey in WIF format |
def link2html(text):
match = r'\[([^\]]+)\]\(([^)]+)\)'
replace = r'<a href="\2">\1</a>'
return re.sub(match, replace, text) | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier identifier identifier | Turns md links to html |
def aggregate(self):
for report in self.reportset:
printtime('Processing {}'.format(report.split('.')[0]), self.start)
header = '' if report != 'mlst.csv' else 'Strain,Genus,SequenceType,Matches,1,2,3,4,5,6,7\n'
data = ''
with open(os.path.join(self.reportpath, report), 'w') as aggregate:
for sample in self.runmetadata.samples:
try:
with open(os.path.join(sample.general.reportpath, report), 'r') as runreport:
if not header:
header = runreport.readline()
else:
for row in runreport:
if not row.endswith('\n'):
row += '\n'
if row.split(',')[0] != header.split(',')[0]:
data += row
except IOError:
pass
aggregate.write(header)
aggregate.write(data) | module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript call attribute identifier identifier argument_list string string_start string_content string_end integer attribute identifier identifier expression_statement assignment identifier conditional_expression string string_start string_end comparison_operator identifier string string_start string_content string_end string string_start string_content escape_sequence string_end expression_statement assignment identifier string string_start string_end with_statement with_clause with_item as_pattern call identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier attribute attribute identifier identifier identifier block try_statement block with_statement with_clause with_item as_pattern call identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier identifier string string_start string_content string_end as_pattern_target identifier block if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block for_statement identifier identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end if_statement comparison_operator subscript call attribute identifier identifier argument_list string string_start string_content string_end integer subscript call attribute identifier identifier argument_list string string_start string_content string_end integer block expression_statement augmented_assignment identifier identifier except_clause identifier block pass_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier | Aggregate all reports of the same type into a master report |
def span_case(self, i, case):
if self.span_stack:
self.span_stack.pop()
if self.single_stack:
self.single_stack.pop()
self.span_stack.append(case)
count = len(self.span_stack)
self.end_found = False
try:
while not self.end_found:
t = next(i)
if self.use_format and t in _CURLY_BRACKETS:
self.handle_format(t, i)
elif t == '\\':
try:
t = next(i)
self.reference(t, i)
except StopIteration:
self.result.append(t)
raise
else:
self.result.append(self.convert_case(t, case))
if self.end_found or count > len(self.span_stack):
self.end_found = False
break
except StopIteration:
pass
if count == len(self.span_stack):
self.span_stack.pop() | module function_definition identifier parameters identifier identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier false try_statement block while_statement not_operator attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator attribute identifier identifier comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier elif_clause comparison_operator identifier string string_start string_content escape_sequence string_end block try_statement block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier raise_statement else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier if_statement boolean_operator attribute identifier identifier comparison_operator identifier call identifier argument_list attribute identifier identifier block expression_statement assignment attribute identifier identifier false break_statement except_clause identifier block pass_statement if_statement comparison_operator identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list | Uppercase or lowercase the next range of characters until end marker is found. |
def show_lbaas_l7policy(self, l7policy, **_params):
return self.get(self.lbaas_l7policy_path % l7policy,
params=_params) | module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier identifier keyword_argument identifier identifier | Fetches information of a certain listener's L7 policy. |
def pdf_from_post(self):
html = self.request.form.get("html")
style = self.request.form.get("style")
reporthtml = "<html><head>{0}</head><body>{1}</body></html>"
reporthtml = reporthtml.format(style, html)
reporthtml = safe_unicode(reporthtml).encode("utf-8")
pdf_fn = tempfile.mktemp(suffix=".pdf")
pdf_file = createPdf(htmlreport=reporthtml, outfile=pdf_fn)
return pdf_file | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier | Returns a pdf stream with the stickers |
def find(name):
if op.exists(name):
return name
path = op.dirname(__file__) or '.'
paths = [path] + config['include_path']
for path in paths:
filename = op.abspath(op.join(path, name))
if op.exists(filename):
return filename
for d in os.listdir(path):
fullpath = op.abspath(op.join(path, d))
if op.isdir(fullpath):
filename = op.abspath(op.join(fullpath, name))
if op.exists(filename):
return filename
return None | module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list identifier block return_statement identifier expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier binary_operator list identifier subscript identifier string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier if_statement call attribute identifier identifier argument_list identifier block return_statement identifier for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier if_statement call attribute identifier identifier argument_list identifier block return_statement identifier return_statement none | Locate a filename into the shader library. |
def reindex(self):
for i in range(self.rally_count()):
self.rally_points[i].count = self.rally_count()
self.rally_points[i].idx = i
self.last_change = time.time() | module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment attribute subscript attribute identifier identifier identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute subscript attribute identifier identifier identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list | reset counters and indexes |
def check_children(self):
if self._restart_processes is True:
for pid, mapping in six.iteritems(self._process_map):
if not mapping['Process'].is_alive():
log.trace('Process restart of %s', pid)
self.restart_process(pid) | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier true block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement not_operator call attribute subscript identifier string string_start string_content string_end identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier | Check the children once |
def stop_listener_thread(self):
self.should_listen = False
if self.sync_thread:
self.sync_thread.kill()
self.sync_thread.get()
if self._handle_thread is not None:
self._handle_thread.get()
self.sync_thread = None
self._handle_thread = None | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier false if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none | Kills sync_thread greenlet before joining it |
def watch_activations(self, flag):
lib.EnvSetDefruleWatchActivations(self._env, int(flag), self._rule) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier call identifier argument_list identifier attribute identifier identifier | Whether or not the Rule Activations are being watched. |
def files_ondisk(self, file_objs: models.File) -> set:
return set([ file_obj for file_obj in file_objs if Path(file_obj.full_path).is_file() ]) | module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier type identifier block return_statement call identifier argument_list list_comprehension identifier for_in_clause identifier identifier if_clause call attribute call identifier argument_list attribute identifier identifier identifier argument_list | Returns a list of files that are not on disk. |
def init(name, *args, **kwargs):
if name in _TIMEFRAME_CATALOG:
if rapport.config.get_int("rapport", "verbosity") >= 2:
print("Initialize timeframe {0}: {1} {2}".format(name, args, kwargs))
try:
return _TIMEFRAME_CATALOG[name](*args, **kwargs)
except ValueError as e:
print("Failed to initialize timeframe {0}: {1}!".format(name, e), file=sys.stderr)
else:
print("Failed to initialize timeframe {0}: Not in catalog!".format(name), file=sys.stderr)
sys.exit(1) | module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement comparison_operator identifier identifier block if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end integer block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier try_statement block return_statement call subscript identifier identifier argument_list list_splat identifier dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier keyword_argument identifier attribute identifier identifier else_clause block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer | Instantiate a timeframe from the catalog. |
def save(self, fname):
out = etree.tostring(self.root, xml_declaration=True,
standalone=True,
pretty_print=True)
with open(fname, 'wb') as fid:
fid.write(out) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier true keyword_argument identifier true keyword_argument identifier true with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier | Save figure to a file |
def dragMoveEvent(self, event):
if mimedata2url(event.mimeData()):
event.setDropAction(Qt.CopyAction)
event.accept()
else:
event.ignore() | module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list | Allow user to move files |
def render_noderef(self, ontol, n, query_ids=None, **args):
if query_ids is None:
query_ids = []
marker = ""
if n in query_ids:
marker = " * "
label = ontol.label(n)
s = None
if label is not None:
s = '{} ! {}{}'.format(n,
label,
marker)
else:
s = str(n)
if self.config.show_text_definition:
td = ontol.text_definition(n)
if td:
s += ' "{}"'.format(td.val)
return s | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier list expression_statement assignment identifier string string_start string_end if_statement comparison_operator identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier none if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier return_statement identifier | Render a node object |
def player_stats(game_id):
data = mlbgame.stats.player_stats(game_id)
return mlbgame.stats.Stats(data, game_id, True) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier true | Return dictionary of player stats for game matching the game id. |
def dedup(seq):
seen = set()
for item in seq:
if item not in seen:
seen.add(item)
yield item | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement yield identifier | Remove duplicates from a list while keeping order. |
def add_shortcut_to_tooltip(action, context, name):
action.setToolTip(action.toolTip() + ' (%s)' %
get_shortcut(context=context, name=name)) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier | Add the shortcut associated with a given action to its tooltip |
def getDefaultItems(self):
return [
RtiRegItem('HDF-5 file',
'argos.repo.rtiplugins.hdf5.H5pyFileRti',
extensions=['hdf5', 'h5', 'h5e', 'he5', 'nc']),
RtiRegItem('MATLAB file',
'argos.repo.rtiplugins.scipyio.MatlabFileRti',
extensions=['mat']),
RtiRegItem('NetCDF file',
'argos.repo.rtiplugins.ncdf.NcdfFileRti',
extensions=['nc', 'nc4']),
RtiRegItem('NumPy binary file',
'argos.repo.rtiplugins.numpyio.NumpyBinaryFileRti',
extensions=['npy']),
RtiRegItem('NumPy compressed file',
'argos.repo.rtiplugins.numpyio.NumpyCompressedFileRti',
extensions=['npz']),
RtiRegItem('NumPy text file',
'argos.repo.rtiplugins.numpyio.NumpyTextFileRti',
extensions=['dat']),
RtiRegItem('IDL save file',
'argos.repo.rtiplugins.scipyio.IdlSaveFileRti',
extensions=['sav']),
RtiRegItem('Pandas CSV file',
'argos.repo.rtiplugins.pandasio.PandasCsvFileRti',
extensions=['csv']),
RtiRegItem('Pillow image',
'argos.repo.rtiplugins.pillowio.PillowFileRti',
extensions=['bmp', 'eps', 'im', 'gif', 'jpg', 'jpeg', 'msp', 'pcx',
'png', 'ppm', 'spi', 'tif', 'tiff', 'xbm', 'xv']),
RtiRegItem('Wav file',
'argos.repo.rtiplugins.scipyio.WavFileRti',
extensions=['wav'])] | module function_definition identifier parameters identifier block return_statement list call identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier 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 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 keyword_argument identifier list 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 keyword_argument identifier 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 keyword_argument identifier list 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 keyword_argument identifier list 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 keyword_argument identifier list 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 keyword_argument identifier list 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 keyword_argument identifier list 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 keyword_argument identifier 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 string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end 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 call identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier list string string_start string_content string_end | Returns a list with the default plugins in the repo tree item registry. |
def DEFINE_string(
name, default, help, flag_values=_flagvalues.FLAGS, **args):
parser = _argument_parser.ArgumentParser()
serializer = _argument_parser.ArgumentSerializer()
DEFINE(parser, name, default, help, flag_values, serializer, **args) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier attribute identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list identifier identifier identifier identifier identifier identifier dictionary_splat identifier | Registers a flag whose value can be any string. |
def sorted_enums(self) -> List[Tuple[str, int]]:
return sorted(self.enum.items(), key=lambda x: x[1]) | module function_definition identifier parameters identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type identifier type identifier block return_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier subscript identifier integer | Return list of enum items sorted by value. |
def convert_2_utc(self, datetime_, timezone):
datetime_ = self.tz_mapper[timezone].localize(datetime_)
return datetime_.astimezone(pytz.UTC) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute subscript attribute identifier identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier | convert to datetime to UTC offset. |
def display_message(self, clear, beep, timeout, line1, line2):
self._elk.send(
dm_encode(self._index, clear, beep, timeout, line1, line2)
) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list attribute identifier identifier identifier identifier identifier identifier identifier | Display a message on all of the keypads in this area. |
def reset_stats(self):
self.stats = pstats.Stats(Profile())
self.ncalls = 0
self.skipped = 0 | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call identifier argument_list expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer | Reset accumulated profiler statistics. |
def paste_clipboard(self, event):
log.critical("paste clipboard")
clipboard = self.root.clipboard_get()
for line in clipboard.splitlines():
log.critical("paste line: %s", repr(line))
self.add_user_input(line + "\r") | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content escape_sequence string_end | Send the clipboard content as user input to the CPU. |
def delete(self):
if self.fullname != "":
try:
os.remove(self.fullname)
except IOError:
print("Cant delete ",self.fullname) | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_end block try_statement block expression_statement call attribute identifier identifier argument_list attribute identifier identifier except_clause identifier block expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier | delete a file, don't really care if it doesn't exist |
def _create_clock(self):
trading_o_and_c = self.trading_calendar.schedule.ix[
self.sim_params.sessions]
market_closes = trading_o_and_c['market_close']
minutely_emission = False
if self.sim_params.data_frequency == 'minute':
market_opens = trading_o_and_c['market_open']
minutely_emission = self.sim_params.emission_rate == "minute"
execution_opens = \
self.trading_calendar.execution_time_from_open(market_opens)
execution_closes = \
self.trading_calendar.execution_time_from_close(market_closes)
else:
execution_closes = \
self.trading_calendar.execution_time_from_close(market_closes)
execution_opens = execution_closes
before_trading_start_minutes = days_at_time(
self.sim_params.sessions,
time(8, 45),
"US/Eastern"
)
return MinuteSimulationClock(
self.sim_params.sessions,
execution_opens,
execution_closes,
before_trading_start_minutes,
minute_emission=minutely_emission,
) | module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute attribute attribute identifier identifier identifier identifier attribute attribute identifier identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier false if_statement comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier line_continuation call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier line_continuation call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment identifier line_continuation call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier call identifier argument_list integer integer string string_start string_content string_end return_statement call identifier argument_list attribute attribute identifier identifier identifier identifier identifier identifier keyword_argument identifier identifier | If the clock property is not set, then create one based on frequency. |
def smart_import(mpath):
try:
rest = __import__(mpath)
except ImportError:
split = mpath.split('.')
rest = smart_import('.'.join(split[:-1]))
rest = getattr(rest, split[-1])
return rest | module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript identifier slice unary_operator integer expression_statement assignment identifier call identifier argument_list identifier subscript identifier unary_operator integer return_statement identifier | Given a path smart_import will import the module and return the attr reffered to. |
def parse_datetime(dt):
d = datetime.strptime(dt[:-1], ISOFORMAT)
if dt[-1:] == 'Z':
return timezone('utc').localize(d)
else:
return d | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier slice unary_operator integer identifier if_statement comparison_operator subscript identifier slice unary_operator integer string string_start string_content string_end block return_statement call attribute call identifier argument_list string string_start string_content string_end identifier argument_list identifier else_clause block return_statement identifier | Parse an ISO datetime, which Python does buggily. |
def main(unusedargv):
del unusedargv
bt_table = (bigtable
.Client(FLAGS.cbt_project, admin=True)
.instance(FLAGS.cbt_instance)
.table(FLAGS.cbt_table))
assert bt_table.exists(), "Table doesn't exist"
last_game = latest_game_number(bt_table)
print("eval_game_counter:", last_game)
print()
existing_paths = read_existing_paths(bt_table)
print("Found {} existing".format(len(existing_paths)))
if existing_paths:
duplicates = Counter(existing_paths)
existing_paths = set(existing_paths)
for k, v in duplicates.most_common():
if v == 1:
break
print("{}x{}".format(v, k))
print("\tmin:", min(existing_paths))
print("\tmax:", max(existing_paths))
print()
data = read_games(FLAGS.sgf_glob, existing_paths)
if data:
write_eval_records(bt_table, data, last_game) | module function_definition identifier parameters identifier block delete_statement identifier expression_statement assignment identifier parenthesized_expression call attribute call attribute call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier true identifier argument_list attribute identifier identifier identifier argument_list attribute identifier identifier assert_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end identifier expression_statement call identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier integer block break_statement expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement call identifier argument_list string string_start string_content escape_sequence string_end call identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content escape_sequence string_end call identifier argument_list identifier expression_statement call identifier argument_list expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier if_statement identifier block expression_statement call identifier argument_list identifier identifier identifier | All of the magic together. |
def _initialize_non_fluents(self):
non_fluents = self.rddl.domain.non_fluents
initializer = self.rddl.non_fluents.init_non_fluent
self.non_fluents = self._initialize_pvariables(
non_fluents,
self.rddl.domain.non_fluent_ordering,
initializer)
return self.non_fluents | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier attribute attribute attribute identifier identifier identifier identifier identifier return_statement attribute identifier identifier | Returns the non-fluents instantiated. |
def __destroyLockedView(self):
if self._lockedView:
self._lockedView.close()
self._lockedView.deleteLater()
self._lockedView = None | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none | Destroys the locked view from this widget. |
def diff_many(models1, models2, migrator=None, reverse=False):
models1 = pw.sort_models(models1)
models2 = pw.sort_models(models2)
if reverse:
models1 = reversed(models1)
models2 = reversed(models2)
models1 = OrderedDict([(m._meta.name, m) for m in models1])
models2 = OrderedDict([(m._meta.name, m) for m in models2])
changes = []
for name, model1 in models1.items():
if name not in models2:
continue
changes += diff_one(model1, models2[name], migrator=migrator)
for name in [m for m in models1 if m not in models2]:
changes.append(create_model(models1[name], migrator=migrator))
for name in [m for m in models2 if m not in models1]:
changes.append(remove_model(models2[name]))
return changes | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list list_comprehension tuple attribute attribute identifier identifier identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list list_comprehension tuple attribute attribute identifier identifier identifier identifier for_in_clause identifier identifier expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block continue_statement expression_statement augmented_assignment identifier call identifier argument_list identifier subscript identifier identifier keyword_argument identifier identifier for_statement identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list subscript identifier identifier keyword_argument identifier identifier for_statement identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list subscript identifier identifier return_statement identifier | Calculate changes for migrations from models2 to models1. |
def _repr_html_(self):
TileServer.run_tileserver(self, self.footprint())
capture = "raster: %s" % self._filename
mp = TileServer.folium_client(self, self.footprint(), capture=capture)
return mp._repr_html_() | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list | Required for jupyter notebook to show raster as an interactive map. |
def resource_of_node(resources, node):
for resource in resources:
model = getattr(resource, 'model', None)
if type(node) == model:
return resource
return BasePageResource | module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none if_statement comparison_operator call identifier argument_list identifier identifier block return_statement identifier return_statement identifier | Returns resource of node. |
def check_whitelist(values):
import os
import tldextract
whitelisted = list()
for name in ['alexa.txt', 'cisco.txt']:
config_path = os.path.expanduser('~/.config/blockade')
file_path = os.path.join(config_path, name)
whitelisted += [x.strip() for x in open(file_path, 'r').readlines()]
output = list()
for item in values:
ext = tldextract.extract(item)
if ext.registered_domain in whitelisted:
continue
output.append(item)
return output | module function_definition identifier parameters identifier block import_statement dotted_name identifier import_statement dotted_name identifier expression_statement assignment identifier call identifier argument_list for_statement identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement augmented_assignment identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier identifier block continue_statement expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Check the indicators against known whitelists. |
def update(self, percent=None, text=None):
if percent is not None:
self.percent = percent
if text is not None:
self.message = text
super().update() | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute call identifier argument_list identifier argument_list | Update the progress bar percentage and message. |
def _generate_actual_grp_constraints(network_constraints):
if 'constraints' not in network_constraints:
return []
constraints = network_constraints['constraints']
actual = []
for desc in constraints:
descs = _expand_description(desc)
for desc in descs:
actual.append(desc)
if 'symetric' in desc:
sym = desc.copy()
sym['src'] = desc['dst']
sym['dst'] = desc['src']
actual.append(sym)
return actual | module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end identifier block return_statement list expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Generate the user specified constraints |
def _calc_odds(self):
def recur(val, h, dice, combinations):
for pip in dice[0]:
tot = val + pip
if len(dice) > 1:
combinations = recur(tot, h, dice[1:], combinations)
else:
combinations += 1
h[tot] = h.get(tot, 0) + 1
return combinations
if self.summable:
start = 0
else:
start = ''
h = dict()
funky = [d.values for d in self._dice]
combinations = recur(start, h, funky, 0.0)
self._odds = [(roll, h[roll], h[roll] / combinations) for roll in h.keys()]
self._odds.sort() | module function_definition identifier parameters identifier block function_definition identifier parameters identifier identifier identifier identifier block for_statement identifier subscript identifier integer block expression_statement assignment identifier binary_operator identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call identifier argument_list identifier identifier subscript identifier slice integer identifier else_clause block expression_statement augmented_assignment identifier integer expression_statement assignment subscript identifier identifier binary_operator call attribute identifier identifier argument_list identifier integer integer return_statement identifier if_statement attribute identifier identifier block expression_statement assignment identifier integer else_clause block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier float expression_statement assignment attribute identifier identifier list_comprehension tuple identifier subscript identifier identifier binary_operator subscript identifier identifier identifier for_in_clause identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list | Calculates the absolute probability of all posible rolls. |
def publish(self):
if self.published is False:
self.published = True
else:
raise Warning(self.title + ' is already published.') | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier false block expression_statement assignment attribute identifier identifier true else_clause block raise_statement call identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end | Mark an episode as published. |
def _holiday_entry(self):
holidays_list = self.get_holidays_for_year()
holidays_list = [
holiday for holiday, holiday_hdate in holidays_list if
holiday_hdate.hdate == self.hdate
]
assert len(holidays_list) <= 1
return holidays_list[0] if holidays_list else htables.HOLIDAYS[0] | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier list_comprehension identifier for_in_clause pattern_list identifier identifier identifier if_clause comparison_operator attribute identifier identifier attribute identifier identifier assert_statement comparison_operator call identifier argument_list identifier integer return_statement conditional_expression subscript identifier integer identifier subscript attribute identifier identifier integer | Return the abstract holiday information from holidays table. |
def log_to_history(logger, name):
def log_to_history_decorator(method):
def l2h_method(self, ri):
history_header = fits.Header()
fh = FITSHistoryHandler(history_header)
fh.setLevel(logging.INFO)
logger.addHandler(fh)
try:
result = method(self, ri)
field = getattr(result, name, None)
if field:
with field.open() as hdulist:
hdr = hdulist[0].header
hdr.extend(history_header.cards)
return result
finally:
logger.removeHandler(fh)
return l2h_method
return log_to_history_decorator | module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier none if_statement identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block expression_statement assignment identifier attribute subscript identifier integer identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier finally_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier return_statement identifier | Decorate function, adding a logger handler stored in FITS. |
def find(self, text):
for key, value in self:
if (text in key) or (text in value):
print(key, value) | module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier identifier block if_statement boolean_operator parenthesized_expression comparison_operator identifier identifier parenthesized_expression comparison_operator identifier identifier block expression_statement call identifier argument_list identifier identifier | Print all substitutions that include the given text string. |
def __identify_user(self, username, csrf):
data = {
"username": username,
"csrf": csrf,
"apiClient": "WEB",
"bindDevice": "false",
"skipLinkAccount": "false",
"redirectTo": "",
"skipFirstUse": "",
"referrerId": "",
}
r = self.post("/login/identifyUser", data)
if r.status_code == requests.codes.ok:
result = r.json()
new_csrf = getSpHeaderValue(result, CSRF_KEY)
auth_level = getSpHeaderValue(result, AUTH_LEVEL_KEY)
return (new_csrf, auth_level)
return (None, None) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement tuple identifier identifier return_statement tuple none none | Returns reusable CSRF code and the auth level as a 2-tuple |
def aap_to_bp (ant1, ant2, pol):
if ant1 < 0:
raise ValueError ('first antenna is below 0: %s' % ant1)
if ant2 < ant1:
raise ValueError ('second antenna is below first: %s' % ant2)
if pol < 1 or pol > 12:
raise ValueError ('illegal polarization code %s' % pol)
fps = _pol_to_fpol[pol]
ap1 = (ant1 << 3) + ((fps >> 4) & 0x07)
ap2 = (ant2 << 3) + (fps & 0x07)
return ap1, ap2 | module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier integer block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier integer block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier integer parenthesized_expression binary_operator parenthesized_expression binary_operator identifier integer integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier integer parenthesized_expression binary_operator identifier integer return_statement expression_list identifier identifier | Create a basepol from antenna numbers and a CASA polarization code. |
def ServiceAccountCredentialsFromFile(filename, scopes, user_agent=None):
filename = os.path.expanduser(filename)
if oauth2client.__version__ > '1.5.2':
credentials = (
service_account.ServiceAccountCredentials.from_json_keyfile_name(
filename, scopes=scopes))
if credentials is not None:
if user_agent is not None:
credentials.user_agent = user_agent
return credentials
else:
with open(filename) as keyfile:
service_account_info = json.load(keyfile)
account_type = service_account_info.get('type')
if account_type != oauth2client.client.SERVICE_ACCOUNT:
raise exceptions.CredentialsError(
'Invalid service account credentials: %s' % (filename,))
credentials = service_account._ServiceAccountCredentials(
service_account_id=service_account_info['client_id'],
service_account_email=service_account_info['client_email'],
private_key_id=service_account_info['private_key_id'],
private_key_pkcs8_text=service_account_info['private_key'],
scopes=scopes, user_agent=user_agent)
return credentials | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier parenthesized_expression call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier if_statement comparison_operator identifier none block if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier identifier return_statement identifier else_clause block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier attribute attribute identifier identifier identifier block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier | Use the credentials in filename to create a token for scopes. |
def getContacts(self, only_active=True):
contacts = self.objectValues("Contact")
if only_active:
contacts = filter(api.is_active, contacts)
return contacts | module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier return_statement identifier | Return an array containing the contacts from this Client |
def watch(ctx):
watcher = Watcher(ctx)
watcher.watch_directory(
path='{pkg.source_less}', ext='.less',
action=lambda e: build(ctx, less=True)
)
watcher.watch_directory(
path='{pkg.source_js}', ext='.jsx',
action=lambda e: build(ctx, js=True)
)
watcher.watch_directory(
path='{pkg.docs}', ext='.rst',
action=lambda e: build(ctx, docs=True)
)
watcher.start() | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier lambda lambda_parameters identifier call identifier argument_list identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier lambda lambda_parameters identifier call identifier argument_list identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier lambda lambda_parameters identifier call identifier argument_list identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list | Automatically run build whenever a relevant file changes. |
def close_all(self):
for host, conns in self._cm.get_all().items():
for h in conns:
self._cm.remove(h)
h.close() | module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list block for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list | close all open connections |
def cancel(self):
if self.__process.is_alive():
self.__process.terminate()
_raise_exception(self.__timeout_exception, self.__exception_message) | module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier | Terminate any possible execution of the embedded function. |
def lock(self):
self.update()
self.execute_operations(False)
self._lock = True
return self | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list false expression_statement assignment attribute identifier identifier true return_statement identifier | Prepare the installer for locking only. |
def write_branch_data(self, file, padding=" "):
attrs = ['%s="%s"' % (k,v) for k,v in self.branch_attr.iteritems()]
attr_str = ", ".join(attrs)
for br in self.case.branches:
file.write("%s%s -> %s [%s];\n" % \
(padding, br.from_bus.name, br.to_bus.name, attr_str)) | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier list_comprehension binary_operator string string_start string_content string_end tuple identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier for_statement identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end line_continuation tuple identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier identifier | Writes branch data in Graphviz DOT language. |
def waitResult(self):
self.thread.execute_queue.join()
try:
e = self.thread.exception_queue[threading.get_ident()].get_nowait()
except queue.Empty:
return self.thread.result_queue[threading.get_ident()].get_nowait()
else:
raise e | module function_definition identifier parameters identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute subscript attribute attribute identifier identifier identifier call attribute identifier identifier argument_list identifier argument_list except_clause attribute identifier identifier block return_statement call attribute subscript attribute attribute identifier identifier identifier call attribute identifier identifier argument_list identifier argument_list else_clause block raise_statement identifier | Wait for the execution of the last enqueued job to be done, and return the result or raise an exception. |
def _slice_vcf_chr21(vcf_file, out_dir):
tmp_file = os.path.join(out_dir, "chr21_qsignature.vcf")
if not utils.file_exists(tmp_file):
cmd = ("grep chr21 {vcf_file} > {tmp_file}").format(**locals())
out = subprocess.check_output(cmd, shell=True)
return tmp_file | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute parenthesized_expression string string_start string_content string_end identifier argument_list dictionary_splat call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true return_statement identifier | Slice chr21 of qsignature SNPs to reduce computation time |
def _generate_html(data, out):
print('<html>', file=out)
print('<body>', file=out)
_generate_html_table(data, out, 0)
print('</body>', file=out)
print('</html>', file=out) | module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement call identifier argument_list identifier identifier integer expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier | Generate report data as HTML |
def create_default_config():
import codecs
config = ConfigParser.SafeConfigParser()
config.readfp(StringIO(DEFAULT_CONFIG))
filename = get_user_config_filename()
if not os.path.exists(filename):
from wizard import setup_wizard
setup_wizard(config)
else:
try:
fi = codecs.open(filename, 'r', encoding='utf-8')
config.readfp(fi)
finally:
fi.close()
return config | module function_definition identifier parameters block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement call identifier argument_list identifier else_clause block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier finally_clause block expression_statement call attribute identifier identifier argument_list return_statement identifier | Create default ConfigParser instance |
def _get_chart_info(df, vtype, cat, prep, callers):
maxval_raw = max(list(df["value.floor"]))
curdf = df[(df["variant.type"] == vtype) & (df["category"] == cat)
& (df["bamprep"] == prep)]
vals = []
labels = []
for c in callers:
row = curdf[df["caller"] == c]
if len(row) > 0:
vals.append(list(row["value.floor"])[0])
labels.append(list(row["value"])[0])
else:
vals.append(1)
labels.append("")
return vals, labels, maxval_raw | module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier binary_operator binary_operator parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end identifier parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end identifier parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier subscript identifier comparison_operator subscript identifier string string_start string_content string_end identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list subscript call identifier argument_list subscript identifier string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list subscript call identifier argument_list subscript identifier string string_start string_content string_end integer else_clause block expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list string string_start string_end return_statement expression_list identifier identifier identifier | Retrieve values for a specific variant type, category and prep method. |
def target_to_ipv6_long(target):
splitted = target.split('-')
if len(splitted) != 2:
return None
try:
start_packed = inet_pton(socket.AF_INET6, splitted[0])
end_packed = inet_pton(socket.AF_INET6, splitted[1])
except socket.error:
return None
if end_packed < start_packed:
return None
return ipv6_range_to_list(start_packed, end_packed) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block return_statement none try_statement block expression_statement assignment identifier call identifier argument_list attribute identifier identifier subscript identifier integer expression_statement assignment identifier call identifier argument_list attribute identifier identifier subscript identifier integer except_clause attribute identifier identifier block return_statement none if_statement comparison_operator identifier identifier block return_statement none return_statement call identifier argument_list identifier identifier | Attempt to return a IPv6 long-range list from a target string. |
def lgamma(x, context=None):
return _apply_function_in_current_context(
BigFloat,
lambda rop, op, rnd: mpfr.mpfr_lgamma(rop, op, rnd)[0],
(BigFloat._implicit_convert(x),),
context,
) | module function_definition identifier parameters identifier default_parameter identifier none block return_statement call identifier argument_list identifier lambda lambda_parameters identifier identifier identifier subscript call attribute identifier identifier argument_list identifier identifier identifier integer tuple call attribute identifier identifier argument_list identifier identifier | Return the logarithm of the absolute value of the Gamma function at x. |
def _add_zoho_token(
self, uri, http_method="GET", body=None, headers=None, token_placement=None
):
headers = self.prepare_zoho_headers(self.access_token, headers)
return uri, headers, body | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier return_statement expression_list identifier identifier identifier | Add a zoho token to the request uri, body or authorization header. follows bearer pattern |
def _learner_interpret(learn:Learner, ds_type:DatasetType=DatasetType.Valid):
"Create a `ClassificationInterpretation` object from `learner` on `ds_type` with `tta`."
return ClassificationInterpretation.from_learner(learn, ds_type=ds_type) | module function_definition identifier parameters typed_parameter identifier type identifier typed_default_parameter identifier type identifier attribute identifier identifier block expression_statement string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier | Create a `ClassificationInterpretation` object from `learner` on `ds_type` with `tta`. |
def import_setting(self):
LOGGER.debug('Import button clicked')
home_directory = os.path.expanduser('~')
file_path, __ = QFileDialog.getOpenFileName(
self,
self.tr('Import InaSAFE settings'),
home_directory,
self.tr('JSON File (*.json)'))
if file_path:
title = tr('Import InaSAFE Settings.')
question = tr(
'This action will replace your current InaSAFE settings with '
'the setting from the file. This action is not reversible. '
'Are you sure to import InaSAFE Setting?')
answer = QMessageBox.question(
self, title, question, QMessageBox.Yes | QMessageBox.No)
if answer == QMessageBox.Yes:
LOGGER.debug('Import from %s' % file_path)
import_setting(file_path) | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier binary_operator attribute identifier identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call identifier argument_list identifier | Import setting to a file. |
def calculate_input(self, buffer):
if TriggerMode.ABBREVIATION in self.modes:
if self._should_trigger_abbreviation(buffer):
if self.immediate:
return len(self._get_trigger_abbreviation(buffer))
else:
return len(self._get_trigger_abbreviation(buffer)) + 1
if TriggerMode.HOTKEY in self.modes:
if buffer == '':
return len(self.modifiers) + 1
return self.parent.calculate_input(buffer) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block if_statement call attribute identifier identifier argument_list identifier block if_statement attribute identifier identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list identifier else_clause block return_statement binary_operator call identifier argument_list call attribute identifier identifier argument_list identifier integer if_statement comparison_operator attribute identifier identifier attribute identifier identifier block if_statement comparison_operator identifier string string_start string_end block return_statement binary_operator call identifier argument_list attribute identifier identifier integer return_statement call attribute attribute identifier identifier identifier argument_list identifier | Calculate how many keystrokes were used in triggering this phrase. |
async def abort(self):
state = await self.state()
res = await self.call("X_Abort", MasterSessionID=state.MasterSessionID)
return res | module function_definition identifier parameters identifier block expression_statement assignment identifier await call attribute identifier identifier argument_list expression_statement assignment identifier await call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier return_statement identifier | Abort current group session. |
def graph_memoized(func):
from ..compat import tfv1
GRAPH_ARG_NAME = '__IMPOSSIBLE_NAME_FOR_YOU__'
@memoized
def func_with_graph_arg(*args, **kwargs):
kwargs.pop(GRAPH_ARG_NAME)
return func(*args, **kwargs)
@functools.wraps(func)
def wrapper(*args, **kwargs):
assert GRAPH_ARG_NAME not in kwargs, "No Way!!"
graph = tfv1.get_default_graph()
kwargs[GRAPH_ARG_NAME] = graph
return func_with_graph_arg(*args, **kwargs)
return wrapper | module function_definition identifier parameters identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement assignment identifier string string_start string_content string_end decorated_definition decorator identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list list_splat identifier dictionary_splat identifier decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block assert_statement comparison_operator identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier identifier identifier return_statement call identifier argument_list list_splat identifier dictionary_splat identifier return_statement identifier | Like memoized, but keep one cache per default graph. |
def register(
self,
app: 'Quart',
first_registration: bool,
*,
url_prefix: Optional[str]=None,
) -> None:
state = self.make_setup_state(app, first_registration, url_prefix=url_prefix)
if self.has_static_folder:
state.add_url_rule(
self.static_url_path + '/<path:filename>',
view_func=self.send_static_file, endpoint='static',
)
for func in self.deferred_functions:
func(state) | module function_definition identifier parameters identifier typed_parameter identifier type string string_start string_content string_end typed_parameter identifier type identifier keyword_separator typed_default_parameter identifier type generic_type identifier type_parameter type identifier none type none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list identifier | Register this blueprint on the app given. |
def delete_job(self, job_name):
logger.debug('Deleting job {0}'.format(job_name))
for idx, job in enumerate(self.jobs):
if job.name == job_name:
self.backend.delete_job(job.job_id)
del self.jobs[idx]
self.commit()
return
raise DagobahError('no job with name %s exists' % job_name) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier delete_statement subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list return_statement raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier | Delete a job by name, or error out if no such job exists. |
def _clean(c):
if isdir(c.sphinx.target):
rmtree(c.sphinx.target) | module function_definition identifier parameters identifier block if_statement call identifier argument_list attribute attribute identifier identifier identifier block expression_statement call identifier argument_list attribute attribute identifier identifier identifier | Nuke docs build target directory so next build is clean. |
def fmt_account(account, title=None):
if title is None:
title = account.__class__.__name__
title = '{} ({} causal link{})'.format(
title, len(account), '' if len(account) == 1 else 's')
body = ''
body += 'Irreducible effects\n'
body += '\n'.join(fmt_ac_ria(m) for m in account.irreducible_effects)
body += '\nIrreducible causes\n'
body += '\n'.join(fmt_ac_ria(m) for m in account.irreducible_causes)
return '\n' + header(title, body, under_char='*') | module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier call identifier argument_list identifier conditional_expression string string_start string_end comparison_operator call identifier argument_list identifier integer string string_start string_content string_end expression_statement assignment identifier string string_start string_end expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end expression_statement augmented_assignment identifier call attribute string string_start string_content escape_sequence string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier attribute identifier identifier expression_statement augmented_assignment identifier string string_start string_content escape_sequence escape_sequence string_end expression_statement augmented_assignment identifier call attribute string string_start string_content escape_sequence string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier attribute identifier identifier return_statement binary_operator string string_start string_content escape_sequence string_end call identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end | Format an Account or a DirectedAccount. |
def gaussian(freq, freq0, sigma, amp, offset, drift):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
return (amp * np.exp(- ((freq - freq0)**2) / (sigma**2) ) +
drift * freq + offset) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block with_statement with_clause with_item call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement parenthesized_expression binary_operator binary_operator binary_operator identifier call attribute identifier identifier argument_list binary_operator unary_operator parenthesized_expression binary_operator parenthesized_expression binary_operator identifier identifier integer parenthesized_expression binary_operator identifier integer binary_operator identifier identifier identifier | A Gaussian function with flexible offset, drift and amplitude |
def _get_from_send_queue(self):
try:
packet = self.transmit.get(block=False)
self.logger.info('Sending packet')
self.logger.debug(packet)
return packet
except queue.Empty:
pass
return None | module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier false expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier except_clause attribute identifier identifier block pass_statement return_statement none | Get message from send queue, if one exists |
def _write(self, what):
try:
open(self.pipefile, "a").write(what)
except:
print("Error writing to %s:" % self.pipefile)
traceback.print_exc() | module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier argument_list identifier except_clause block expression_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list | writes something to the Purr pipe |
def one_of(*args):
"Verifies that only one of the arguments is not None"
for i, arg in enumerate(args):
if arg is not None:
for argh in args[i+1:]:
if argh is not None:
raise OperationError("Too many parameters")
else:
return
raise OperationError("Insufficient parameters") | module function_definition identifier parameters list_splat_pattern identifier block expression_statement string string_start string_content string_end for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator identifier none block for_statement identifier subscript identifier slice binary_operator identifier integer block if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end else_clause block return_statement raise_statement call identifier argument_list string string_start string_content string_end | Verifies that only one of the arguments is not None |
def heptad_register(self):
base_reg = 'abcdefg'
exp_base = base_reg * (self.cc_len//7+2)
ave_ca_layers = self.calc_average_parameters(self.ca_layers)[0][:-1]
reg_fit = fit_heptad_register(ave_ca_layers)
hep_pos = reg_fit[0][0]
return exp_base[hep_pos:hep_pos+self.cc_len], reg_fit[0][1:] | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator binary_operator attribute identifier identifier integer integer expression_statement assignment identifier subscript subscript call attribute identifier identifier argument_list attribute identifier identifier integer slice unary_operator integer expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier subscript subscript identifier integer integer return_statement expression_list subscript identifier slice identifier binary_operator identifier attribute identifier identifier subscript subscript identifier integer slice integer | Returns the calculated register of the coiled coil and the fit quality. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.