code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def unused(self, _dict):
for key, value in _dict.items():
if value is None:
del _dict[key]
return _dict | module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier none block delete_statement subscript identifier identifier return_statement identifier | Remove empty parameters from the dict |
def delete_all_but_self(self):
prefix = self.settings.alias
name = self.settings.index
if prefix == name:
Log.note("{{index_name}} will not be deleted", index_name= prefix)
for a in self.cluster.get_aliases():
if re.match(re.escape(prefix) + "\\d{8}_\\d{6}", a.index) and a.index != name:
self.cluster.delete_index(a.index) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement boolean_operator call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list identifier string string_start string_content escape_sequence escape_sequence string_end attribute identifier identifier comparison_operator attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier | DELETE ALL INDEXES WITH GIVEN PREFIX, EXCEPT name |
def _slice(self, view):
if self._data is not None:
return self._data[view]
return self._proxy.get_view(self.id, view) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block return_statement subscript attribute identifier identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier | Send view to remote server and do slicing there. |
def validate_link(link_data):
from django.apps import apps
try:
Model = apps.get_model(*link_data['model'].split('.'))
Model.objects.get(pk=link_data['pk'])
except Model.DoesNotExist:
raise ValidationError(_("Unable to link onto '{0}'.").format(Model.__name__)) | module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list list_splat call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end except_clause attribute identifier identifier block raise_statement call identifier argument_list call attribute call identifier argument_list string string_start string_content string_end identifier argument_list attribute identifier identifier | Check if the given model exists, otherwise raise a Validation error |
def parse_pseudo_open(self, sel, name, has_selector, iselector, index):
flags = FLG_PSEUDO | FLG_OPEN
if name == ':not':
flags |= FLG_NOT
if name == ':has':
flags |= FLG_RELATIVE
sel.selectors.append(self.parse_selectors(iselector, index, flags))
has_selector = True
return has_selector | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier binary_operator identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement augmented_assignment identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement augmented_assignment identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier true return_statement identifier | Parse pseudo with opening bracket. |
def check_hex_chain(chain):
return codecs.encode(check_chain([(codecs.decode(i[0], 'hex_codec'), i[1]) for i in chain]), 'hex_codec') | module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list call identifier argument_list list_comprehension tuple call attribute identifier identifier argument_list subscript identifier integer string string_start string_content string_end subscript identifier integer for_in_clause identifier identifier string string_start string_content string_end | Verify a merkle chain, with hashes hex encoded, to see if the Merkle root can be reproduced. |
def dispatch_request(self, *args, **kwargs):
self.args = args
self.kwargs = kwargs
self.meth = request.method.lower()
self.resource = current_app.blueprints.get(request.blueprint, None)
if not any([self.meth in self.methods, self.meth.upper() in self.methods]):
return self.return_error(405)
self.process_before_request_hooks()
resp = super(Endpoint, self).dispatch_request(*args, **kwargs)
resp = self.make_response(resp)
resp = self.process_after_request_hooks(resp)
return resp | module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier none if_statement not_operator call identifier argument_list list comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block return_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier | Dispatch the incoming HTTP request to the appropriate handler. |
def prepare_notes(self, *notes, **keyword_notes):
__partial = keyword_notes.pop('__partial', False)
args = tuple(self.get(note) for note in notes)
kwargs = {}
for arg in keyword_notes:
note = keyword_notes[arg]
if isinstance(note, tuple) and len(note) == 2 and note[0] == MAYBE:
try:
kwargs[arg] = self.get(note[1])
except LookupError:
continue
elif __partial:
try:
kwargs[arg] = self.get(note)
except LookupError:
continue
else:
kwargs[arg] = self.get(note)
return args, kwargs | module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier call identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement boolean_operator boolean_operator call identifier argument_list identifier identifier comparison_operator call identifier argument_list identifier integer comparison_operator subscript identifier integer identifier block try_statement block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list subscript identifier integer except_clause identifier block continue_statement elif_clause identifier block try_statement block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier except_clause identifier block continue_statement else_clause block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier return_statement expression_list identifier identifier | Get injection values for all given notes. |
def create(ctx, data):
swag = create_swag_from_ctx(ctx)
data = json.loads(data.read())
for account in data:
swag.create(account, dry_run=ctx.dry_run) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier | Create a new SWAG item. |
def setImageMode(self):
if self._version_server == 3.889:
self.setPixelFormat(
bpp = 16, depth = 16, bigendian = 0, truecolor = 1,
redmax = 31, greenmax = 63, bluemax = 31,
redshift = 11, greenshift = 5, blueshift = 0
)
self.image_mode = "BGR;16"
elif (self.truecolor and (not self.bigendian) and self.depth == 24
and self.redmax == 255 and self.greenmax == 255 and self.bluemax == 255):
pixel = ["X"] * self.bypp
offsets = [offset // 8 for offset in (self.redshift, self.greenshift, self.blueshift)]
for offset, color in zip(offsets, "RGB"):
pixel[offset] = color
self.image_mode = "".join(pixel)
else:
self.setPixelFormat() | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier float block expression_statement call attribute identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier integer expression_statement assignment attribute identifier identifier string string_start string_content string_end elif_clause parenthesized_expression boolean_operator boolean_operator boolean_operator boolean_operator boolean_operator attribute identifier identifier parenthesized_expression not_operator attribute identifier identifier comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier integer block expression_statement assignment identifier binary_operator list string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier list_comprehension binary_operator identifier integer for_in_clause identifier tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment subscript identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute string string_start string_end identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list | Extracts color ordering and 24 vs. 32 bpp info out of the pixel format information |
def play_env_problem_randomly(env_problem,
num_steps):
env_problem.reset()
for _ in range(num_steps):
actions = np.stack([env_problem.action_space.sample() for _ in range(
env_problem.batch_size)])
_, _, dones, _ = env_problem.step(actions)
env_problem.reset(indices=done_indices(dones)) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension call attribute attribute identifier identifier identifier argument_list for_in_clause identifier call identifier argument_list attribute identifier identifier expression_statement assignment pattern_list identifier identifier identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier | Plays the env problem by randomly sampling actions for `num_steps`. |
def encode(x, x_space, hparams, name):
with tf.variable_scope(name):
(encoder_input, encoder_self_attention_bias,
ed) = transformer.transformer_prepare_encoder(x, x_space, hparams)
encoder_input = tf.nn.dropout(encoder_input, 1.0 - hparams.dropout)
return transformer.transformer_encoder(
encoder_input, encoder_self_attention_bias, hparams), ed | module function_definition identifier parameters identifier identifier identifier identifier block with_statement with_clause with_item call attribute identifier identifier argument_list identifier block expression_statement assignment tuple_pattern identifier identifier identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator float attribute identifier identifier return_statement expression_list call attribute identifier identifier argument_list identifier identifier identifier identifier | Transformer preparations and encoder. |
def create_query_constraint():
op = oneOf("= < > >= <= != <>", caseless=True).setName("operator")
basic_constraint = (var + op + var_val).setResultsName("operator")
between = (
var + Suppress(upkey("between")) + value + Suppress(and_) + value
).setResultsName("between")
is_in = (var + Suppress(upkey("in")) + set_).setResultsName("in")
fxn = (
function("attribute_exists", var)
| function("attribute_not_exists", var)
| function("attribute_type", var, types)
| function("begins_with", var, Group(string))
| function("contains", var, value)
| (function("size", var) + op + value)
).setResultsName("function")
all_constraints = between | basic_constraint | is_in | fxn
return Group(all_constraints).setName("constraint") | module function_definition identifier parameters block expression_statement assignment identifier call attribute call identifier argument_list string string_start string_content string_end keyword_argument identifier true identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute parenthesized_expression binary_operator binary_operator identifier identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute parenthesized_expression binary_operator binary_operator binary_operator binary_operator identifier call identifier argument_list call identifier argument_list string string_start string_content string_end identifier call identifier argument_list identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute parenthesized_expression binary_operator binary_operator identifier call identifier argument_list call identifier argument_list string string_start string_content string_end identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute parenthesized_expression binary_operator binary_operator binary_operator binary_operator binary_operator call identifier argument_list string string_start string_content string_end identifier call identifier argument_list string string_start string_content string_end identifier call identifier argument_list string string_start string_content string_end identifier identifier call identifier argument_list string string_start string_content string_end identifier call identifier argument_list identifier call identifier argument_list string string_start string_content string_end identifier identifier parenthesized_expression binary_operator binary_operator call identifier argument_list string string_start string_content string_end identifier identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator binary_operator identifier identifier identifier identifier return_statement call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end | Create a constraint for a query WHERE clause |
def dd2dm(dd):
d,m,s = dd2dms(dd)
m = m + float(s)/3600
return d,m,s | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier binary_operator call identifier argument_list identifier integer return_statement expression_list identifier identifier identifier | Convert decimal to degrees, decimal minutes |
def _url(self, url, file_upload=False):
host = self.api_url
if file_upload:
host = self.uploads_api_url
protocol = 'https' if self.https else 'http'
if url.endswith('/'):
url = url[:-1]
return '{0}://{1}/{2}'.format(
protocol,
host,
url
) | module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier conditional_expression string string_start string_content string_end attribute identifier identifier string string_start string_content string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice unary_operator integer return_statement call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier | Creates the request URL. |
def print_new(ctx, name, migration_type):
click.echo(ctx.obj.repository.generate_migration_name(name, migration_type)) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier | Prints filename of a new migration |
def clean():
for queue in MyQueue.collection().instances():
queue.delete()
for job in MyJob.collection().instances():
job.delete()
for person in Person.collection().instances():
person.delete() | module function_definition identifier parameters block for_statement identifier call attribute call attribute identifier identifier argument_list identifier argument_list block expression_statement call attribute identifier identifier argument_list for_statement identifier call attribute call attribute identifier identifier argument_list identifier argument_list block expression_statement call attribute identifier identifier argument_list for_statement identifier call attribute call attribute identifier identifier argument_list identifier argument_list block expression_statement call attribute identifier identifier argument_list | Clean data created by this script |
def openFile(self, openDQ=False):
if self._im.closed:
if not self._dq.closed:
self._dq.release()
assert(self._dq.closed)
fi = FileExtMaskInfo(clobber=False,
doNotOpenDQ=not openDQ,
im_fmode=self.open_mode)
fi.image = self.name
self._im = fi.image
fi.append_ext(spu.get_ext_list(self._im, extname='SCI'))
fi.finalize()
self._im = fi.image
self._dq = fi.DQimage
self._imext = fi.fext
self._dqext = fi.dqext | module function_definition identifier parameters identifier default_parameter identifier false block if_statement attribute attribute identifier identifier identifier block if_statement not_operator attribute attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list assert_statement parenthesized_expression attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier false keyword_argument identifier not_operator identifier keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier | Open file and set up filehandle for image file |
def check_input_files(headerDir, sourceDir, containers=['vector', 'list', 'set', 'map'],
seqType='both', verbose=False):
result1 = False
if seqType == "both" or seqType == "variadic":
if verbose:
print "Check if input files for pre-processing Boost.MPL variadic containers need fixing."
result1 = check_input_files_for_variadic_seq(headerDir, sourceDir)
if verbose:
if result1:
print " At least one input file needs fixing!"
else:
print " No input file needs fixing!"
result2 = False
result3 = False
if seqType == "both" or seqType == "numbered":
if verbose:
print "Check input files for pre-processing Boost.MPL numbered containers."
result2 = check_input_files_for_numbered_seq(headerDir, ".hpp", containers)
result3 = check_input_files_for_numbered_seq(sourceDir, ".cpp", containers)
if verbose:
if result2 or result3:
print " At least one input file needs fixing!"
else:
print " No input file needs fixing!"
return result1 or result2 or result3 | module function_definition identifier parameters identifier identifier default_parameter 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 default_parameter identifier string string_start string_content string_end default_parameter identifier false block expression_statement assignment identifier false if_statement boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block if_statement identifier block print_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier if_statement identifier block if_statement identifier block print_statement string string_start string_content string_end else_clause block print_statement string string_start string_content string_end expression_statement assignment identifier false expression_statement assignment identifier false if_statement boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block if_statement identifier block print_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end identifier if_statement identifier block if_statement boolean_operator identifier identifier block print_statement string string_start string_content string_end else_clause block print_statement string string_start string_content string_end return_statement boolean_operator boolean_operator identifier identifier identifier | Checks if source- and header-files, used as input when pre-processing MPL-containers, need fixing. |
def pre_sql_setup(self):
super(MultilingualSQLCompiler, self).pre_sql_setup()
if not self.query.include_translation_data:
return
opts = self.query.model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
if hasattr(opts, 'translation_model'):
master_table_name = self.query.join((None, opts.db_table, None, None))
translation_opts = opts.translation_model._meta
trans_table_name = translation_opts.db_table
for language_code in get_language_code_list():
table_alias = get_translation_table_alias(trans_table_name,
language_code)
trans_join = ("LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_code = '%s'))"
% (qn2(translation_opts.db_table),
qn2(table_alias),
qn2(table_alias),
qn(master_table_name),
qn2(opts.pk.column),
qn2(table_alias),
language_code))
self.query.extra_join[table_alias] = trans_join | module function_definition identifier parameters identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list if_statement not_operator attribute attribute identifier identifier identifier block return_statement expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list tuple none attribute identifier identifier none none expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute identifier identifier for_statement identifier call identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier parenthesized_expression binary_operator string string_start string_content string_end tuple call identifier argument_list attribute identifier identifier call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list attribute attribute identifier identifier identifier call identifier argument_list identifier identifier expression_statement assignment subscript attribute attribute identifier identifier identifier identifier identifier | Adds the JOINS and SELECTS for fetching multilingual data. |
def getreference(self, validate=True):
if self.offset is None: return None
if self.ref:
ref = self.doc[self.ref]
else:
ref = self.finddefaultreference()
if not ref:
raise UnresolvableTextContent("Default reference for phonetic content not found!")
elif not ref.hasphon(self.cls):
raise UnresolvableTextContent("Reference has no such phonetic content (class=" + self.cls+")")
elif validate and self.phon() != ref.textcontent(self.cls).phon()[self.offset:self.offset+len(self.data[0])]:
raise UnresolvableTextContent("Reference (class=" + self.cls+") found but no phonetic match at specified offset ("+str(self.offset)+")! Expected '" + self.text() + "', got '" + ref.textcontent(self.cls).text()[self.offset:self.offset+len(self.data[0])] +"'")
else:
return ref | module function_definition identifier parameters identifier default_parameter identifier true block if_statement comparison_operator attribute identifier identifier none block return_statement none if_statement attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end elif_clause not_operator call attribute identifier identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end elif_clause boolean_operator identifier comparison_operator call attribute identifier identifier argument_list subscript call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list slice attribute identifier identifier binary_operator attribute identifier identifier call identifier argument_list subscript attribute identifier identifier integer block raise_statement call identifier argument_list binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end subscript call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list slice attribute identifier identifier binary_operator attribute identifier identifier call identifier argument_list subscript attribute identifier identifier integer string string_start string_content string_end else_clause block return_statement identifier | Return and validate the Phonetic Content's reference. Raises UnresolvableTextContent when invalid |
def _register(self, session, url):
dist = self._poetry.file.parent / "dist"
file = dist / "{}-{}.tar.gz".format(
self._package.name, normalize_version(self._package.version.text)
)
if not file.exists():
raise RuntimeError('"{0}" does not exist.'.format(file.name))
data = self.post_data(file)
data.update({":action": "submit", "protocol_version": "1"})
data_to_send = self._prepare_data(data)
encoder = MultipartEncoder(data_to_send)
resp = session.post(
url,
data=encoder,
allow_redirects=False,
headers={"Content-Type": encoder.content_type},
)
resp.raise_for_status()
return resp | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator attribute attribute attribute identifier identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier binary_operator identifier call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier call identifier argument_list attribute attribute attribute identifier identifier identifier identifier if_statement not_operator call attribute identifier identifier argument_list block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier false keyword_argument identifier dictionary pair string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier | Register a package to a repository. |
def restore_default_settings():
global __DEFAULTS
__DEFAULTS.CACHE_DIR = defaults.CACHE_DIR
__DEFAULTS.SET_SEED = defaults.SET_SEED
__DEFAULTS.SEED = defaults.SEED
logging.info('Settings reverted to their default values.') | module function_definition identifier parameters block global_statement identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | Restore settings to default values. |
def askopenfile(mode="r", **options):
"Ask for a filename to open, and returned the opened file"
filename = askopenfilename(**options)
if filename:
return open(filename, mode)
return None | module function_definition identifier parameters default_parameter identifier string string_start string_content string_end dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list dictionary_splat identifier if_statement identifier block return_statement call identifier argument_list identifier identifier return_statement none | Ask for a filename to open, and returned the opened file |
def dict_from_hdf5(dict_like, h5group):
for name, value in h5group.attrs.items():
dict_like[name] = value | module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier identifier identifier | Load a dictionnary-like object from a h5 file group |
def _pprint(dic):
for key, value in dic.items():
print(" {0}: {1}".format(key, value)) | module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier | Prints a dictionary with one indentation level |
def node2freqt(docgraph, node_id, child_str='', include_pos=False,
escape_func=FREQT_ESCAPE_FUNC):
node_attrs = docgraph.node[node_id]
if istoken(docgraph, node_id):
token_str = escape_func(node_attrs[docgraph.ns+':token'])
if include_pos:
pos_str = escape_func(node_attrs.get(docgraph.ns+':pos', ''))
return u"({pos}({token}){child})".format(
pos=pos_str, token=token_str, child=child_str)
else:
return u"({token}{child})".format(token=token_str, child=child_str)
else:
label_str=escape_func(node_attrs.get('label', node_id))
return u"({label}{child})".format(label=label_str, child=child_str) | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end default_parameter identifier false default_parameter identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list subscript identifier binary_operator attribute identifier identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end string string_start string_end return_statement call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier else_clause block return_statement call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier | convert a docgraph node into a FREQT string. |
def after_start_check(self):
try:
conn = HTTPConnection(self.host, self.port)
conn.request('HEAD', self.url.path)
status = str(conn.getresponse().status)
if status == self.status or self.status_re.match(status):
conn.close()
return True
except (HTTPException, socket.timeout, socket.error):
return False | module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list attribute call attribute identifier identifier argument_list identifier if_statement boolean_operator comparison_operator identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list return_statement true except_clause tuple identifier attribute identifier identifier attribute identifier identifier block return_statement false | Check if defined URL returns expected status to a HEAD request. |
def map_equal_contributions(contributors):
equal_contribution_map = {}
equal_contribution_keys = []
for contributor in contributors:
if contributor.get("references") and "equal-contrib" in contributor.get("references"):
for key in contributor["references"]["equal-contrib"]:
if key not in equal_contribution_keys:
equal_contribution_keys.append(key)
equal_contribution_keys = sorted(equal_contribution_keys)
for i, equal_contribution_key in enumerate(equal_contribution_keys):
equal_contribution_map[equal_contribution_key] = i+1
return equal_contribution_map | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier list for_statement identifier identifier block if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end comparison_operator string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block for_statement identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment subscript identifier identifier binary_operator identifier integer return_statement identifier | assign numeric values to each unique equal-contrib id |
def build_thumb_path(self, image):
image_file = image.file
image_name_w_ext = split(image.name)[-1]
image_name, ext = splitext(image_name_w_ext)
if not self.in_memory(image_file):
image_name = image_name.split('/')[-1]
upload_to = image.field.upload_to
if not upload_to.endswith('/'):
upload_to = f'{upload_to}/'
path_upload_to = f'{upload_to}{image_name}'
return f'{self.storage.location}/{path_upload_to}{THUMB_EXT}{ext}' | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier subscript call identifier argument_list attribute identifier identifier unary_operator integer expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier string string_start interpolation identifier string_content string_end expression_statement assignment identifier string string_start interpolation identifier interpolation identifier string_end return_statement string string_start interpolation attribute attribute identifier identifier identifier string_content interpolation identifier interpolation identifier interpolation identifier string_end | Build the absolute path of the to-be-saved thumbnail. |
def _find_already_built_wheel(metadata_directory):
if not metadata_directory:
return None
metadata_parent = os.path.dirname(metadata_directory)
if not os.path.isfile(pjoin(metadata_parent, WHEEL_BUILT_MARKER)):
return None
whl_files = glob(os.path.join(metadata_parent, '*.whl'))
if not whl_files:
print('Found wheel built marker, but no .whl files')
return None
if len(whl_files) > 1:
print('Found multiple .whl files; unspecified behaviour. '
'Will call build_wheel.')
return None
return whl_files[0] | module function_definition identifier parameters identifier block if_statement not_operator identifier block return_statement none expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier identifier block return_statement none expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end if_statement not_operator identifier block expression_statement call identifier argument_list string string_start string_content string_end return_statement none if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement none return_statement subscript identifier integer | Check for a wheel already built during the get_wheel_metadata hook. |
def userCreate(self, request, tag):
userCreator = liveform.LiveForm(
self.createUser,
[liveform.Parameter(
"localpart",
liveform.TEXT_INPUT,
unicode,
"localpart"),
liveform.Parameter(
"domain",
liveform.TEXT_INPUT,
unicode,
"domain"),
liveform.Parameter(
"password",
liveform.PASSWORD_INPUT,
unicode,
"password")])
userCreator.setFragmentParent(self)
return userCreator | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier list call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Render a form for creating new users. |
def _process_wave_param(self, pval):
return self._process_generic_param(
pval, self._internal_wave_unit, equivalencies=u.spectral()) | module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list | Process individual model parameter representing wavelength. |
def _get_focused_item(self):
focused_model = self._selection.focus
if not focused_model:
return None
return self.canvas.get_view_for_model(focused_model) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement not_operator identifier block return_statement none return_statement call attribute attribute identifier identifier identifier argument_list identifier | Returns the currently focused item |
def auth(self):
if self.oauth:
return self.oauth
return (self.username, self.password) | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement attribute identifier identifier return_statement tuple attribute identifier identifier attribute identifier identifier | Return credentials for current Bitbucket user. |
def prepend_field(self, field_name, list_value):
return self._single_list_field_operation(field_name, list_value, prepend=True) | module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier true | Return a copy of this object with `list_value` prepended to the field named `field_name`. |
def _setupHttp(self):
if self._http == None:
http = httplib2.Http()
self._http = self._credentials.authorize(http) | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier | Setup an HTTP session authorized by OAuth2. |
def getLeastUsedCell(self, c):
segmentsPerCell = numpy.zeros(self.cellsPerColumn, dtype='uint32')
for i in range(self.cellsPerColumn):
segmentsPerCell[i] = self.getNumSegmentsInCell(c,i)
cellMinUsage = numpy.where(segmentsPerCell==segmentsPerCell.min())[0]
self._random.getUInt32(len(cellMinUsage))
return cellMinUsage[self._random.getUInt32(len(cellMinUsage))] | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier string string_start string_content string_end for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list comparison_operator identifier call attribute identifier identifier argument_list integer expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier return_statement subscript identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier | For the least used cell in a column |
def render_app_label(context, app, fallback=""):
try:
text = app['app_label']
except KeyError:
text = fallback
except TypeError:
text = app
return text | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end block try_statement block expression_statement assignment identifier subscript identifier string string_start string_content string_end except_clause identifier block expression_statement assignment identifier identifier except_clause identifier block expression_statement assignment identifier identifier return_statement identifier | Render the application label. |
def _AcquireLock(self,
urn,
blocking=None,
blocking_lock_timeout=None,
lease_time=None,
blocking_sleep_interval=None):
if urn is None:
raise ValueError("URN cannot be None")
urn = rdfvalue.RDFURN(urn)
try:
return data_store.DB.LockRetryWrapper(
urn,
retrywrap_timeout=blocking_sleep_interval,
retrywrap_max_timeout=blocking_lock_timeout,
blocking=blocking,
lease_time=lease_time)
except data_store.DBSubjectLockError as e:
raise LockError(e) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block return_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block raise_statement call identifier argument_list identifier | This actually acquires the lock for a given URN. |
def _extract_obo_relation(cls, rawterm):
relations = {}
if 'subClassOf' in rawterm:
relations[Relationship('is_a')] = l = []
l.extend(map(cls._get_id_from_url, rawterm.pop('subClassOf')))
return relations | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier call identifier argument_list string string_start string_content string_end assignment identifier list expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier | Extract the relationships defined in the rawterm. |
def strict_err_or_warn(self, *args, **kwargs):
if self.strict:
raise self.make_err(CoconutStyleError, *args, **kwargs)
else:
logger.warn_err(self.make_err(CoconutSyntaxWarning, *args, **kwargs)) | module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement attribute identifier identifier block raise_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier | Raises an error if in strict mode, otherwise raises a warning. |
def _get(self, url, params=None):
self._call(self.GET, url, params, None) | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier identifier none | Wrapper method for GET calls. |
def load_table(self, table):
region = table.database if table.database else self.default_region
resource_name, collection_name = table.table.split('_', 1)
boto_region_name = region.replace('_', '-')
resource = self.boto3_session.resource(resource_name, region_name=boto_region_name)
if not hasattr(resource, collection_name):
raise QueryError(
'Unknown collection <{0}> of resource <{1}>'.format(collection_name, resource_name))
self.attach_region(region)
self.refresh_table(region, table.table, resource, getattr(resource, collection_name)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier conditional_expression attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier identifier call identifier argument_list identifier identifier | Load resources as specified by given table into our db. |
def rpy2():
if LazyImport.rpy2_module is None:
try:
rpy2 = __import__('rpy2.robjects')
except ImportError:
raise ImportError('The rpy2 module is required')
LazyImport.rpy2_module = rpy2
try:
rpy2.forecast = rpy2.robjects.packages.importr('forecast')
except:
raise ImportError('R and the "forecast" package are required')
rpy2.ts = rpy2.robjects.r['ts']
__import__('rpy2.robjects.numpy2ri')
rpy2.robjects.numpy2ri.activate()
return LazyImport.rpy2_module | module function_definition identifier parameters block if_statement comparison_operator attribute identifier identifier none block try_statement block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier try_statement block expression_statement assignment attribute identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end except_clause block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list return_statement attribute identifier identifier | Lazily import the rpy2 module |
def blend_vars(secrets, opt):
base_obj = load_vars(opt)
merged = merge_dicts(base_obj, secrets)
template_obj = dict((k, v) for k, v in iteritems(merged) if v)
template_obj['aomi_items'] = template_obj.copy()
return template_obj | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier generator_expression tuple identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier if_clause identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list return_statement identifier | Blends secret and static variables together |
def _check_sample_config(items, in_file, config):
logger.info("Checking sample YAML configuration: %s" % in_file)
_check_quality_format(items)
_check_for_duplicates(items, "lane")
_check_for_duplicates(items, "description")
_check_for_degenerate_interesting_groups(items)
_check_for_batch_clashes(items)
_check_for_problem_somatic_batches(items, config)
_check_for_misplaced(items, "algorithm",
["resources", "metadata", "analysis",
"description", "genome_build", "lane", "files"])
[_check_toplevel_misplaced(x) for x in items]
[_check_algorithm_keys(x) for x in items]
[_check_algorithm_values(x) for x in items]
[_check_aligner(x) for x in items]
[_check_variantcaller(x) for x in items]
[_check_svcaller(x) for x in items]
[_check_hetcaller(x) for x in items]
[_check_indelcaller(x) for x in items]
[_check_jointcaller(x) for x in items]
[_check_hlacaller(x) for x in items]
[_check_realign(x) for x in items]
[_check_trim(x) for x in items] | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier string string_start string_content string_end expression_statement call identifier argument_list identifier string string_start string_content string_end expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier string string_start string_content string_end 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 expression_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier | Identify common problems in input sample configuration files. |
def safeprint(*args, **kwargs):
new_args = []
str_encoding = getattr(sys.stdout, 'encoding', None) or 'ascii'
for s in args:
new_args.append(s.encode('utf-8').decode(str_encoding, 'ignore'))
return print(*new_args, **kwargs) | module function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier list expression_statement assignment identifier boolean_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end none string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list identifier string string_start string_content string_end return_statement call identifier argument_list list_splat identifier dictionary_splat identifier | Convert and print characters using the proper encoding |
def blur(self):
scene = self.get_scene()
if scene and scene._focus_sprite == self:
scene._focus_sprite = None | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator identifier comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier none | removes focus from the current element if it has it |
def bytes2num(s):
res = 0
for i, c in enumerate(reversed(bytearray(s))):
res += c << (i * 8)
return res | module function_definition identifier parameters identifier block expression_statement assignment identifier integer for_statement pattern_list identifier identifier call identifier argument_list call identifier argument_list call identifier argument_list identifier block expression_statement augmented_assignment identifier binary_operator identifier parenthesized_expression binary_operator identifier integer return_statement identifier | Convert MSB-first bytes to an unsigned integer. |
def result(self):
final_result = {'epoch_idx': self.global_epoch_idx}
for key, value in self.frozen_results.items():
final_result[key] = value
return final_result | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier identifier identifier return_statement identifier | Return the epoch result |
def construct_asset_path(self, asset_path, css_path, output_filename, variant=None):
public_path = self.absolute_path(asset_path, os.path.dirname(css_path).replace('\\', '/'))
if self.embeddable(public_path, variant):
return "__EMBED__%s" % public_path
if not posixpath.isabs(asset_path):
asset_path = self.relative_path(public_path, output_filename)
return asset_path | module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end if_statement call attribute identifier identifier argument_list identifier identifier block return_statement binary_operator string string_start string_content string_end identifier if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier | Return a rewritten asset URL for a stylesheet |
def create_bucket(self):
bucket_exists = self._bucket_exists()
if self.s3props.get('shared_bucket_target'):
if bucket_exists:
LOG.info('App uses shared bucket - %s ', self.bucket)
else:
LOG.error("Shared bucket %s does not exist", self.bucket)
raise S3SharedBucketNotFound
else:
if self.region == 'us-east-1':
_response = self.s3client.create_bucket(ACL=self.s3props['bucket_acl'], Bucket=self.bucket)
else:
if not bucket_exists:
_response = self.s3client.create_bucket(ACL=self.s3props['bucket_acl'], Bucket=self.bucket,
CreateBucketConfiguration={
'LocationConstraint': self.region})
else:
_response = "bucket already exists, skipping create for non-standard region buckets."
LOG.debug('Response creating bucket: %s', _response)
LOG.info('%s - S3 Bucket Upserted', self.bucket)
self._put_bucket_policy()
self._put_bucket_website()
self._put_bucket_logging()
self._put_bucket_lifecycle()
self._put_bucket_versioning()
self._put_bucket_encryption()
self._put_bucket_tagging() | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier raise_statement identifier else_clause block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier else_clause block if_statement not_operator identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end attribute identifier identifier else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | Create or update bucket based on app name. |
def _maybe_nest_bare_single(items_by_key, parallel):
if (parallel == "multi-parallel" and
(sum([1 for x in items_by_key.values() if not _is_nested_item(x)]) >=
sum([1 for x in items_by_key.values() if _is_nested_item(x)]))):
out = {}
for k, v in items_by_key.items():
out[k] = [v]
return out
else:
return items_by_key | module function_definition identifier parameters identifier identifier block if_statement parenthesized_expression boolean_operator comparison_operator identifier string string_start string_content string_end parenthesized_expression comparison_operator call identifier argument_list list_comprehension integer for_in_clause identifier call attribute identifier identifier argument_list if_clause not_operator call identifier argument_list identifier call identifier argument_list list_comprehension integer for_in_clause identifier call attribute identifier identifier argument_list if_clause call identifier argument_list identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier list identifier return_statement identifier else_clause block return_statement identifier | Nest single inputs to avoid confusing single items and lists like files. |
def run():
server_address = (args.listen_addr, args.listen_port)
httpd = YHSM_VALServer(server_address, YHSM_VALRequestHandler)
my_log_message(args, syslog.LOG_INFO, "Serving requests to 'http://%s:%s%s' (YubiHSM: '%s')" \
% (args.listen_addr, args.listen_port, args.serve_url, args.device))
httpd.serve_forever() | module function_definition identifier parameters block expression_statement assignment identifier tuple attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier attribute identifier identifier binary_operator string string_start string_content string_end line_continuation tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list | Start the BaseHTTPServer and serve requests forever. |
def _augment(graph, capacity, flow, source, target):
n = len(graph)
A = [0] * n
augm_path = [None] * n
Q = deque()
Q.append(source)
augm_path[source] = source
A[source] = float('inf')
while Q:
u = Q.popleft()
for v in graph[u]:
cuv = capacity[u][v]
residual = cuv - flow[u][v]
if residual > 0 and augm_path[v] is None:
augm_path[v] = u
A[v] = min(A[u], residual)
if v == target:
break
else:
Q.append(v)
return (augm_path, A[target]) | module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator list integer identifier expression_statement assignment identifier binary_operator list none identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier expression_statement assignment subscript identifier identifier call identifier argument_list string string_start string_content string_end while_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier subscript identifier identifier block expression_statement assignment identifier subscript subscript identifier identifier identifier expression_statement assignment identifier binary_operator identifier subscript subscript identifier identifier identifier if_statement boolean_operator comparison_operator identifier integer comparison_operator subscript identifier identifier none block expression_statement assignment subscript identifier identifier identifier expression_statement assignment subscript identifier identifier call identifier argument_list subscript identifier identifier identifier if_statement comparison_operator identifier identifier block break_statement else_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement tuple identifier subscript identifier identifier | find a shortest augmenting path |
def _fill_col_borders(self):
first = True
last = True
if self.col_indices[0] == self.hcol_indices[0]:
first = False
if self.col_indices[-1] == self.hcol_indices[-1]:
last = False
for num, data in enumerate(self.tie_data):
self.tie_data[num] = self._extrapolate_cols(data, first, last)
if first and last:
self.col_indices = np.concatenate((np.array([self.hcol_indices[0]]),
self.col_indices,
np.array([self.hcol_indices[-1]])))
elif first:
self.col_indices = np.concatenate((np.array([self.hcol_indices[0]]),
self.col_indices))
elif last:
self.col_indices = np.concatenate((self.col_indices,
np.array([self.hcol_indices[-1]]))) | module function_definition identifier parameters identifier block expression_statement assignment identifier true expression_statement assignment identifier true if_statement comparison_operator subscript attribute identifier identifier integer subscript attribute identifier identifier integer block expression_statement assignment identifier false if_statement comparison_operator subscript attribute identifier identifier unary_operator integer subscript attribute identifier identifier unary_operator integer block expression_statement assignment identifier false for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list identifier identifier identifier if_statement boolean_operator identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list tuple call attribute identifier identifier argument_list list subscript attribute identifier identifier integer attribute identifier identifier call attribute identifier identifier argument_list list subscript attribute identifier identifier unary_operator integer elif_clause identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list tuple call attribute identifier identifier argument_list list subscript attribute identifier identifier integer attribute identifier identifier elif_clause identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list tuple attribute identifier identifier call attribute identifier identifier argument_list list subscript attribute identifier identifier unary_operator integer | Add the first and last column to the data by extrapolation. |
def process_upload(self, set_content_type=True):
metadata = self.get_upload_key_metadata()
if set_content_type:
content_type = self.get_upload_content_type()
metadata.update({b'Content-Type': b'{0}'.format(content_type)})
upload_key = self.get_upload_key()
processed_key_name = self.get_processed_key_name()
processed_key = upload_key.copy(upload_key.bucket.name,
processed_key_name, metadata)
processed_key.set_acl(self.get_processed_acl())
upload_key.delete()
return processed_key | module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement identifier | Process the uploaded file. |
def list_rocs_files(url=ROCS_URL):
soup = BeautifulSoup(get(url))
if not url.endswith('/'):
url += '/'
files = []
for elem in soup.findAll('a'):
if elem['href'].startswith('?'):
continue
if elem.string.lower() == 'parent directory':
continue
files.append(url + elem['href'])
return files | module function_definition identifier parameters default_parameter identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block if_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end block continue_statement if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block continue_statement expression_statement call attribute identifier identifier argument_list binary_operator identifier subscript identifier string string_start string_content string_end return_statement identifier | Gets the contents of the given url. |
def on_number(self, ctx, value):
value = int(value) if value.isdigit() else float(value)
top = self._stack[-1]
if top is JSONCompositeType.OBJECT:
self.fire(JSONStreamer.VALUE_EVENT, value)
elif top is JSONCompositeType.ARRAY:
self.fire(JSONStreamer.ELEMENT_EVENT, value)
else:
raise RuntimeError('Invalid json-streamer state') | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier conditional_expression call identifier argument_list identifier call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier subscript attribute identifier identifier unary_operator integer if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier elif_clause comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end | Since this is defined both integer and double callbacks are useless |
def _parse_args():
token_file = os.path.expanduser('~/.nikeplus_access_token')
parser = argparse.ArgumentParser(description='Export NikePlus data to CSV')
parser.add_argument('-t', '--token', required=False, default=None,
help=('Access token for API, can also store in file %s'
' to avoid passing via command line' % (token_file)))
parser.add_argument('-s', '--since', type=_validate_date_str,
help=('Only process entries starting with YYYY-MM-DD '
'and newer'))
args = vars(parser.parse_args())
if args['token'] is None:
try:
with open(token_file, 'r') as _file:
access_token = _file.read().strip()
except IOError:
print 'Must pass access token via command line or store in file %s' % (
token_file)
sys.exit(-1)
args['token'] = access_token
return args | module function_definition identifier parameters 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 identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier false keyword_argument identifier none keyword_argument identifier parenthesized_expression binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end parenthesized_expression identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list if_statement comparison_operator subscript identifier string string_start string_content string_end none block try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list except_clause identifier block print_statement binary_operator string string_start string_content string_end parenthesized_expression identifier expression_statement call attribute identifier identifier argument_list unary_operator integer expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier | Parse sys.argv arguments |
def initialise_logging(level: str, target: str, short_format: bool):
try:
log_level = getattr(logging, level)
except AttributeError:
raise SystemExit(
"invalid log level %r, expected any of 'DEBUG', 'INFO', 'WARNING', 'ERROR' or 'CRITICAL'" % level
)
handler = create_handler(target=target)
logging.basicConfig(
level=log_level,
format='%(asctime)-15s (%(process)d) %(message)s' if not short_format else '%(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
handlers=[handler]
) | module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier identifier except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier conditional_expression string string_start string_content string_end not_operator identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier list identifier | Initialise basic logging facilities |
def run(self):
if (self.repo in self.meta.default_repositories and
self.repo in self.meta.repositories):
try:
self.check = self.all_repos[self.repo]()
except OSError:
usage(self.repo)
raise SystemExit()
elif self.repo in self.meta.repositories:
self.check = self._init.custom(self.repo)
else:
usage(self.repo)
raise SystemExit()
self.status_bar()
self.status()
self.print_status(self.repo)
self.summary() | module function_definition identifier parameters identifier block if_statement parenthesized_expression boolean_operator comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block try_statement block expression_statement assignment attribute identifier identifier call subscript attribute identifier identifier attribute identifier identifier argument_list except_clause identifier block expression_statement call identifier argument_list attribute identifier identifier raise_statement call identifier argument_list elif_clause comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier else_clause block expression_statement call identifier argument_list attribute identifier identifier raise_statement call identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list | Run and check if new in ChangeLog.txt |
def _get_fieldnames(item):
if hasattr(item, "_fldsdefprt"):
return item.get_prtflds_all()
if hasattr(item, "_fields"):
return item._fields | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement attribute identifier identifier | Return fieldnames of either a namedtuple or GOEnrichmentRecord. |
def add_interface_router(self, router, body=None):
return self.put((self.router_path % router) + "/add_router_interface",
body=body) | module function_definition identifier parameters identifier identifier default_parameter identifier none block return_statement call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator attribute identifier identifier identifier string string_start string_content string_end keyword_argument identifier identifier | Adds an internal network interface to the specified router. |
def hsetnx(self, key, field, value):
return self.execute(b'HSETNX', key, field, value) | module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier | Set the value of a hash field, only if the field does not exist. |
def hmsToDeg(h, m, s):
return h * degPerHMSHour + m * degPerHMSMin + s * degPerHMSSec | module function_definition identifier parameters identifier identifier identifier block return_statement binary_operator binary_operator binary_operator identifier identifier binary_operator identifier identifier binary_operator identifier identifier | Convert RA hours, minutes, seconds into an angle in degrees. |
def GetSource(self, row, col, table=None):
if table is None:
table = self.grid.current_table
value = self.code_array((row, col, table))
if value is None:
return u""
else:
return value | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier identifier identifier if_statement comparison_operator identifier none block return_statement string string_start string_end else_clause block return_statement identifier | Return the source string of a cell |
def search_datasets(
self,
license=None,
format=None,
query=None,
featured=None,
owner=None,
organization=None,
badge=None,
reuses=None,
page_size=20,
x_fields=None,
):
payload = {"badge": badge, "size": page_size, "X-Fields": x_fields}
search_url = "{}/datasets".format(
self.base_url,
)
search_req = requests.get(
search_url,
params=payload,
)
logger.debug(search_req.url)
return search_req.json() | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier integer default_parameter identifier none 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 identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list | Search datasets within uData portal. |
def dispatch(self, operation, request, **path_args):
request.current_operation = operation
try:
for middleware in self.middleware.pre_request:
response = middleware(request, path_args)
if isinstance(response, HttpResponse):
return response
response = self._dispatch(operation, request, path_args)
for middleware in self.middleware.post_request:
response = middleware(request, response)
except Exception as ex:
if self.debug_enabled:
raise
self.handle_500(request, ex)
return HttpResponse("Error processing response.", HTTPStatus.INTERNAL_SERVER_ERROR)
else:
return response | module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier identifier try_statement block for_statement identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement call identifier argument_list identifier identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier for_statement identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement attribute identifier identifier block raise_statement expression_statement call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier else_clause block return_statement identifier | Dispatch incoming request and capture top level exceptions. |
def do_disconnect(self, arg):
if not self.arm.is_connected():
print(self.style.error('Error: ', 'Arm is already disconnected.'))
else:
self.arm.disconnect()
print(self.style.success('Success: ', 'Disconnected.')) | module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list block expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end | Disconnect from the arm. |
def __distinguished_name(self, type, fname=None, lname=None,
username=None):
if username is None:
uid = "uid={}".format(self.username)
else:
uid = "uid={}".format(username)
dn_list = [
uid,
"ou={}".format(self.__organizational_unit(type)),
self.client.basedn,
]
return ','.join(dn_list) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier list identifier call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list identifier attribute attribute identifier identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier | Assemble the DN of the user. |
def reward_goal(self):
if not 'goal' in self.mode:
return
mode = self.mode['goal']
if mode and mode['reward'] and self.__test_cond(mode):
if mode['reward'] > 0:
self.logger.info("Escaped!!")
self.player.stats['reward'] += mode['reward']
self.player.stats['score'] += mode['reward']
self.player.game_over = self.player.game_over or mode['terminal'] | module function_definition identifier parameters identifier block if_statement not_operator comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement boolean_operator boolean_operator identifier subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end integer block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement augmented_assignment subscript attribute attribute identifier identifier identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement augmented_assignment subscript attribute attribute identifier identifier identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment attribute attribute identifier identifier identifier boolean_operator attribute attribute identifier identifier identifier subscript identifier string string_start string_content string_end | Add an end goal reward |
def _parse_file_spec(self, spec):
if '*' in spec['file']:
expanded_paths = _expand_paths(spec['file'])
if not expanded_paths:
return []
expanded_specs = []
for p in expanded_paths:
_spec = copy.copy(spec)
_spec['file'] = p
expanded_specs.append(_spec)
return expanded_specs
else:
return [spec] | module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end if_statement not_operator identifier block return_statement list expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier else_clause block return_statement list identifier | Separate wildcard specs into more specs |
def _add_or_remove_flag(self, flag, add):
meth = self.add_flag if add else self.remove_flag
meth(flag) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier conditional_expression attribute identifier identifier identifier attribute identifier identifier expression_statement call identifier argument_list identifier | Add the given `flag` if `add` is True, remove it otherwise. |
def from_key(cls, container, key):
if key is None:
raise errors.NoObjectException
return cls(container,
name=key.name,
size=key.size,
content_type=key.content_type,
content_encoding=key.content_encoding,
last_modified=dt_from_header(key.last_modified),
obj_type=cls.type_cls.FILE) | module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier none block raise_statement attribute identifier identifier return_statement call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier call identifier argument_list attribute identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier | Create from key object. |
def file_signature(filename):
if not os.path.isfile(filename):
return None
if not os.path.exists(filename):
return None
sig = hashlib.sha1()
with open(filename, "rb") as f:
buf = f.read()
sig.update(buf)
return sig.hexdigest() | module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block return_statement none if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block return_statement none expression_statement assignment identifier call attribute identifier identifier argument_list with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list | Return a signature for a file. |
def make_tensor_value_info(
name,
elem_type,
shape,
doc_string="",
shape_denotation=None,
):
value_info_proto = ValueInfoProto()
value_info_proto.name = name
if doc_string:
value_info_proto.doc_string = doc_string
tensor_type_proto = value_info_proto.type.tensor_type
tensor_type_proto.elem_type = elem_type
tensor_shape_proto = tensor_type_proto.shape
if shape is not None:
tensor_shape_proto.dim.extend([])
if shape_denotation:
if len(shape_denotation) != len(shape):
raise ValueError(
'Invalid shape_denotation. '
'Must be of the same length as shape.')
for i, d in enumerate(shape):
dim = tensor_shape_proto.dim.add()
if d is None:
pass
elif isinstance(d, integer_types):
dim.dim_value = d
elif isinstance(d, text_type):
dim.dim_param = d
else:
raise ValueError(
'Invalid item in shape: {}. '
'Needs to of integer_types or text_type.'.format(d))
if shape_denotation:
dim.denotation = shape_denotation[i]
return value_info_proto | module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_end default_parameter identifier none block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier identifier if_statement identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list list if_statement identifier block if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier none block pass_statement elif_clause call identifier argument_list identifier identifier block expression_statement assignment attribute identifier identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment attribute identifier identifier identifier else_clause block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier if_statement identifier block expression_statement assignment attribute identifier identifier subscript identifier identifier return_statement identifier | Makes a ValueInfoProto based on the data type and shape. |
def change_approver_email_address(self, order_id, approver_email):
response = self.request(
E.changeApproverEmailAddressSslCertRequest(
E.id(order_id),
E.approverEmail(approver_email)
)
)
return int(response.data.id) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list attribute attribute identifier identifier identifier | Change the approver email address for an ordered SSL certificate. |
def readBatchTupleQuotes(self, symbols, start, end):
if end is None:
end=sys.maxint
ret={}
session=self.getReadSession()()
try:
symbolChunks=splitListEqually(symbols, 100)
for chunk in symbolChunks:
rows=session.query(Quote.symbol, Quote.time, Quote.close, Quote.volume,
Quote.low, Quote.high).filter(and_(Quote.symbol.in_(chunk),
Quote.time >= int(start),
Quote.time < int(end)))
for row in rows:
if row.time not in ret:
ret[row.time]={}
ret[row.time][row.symbol]=self.__sqlToTupleQuote(row)
finally:
self.getReadSession().remove()
return ret | module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier dictionary expression_statement assignment identifier call call attribute identifier identifier argument_list argument_list try_statement block expression_statement assignment identifier call identifier argument_list identifier integer for_statement identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier argument_list call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier comparison_operator attribute identifier identifier call identifier argument_list identifier comparison_operator attribute identifier identifier call identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier dictionary expression_statement assignment subscript subscript identifier attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list identifier finally_clause block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list return_statement identifier | read batch quotes as tuple to save memory |
def instruction_PAGE(self, opcode):
op_address, opcode2 = self.read_pc_byte()
paged_opcode = opcode * 256 + opcode2
self.call_instruction_func(op_address - 1, paged_opcode) | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator binary_operator identifier integer identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier integer identifier | call op from page 2 or 3 |
def _nanmean_ddof_object(ddof, value, axis=None, **kwargs):
from .duck_array_ops import (count, fillna, _dask_or_eager_func,
where_method)
valid_count = count(value, axis=axis)
value = fillna(value, 0)
dtype = kwargs.pop('dtype', None)
if dtype is None and value.dtype.kind == 'O':
dtype = value.dtype if value.dtype.kind in ['cf'] else float
data = _dask_or_eager_func('sum')(value, axis=axis, dtype=dtype, **kwargs)
data = data / (valid_count - ddof)
return where_method(data, valid_count != 0) | module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier dotted_name identifier dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none if_statement boolean_operator comparison_operator identifier none comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end block expression_statement assignment identifier conditional_expression attribute identifier identifier comparison_operator attribute attribute identifier identifier identifier list string string_start string_content string_end identifier expression_statement assignment identifier call call identifier argument_list string string_start string_content string_end argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier dictionary_splat identifier expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator identifier identifier return_statement call identifier argument_list identifier comparison_operator identifier integer | In house nanmean. ddof argument will be used in _nanvar method |
def update_hpolist(self, case_obj):
hpo_list = self.case_genelist(case_obj)
hpo_results = hpo_genes(case_obj.phenotype_ids(),
*self.phenomizer_auth)
if hpo_results is None:
pass
else:
gene_ids = [result['gene_id'] for result in hpo_results
if result['gene_id']]
hpo_list.gene_ids = gene_ids
self.save() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list list_splat attribute identifier identifier if_statement comparison_operator identifier none block pass_statement else_clause block expression_statement assignment identifier list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier identifier if_clause subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list | Update the HPO gene list for a case based on current terms. |
def content_type(self) -> Optional[ContentTypeHeader]:
try:
return cast(ContentTypeHeader, self[b'content-type'][0])
except (KeyError, IndexError):
return None | module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block try_statement block return_statement call identifier argument_list identifier subscript subscript identifier string string_start string_content string_end integer except_clause tuple identifier identifier block return_statement none | The ``Content-Type`` header. |
def cmap2pixmap(cmap, steps=50):
import numpy as np
inds = np.linspace(0, 1, steps)
n = len(cmap.clst) - 1
tups = [cmap.clst[int(x * n)] for x in inds]
rgbas = [QColor(int(r * 255), int(g * 255),
int(b * 255), 255).rgba() for r, g, b in tups]
im = QImage(steps, 1, QImage.Format_Indexed8)
im.setColorTable(rgbas)
for i in range(steps):
im.setPixel(i, 0, i)
im = im.scaled(128, 32)
pm = QPixmap.fromImage(im)
return pm | module function_definition identifier parameters identifier default_parameter identifier integer block import_statement aliased_import dotted_name identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list integer integer identifier expression_statement assignment identifier binary_operator call identifier argument_list attribute identifier identifier integer expression_statement assignment identifier list_comprehension subscript attribute identifier identifier call identifier argument_list binary_operator identifier identifier for_in_clause identifier identifier expression_statement assignment identifier list_comprehension call attribute call identifier argument_list call identifier argument_list binary_operator identifier integer call identifier argument_list binary_operator identifier integer call identifier argument_list binary_operator identifier integer integer identifier argument_list for_in_clause pattern_list identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier integer attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier for_statement identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list integer integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier | Convert a Ginga colormap into a QPixmap |
def fixup_parents(self, node, parent):
start, finish = 0, self.last_finish
needs_range = not hasattr(node, 'start')
if not hasattr(node, 'parent'):
node.parent = parent
for n in node:
if needs_range and hasattr(n, 'start'):
if n.start < start: start = n.start
if n.finish > finish: finish = n.finish
if hasattr(n, 'offset') and not hasattr(n, 'parent'):
n.parent = node
else:
self.fixup_parents(n, node)
pass
pass
if needs_range:
node.start, node.finish = start, finish
return | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list integer attribute identifier identifier expression_statement assignment identifier not_operator call identifier argument_list identifier string string_start string_content string_end if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier identifier for_statement identifier identifier block if_statement boolean_operator identifier call identifier argument_list identifier string string_start string_content string_end block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement boolean_operator call identifier argument_list identifier string string_start string_content string_end not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier pass_statement pass_statement if_statement identifier block expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier expression_list identifier identifier return_statement | Make sure each node has a parent |
def unread(self, include_deleted=False):
if is_soft_delete() and not include_deleted:
return self.filter(unread=True, deleted=False)
return self.filter(unread=True) | module function_definition identifier parameters identifier default_parameter identifier false block if_statement boolean_operator call identifier argument_list not_operator identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier true keyword_argument identifier false return_statement call attribute identifier identifier argument_list keyword_argument identifier true | Return only unread items in the current queryset |
def run_forever(self, **kwargs):
for key in kwargs:
setattr(self, key, kwargs[key])
self.command = self.COMMAND_RUN_FOREVER | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block for_statement identifier identifier block expression_statement call identifier argument_list identifier identifier subscript identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier | Run the motor until another command is sent. |
def seconds(num):
now = pytime.time()
end = now + num
until(end) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator identifier identifier expression_statement call identifier argument_list identifier | Pause for this many seconds |
def shift(self, next_state, token_type, value, lineno, column):
dfa, state, node = self.stack[-1]
new_node = Node(token_type, value, None, lineno, column)
node.children.append(new_node)
self.stack[-1] = (dfa, next_state, node) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier identifier subscript attribute identifier identifier unary_operator integer expression_statement assignment identifier call identifier argument_list identifier identifier none identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier unary_operator integer tuple identifier identifier identifier | Shift a non-terminal and prepare for the next state. |
def queued_spans(self):
spans = []
while True:
try:
s = self.queue.get(False)
except queue.Empty:
break
else:
spans.append(s)
return spans | module function_definition identifier parameters identifier block expression_statement assignment identifier list while_statement true block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list false except_clause attribute identifier identifier block break_statement else_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Get all of the spans in the queue |
def enter_state(self, request, application):
authorised_persons = self.get_email_persons(application)
link, is_secret = self.get_request_email_link(application)
emails.send_request_email(
self.authorised_text,
self.authorised_role,
authorised_persons,
application,
link, is_secret) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier identifier identifier identifier | This is becoming the new current state. |
def network_details():
ipv4_addresses = [
info[4][0]
for info in socket.getaddrinfo(
socket.gethostname(), None, socket.AF_INET
)
]
ipv4_addresses.extend(
info[4][0]
for info in socket.getaddrinfo("localhost", None, socket.AF_INET)
)
ipv4_addresses = sorted(set(ipv4_addresses))
try:
ipv6_addresses = [
info[4][0]
for info in socket.getaddrinfo(
socket.gethostname(), None, socket.AF_INET6
)
]
ipv6_addresses.extend(
info[4][0]
for info in socket.getaddrinfo(
"localhost", None, socket.AF_INET6
)
)
ipv6_addresses = sorted(set(ipv6_addresses))
except (socket.gaierror, AttributeError):
ipv6_addresses = None
return {
"IPv4": ipv4_addresses,
"IPv6": ipv6_addresses,
"host.name": socket.gethostname(),
"host.fqdn": socket.getfqdn(),
} | module function_definition identifier parameters block expression_statement assignment identifier list_comprehension subscript subscript identifier integer integer for_in_clause identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list none attribute identifier identifier expression_statement call attribute identifier identifier generator_expression subscript subscript identifier integer integer for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end none attribute identifier identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier try_statement block expression_statement assignment identifier list_comprehension subscript subscript identifier integer integer for_in_clause identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list none attribute identifier identifier expression_statement call attribute identifier identifier generator_expression subscript subscript identifier integer integer for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end none attribute identifier identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier except_clause tuple attribute identifier identifier identifier block expression_statement assignment identifier none return_statement 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 call attribute identifier identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list | Returns details about the network links |
def _indent_decor(lbl):
def closure_indent(func):
if util_arg.TRACE:
@ignores_exc_tb(outer_wrapper=False)
def wrp_indent(*args, **kwargs):
with util_print.Indenter(lbl):
print(' ...trace[in]')
ret = func(*args, **kwargs)
print(' ...trace[out]')
return ret
else:
@ignores_exc_tb(outer_wrapper=False)
def wrp_indent(*args, **kwargs):
with util_print.Indenter(lbl):
ret = func(*args, **kwargs)
return ret
wrp_indent_ = ignores_exc_tb(wrp_indent)
wrp_indent_ = preserve_sig(wrp_indent, func)
return wrp_indent_
return closure_indent | module function_definition identifier parameters identifier block function_definition identifier parameters identifier block if_statement attribute identifier identifier block decorated_definition decorator call identifier argument_list keyword_argument identifier false function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block with_statement with_clause with_item call attribute identifier identifier argument_list identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier expression_statement call identifier argument_list string string_start string_content string_end return_statement identifier else_clause block decorated_definition decorator call identifier argument_list keyword_argument identifier false function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block with_statement with_clause with_item call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier return_statement identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement identifier return_statement identifier | does the actual work of indent_func |
def choose(s, possibilities, threshold=.6):
if not possibilities: return None
if s in possibilities: return s
if s == '': return None
startswith = [x for x in possibilities if x.lower().startswith(s.lower())]
if len(startswith) == 1: return startswith[0]
contained = [x for x in possibilities if s.lower() in x.lower()]
if len(contained) == 1: return contained[0]
best = max([(x, Levenshtein.jaro_winkler(s, x, .05)) for x in possibilities], key=itemgetter(1))
if best[1] < threshold:
return None
return best[0] | module function_definition identifier parameters identifier identifier default_parameter identifier float block if_statement not_operator identifier block return_statement none if_statement comparison_operator identifier identifier block return_statement identifier if_statement comparison_operator identifier string string_start string_end block return_statement none expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause call attribute call attribute identifier identifier argument_list identifier argument_list call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block return_statement subscript identifier integer expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block return_statement subscript identifier integer expression_statement assignment identifier call identifier argument_list list_comprehension tuple identifier call attribute identifier identifier argument_list identifier identifier float for_in_clause identifier identifier keyword_argument identifier call identifier argument_list integer if_statement comparison_operator subscript identifier integer identifier block return_statement none return_statement subscript identifier integer | Returns the closest match to string s if exceeds threshold, else returns None |
def loop(self, max_seconds=None):
loop_started = datetime.datetime.now()
self._is_running = True
while self._is_running:
self.process_error_queue(self.q_error)
if max_seconds is not None:
if (datetime.datetime.now() - loop_started).total_seconds() > max_seconds:
break
for subprocess in self._subprocesses:
if not subprocess.is_alive():
subprocess.start()
self.process_io_queue(self.q_stdout, sys.stdout)
self.process_io_queue(self.q_stderr, sys.stderr) | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier true while_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block if_statement comparison_operator call attribute parenthesized_expression binary_operator call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list identifier block break_statement for_statement identifier attribute identifier identifier block if_statement not_operator call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier | Main loop for the process. This will run continuously until maxiter |
def _load(self, scale=1.0):
LOG.debug("File: %s", str(self.requested_band_filename))
ncf = Dataset(self.requested_band_filename, 'r')
wvl = ncf.variables['wavelength'][:] * scale
resp = ncf.variables['response'][:]
self.rsr = {'wavelength': wvl, 'response': resp} | module function_definition identifier parameters identifier default_parameter identifier float block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier binary_operator subscript subscript attribute identifier identifier string string_start string_content string_end slice identifier expression_statement assignment identifier subscript subscript attribute identifier identifier string string_start string_content string_end slice expression_statement assignment attribute identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier | Load the SLSTR relative spectral responses |
def log(message, type):
(sys.stdout if type == 'notice' else sys.stderr).write(message + "\n") | module function_definition identifier parameters identifier identifier block expression_statement call attribute parenthesized_expression conditional_expression attribute identifier identifier comparison_operator identifier string string_start string_content string_end attribute identifier identifier identifier argument_list binary_operator identifier string string_start string_content escape_sequence string_end | Log notices to stdout and errors to stderr |
def del_bridge_port(name, port):
log('Deleting port {} from bridge {}'.format(port, name))
subprocess.check_call(["ovs-vsctl", "--", "--if-exists", "del-port",
name, port])
subprocess.check_call(["ip", "link", "set", port, "down"])
subprocess.check_call(["ip", "link", "set", port, "promisc", "off"]) | module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier identifier expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end string string_start string_content string_end | Delete a port from the named openvswitch bridge |
def copy_plan(modeladmin, request, queryset):
for plan in queryset:
plan_copy = deepcopy(plan)
plan_copy.id = None
plan_copy.available = False
plan_copy.default = False
plan_copy.created = None
plan_copy.save(force_insert=True)
for pricing in plan.planpricing_set.all():
pricing.id = None
pricing.plan = plan_copy
pricing.save(force_insert=True)
for quota in plan.planquota_set.all():
quota.id = None
quota.plan = plan_copy
quota.save(force_insert=True) | module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier none expression_statement call attribute identifier identifier argument_list keyword_argument identifier true for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier true for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier true | Admin command for duplicating plans preserving quotas and pricings. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.