code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def save(self, path):
pos = self.tell()
self.seek(0)
with fopen(path, 'wb') as output:
output.truncate(self.length)
for chunk in iter(lambda: self.read(1024), b''):
output.write(chunk)
self.seek(pos) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list integer with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier for_statement identifier call identifier argument_list lambda call attribute identifier identifier argument_list integer string string_start string_end block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier | Save the file to the specified path |
def _handle_tag_module_refresh(self, tag, data):
self.module_refresh(
force_refresh=data.get('force_refresh', False),
notify=data.get('notify', False)
) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end false keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end false | Handle a module_refresh event |
def localize(dt):
if dt.tzinfo is UTC:
return (dt + LOCAL_UTC_OFFSET).replace(tzinfo=None)
return dt | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier identifier block return_statement call attribute parenthesized_expression binary_operator identifier identifier identifier argument_list keyword_argument identifier none return_statement identifier | Localize a datetime object to local time. |
def comp_pipe_handle(loc, tokens):
internal_assert(len(tokens) >= 3 and len(tokens) % 2 == 1, "invalid composition pipe tokens", tokens)
funcs = [tokens[0]]
stars = []
direction = None
for i in range(1, len(tokens), 2):
op, fn = tokens[i], tokens[i + 1]
new_direction, star = comp_pipe_info(op)
if direction is None:
direction = new_direction
elif new_direction != direction:
raise CoconutDeferredSyntaxError("cannot mix function composition pipe operators with different directions", loc)
funcs.append(fn)
stars.append(star)
if direction == "backwards":
funcs.reverse()
stars.reverse()
func = funcs.pop(0)
funcstars = zip(funcs, stars)
return "_coconut_base_compose(" + func + ", " + ", ".join(
"(%s, %s)" % (f, star) for f, star in funcstars
) + ")" | module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator binary_operator call identifier argument_list identifier integer integer string string_start string_content string_end identifier expression_statement assignment identifier list subscript identifier integer expression_statement assignment identifier list expression_statement assignment identifier none for_statement identifier call identifier argument_list integer call identifier argument_list identifier integer block expression_statement assignment pattern_list identifier identifier expression_list subscript identifier identifier subscript identifier binary_operator identifier integer expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier identifier elif_clause comparison_operator identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list identifier identifier return_statement binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier generator_expression binary_operator string string_start string_content string_end tuple identifier identifier for_in_clause pattern_list identifier identifier identifier string string_start string_content string_end | Process pipe function composition. |
def yahoo(base, target):
api_url = 'http://download.finance.yahoo.com/d/quotes.csv'
resp = requests.get(
api_url,
params={
'e': '.csv',
'f': 'sl1d1t1',
's': '{0}{1}=X'.format(base, target)
},
timeout=1,
)
value = resp.text.split(',', 2)[1]
return decimal.Decimal(value) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier identifier keyword_argument identifier integer expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer integer return_statement call attribute identifier identifier argument_list identifier | Parse data from Yahoo. |
def _authenticate(self):
response = self._get("/v1/domains/{0}".format(self.domain))
self.domain_id = response["domain"]["id"] | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end | An innocent call to check that the credentials are okay. |
def secgroup_create(self, name, description):
nt_ks = self.compute_conn
nt_ks.security_groups.create(name, description)
ret = {'name': name, 'description': description}
return ret | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement identifier | Create a security group |
def _add_entry(self, formdata=None, data=unset_value, index=None):
if formdata:
prefix = '-'.join((self.name, str(index)))
basekey = '-'.join((prefix, '{0}'))
idkey = basekey.format('id')
if prefix in formdata:
formdata[idkey] = formdata.pop(prefix)
if hasattr(self.nested_model, 'id') and idkey in formdata:
id = self.nested_model.id.to_python(formdata[idkey])
data = get_by(self.initial_data, 'id', id)
initial = flatten_json(self.nested_form,
data.to_mongo(),
prefix)
for key, value in initial.items():
if key not in formdata:
formdata[key] = value
else:
data = None
return super(NestedModelList, self)._add_entry(formdata, data, index) | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier identifier default_parameter identifier none block if_statement identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list tuple attribute identifier identifier call identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list tuple identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end comparison_operator identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list subscript identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement assignment identifier none return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier identifier | Fill the form with previous data if necessary to handle partial update |
def apply_filters(self, queryset, applicable_filters=None, applicable_exclusions=None):
for field, options in applicable_filters["field_facets"].items():
queryset = queryset.facet(field, **options)
for field, options in applicable_filters["date_facets"].items():
queryset = queryset.date_facet(field, **options)
for field, options in applicable_filters["query_facets"].items():
queryset = queryset.query_facet(field, **options)
return queryset | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block for_statement pattern_list identifier identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier for_statement pattern_list identifier identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier for_statement pattern_list identifier identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier return_statement identifier | Apply faceting to the queryset |
def age(self, as_at_date=None):
if self.date_of_death != None or self.is_deceased == True:
return None
as_at_date = date.today() if as_at_date == None else as_at_date
if self.date_of_birth != None:
if (as_at_date.month >= self.date_of_birth.month) and (as_at_date.day >= self.date_of_birth.day):
return (as_at_date.year - self.date_of_birth.year)
else:
return ((as_at_date.year - self.date_of_birth.year) -1)
else:
return None | module function_definition identifier parameters identifier default_parameter identifier none block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier true block return_statement none expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list comparison_operator identifier none identifier if_statement comparison_operator attribute identifier identifier none block if_statement boolean_operator parenthesized_expression comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier parenthesized_expression comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block return_statement parenthesized_expression binary_operator attribute identifier identifier attribute attribute identifier identifier identifier else_clause block return_statement parenthesized_expression binary_operator parenthesized_expression binary_operator attribute identifier identifier attribute attribute identifier identifier identifier integer else_clause block return_statement none | Compute the person's age |
def call_async(func):
@wraps(func)
def wrapper(self, *args, **kw):
def call():
try:
func(self, *args, **kw)
except Exception:
logger.exception(
"failed to call async [%r] with [%r] [%r]", func, args, kw
)
self.loop.call_soon_threadsafe(call)
return wrapper | module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block function_definition identifier parameters block try_statement block expression_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier | Decorates a function to be called async on the loop thread |
def _raise_closed(reason):
if isinstance(reason, Message):
if reason.method.klass.name == "channel":
raise ChannelClosed(reason)
elif reason.method.klass.name == "connection":
raise ConnectionClosed(reason)
raise Closed(reason) | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block if_statement comparison_operator attribute attribute attribute identifier identifier identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list identifier elif_clause comparison_operator attribute attribute attribute identifier identifier identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list identifier raise_statement call identifier argument_list identifier | Raise the appropriate Closed-based error for the given reason. |
def use_plenary_comment_view(self):
self._object_views['comment'] = PLENARY
for session in self._get_provider_sessions():
try:
session.use_plenary_comment_view()
except AttributeError:
pass | module function_definition identifier parameters identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement | Pass through to provider CommentLookupSession.use_plenary_comment_view |
def remove(self,obj):
relationship_table = self.params['relationship_table']
with self.obj.backend.transaction(implicit = True):
condition = and_(relationship_table.c[self.params['related_pk_field_name']] == obj.pk,
relationship_table.c[self.params['pk_field_name']] == self.obj.pk)
self.obj.backend.connection.execute(delete(relationship_table).where(condition))
self._queryset = None | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end with_statement with_clause with_item call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier true block expression_statement assignment identifier call identifier argument_list comparison_operator subscript attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier comparison_operator subscript attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list call attribute call identifier argument_list identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier none | Remove an object from the relation |
def expand_syntax(string):
match = syntax_pattern.search(string)
if match:
prefix = string[:match.start()]
suffix = string[match.end():]
intervals = match.group(1).split(',')
for interval in intervals:
interval_match = interval_pattern.match(interval)
if interval_match:
start = interval_match.group(1)
end = (interval_match.group(2) or start).strip('-')
for i in _iter_numbers(start, end):
for expanded in expand_syntax(prefix + i + suffix):
yield expanded
else:
yield string | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier subscript identifier slice call attribute identifier identifier argument_list expression_statement assignment identifier subscript identifier slice call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call attribute identifier identifier argument_list integer identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute parenthesized_expression boolean_operator call attribute identifier identifier argument_list integer identifier identifier argument_list string string_start string_content string_end for_statement identifier call identifier argument_list identifier identifier block for_statement identifier call identifier argument_list binary_operator binary_operator identifier identifier identifier block expression_statement yield identifier else_clause block expression_statement yield identifier | Iterator over all the strings in the expansion of the argument |
def plot_sediment_rate(self, ax=None):
if ax is None:
ax = plt.gca()
y_prior, x_prior = self.prior_sediment_rate()
ax.plot(x_prior, y_prior, label='Prior')
y_posterior = self.mcmcfit.sediment_rate
density = scipy.stats.gaussian_kde(y_posterior.flat)
density.covariance_factor = lambda: 0.25
density._compute_covariance()
ax.plot(x_prior, density(x_prior), label='Posterior')
acc_shape = self.mcmcsetup.mcmc_kws['acc_shape']
acc_mean = self.mcmcsetup.mcmc_kws['acc_mean']
annotstr_template = 'acc_shape: {0}\nacc_mean: {1}'
annotstr = annotstr_template.format(acc_shape, acc_mean)
ax.annotate(annotstr, xy=(0.9, 0.9), xycoords='axes fraction',
horizontalalignment='right', verticalalignment='top')
ax.set_ylabel('Density')
ax.set_xlabel('Acc. rate (yr/cm)')
ax.grid(True)
return ax | module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier lambda float expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier tuple float float keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list true return_statement identifier | Plot sediment accumulation rate prior and posterior distributions |
def type(self):
if isinstance(self.value, numbers.Number):
return "number"
if isinstance(self.value, basestring):
return "string"
return "unknown" | module function_definition identifier parameters identifier block if_statement call identifier argument_list attribute identifier identifier attribute identifier identifier block return_statement string string_start string_content string_end if_statement call identifier argument_list attribute identifier identifier identifier block return_statement string string_start string_content string_end return_statement string string_start string_content string_end | Returns 'number', 'string', 'date' or 'unknown' based on the type of the value |
def _or(ctx, *logical):
for arg in logical:
if conversions.to_boolean(arg, ctx):
return True
return False | module function_definition identifier parameters identifier list_splat_pattern identifier block for_statement identifier identifier block if_statement call attribute identifier identifier argument_list identifier identifier block return_statement true return_statement false | Returns TRUE if any argument is TRUE |
def _get_auth_challenge(self, exc):
response = HttpResponse(content=exc.content, status=exc.get_code_num())
response['WWW-Authenticate'] = 'Basic realm="%s"' % REALM
return response | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end binary_operator string string_start string_content string_end identifier return_statement identifier | Returns HttpResponse for the client. |
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument('file', metavar="FILE", nargs='+',
help='file to be made executable')
parser.add_argument("-p", "--python", metavar="VERSION",
help="python version (2 or 3)")
parser.add_argument('-v', '--version', action='version',
version='%(prog)s ' + __version__, help='show version')
parser.add_argument('-r', '--recursive', action='store_true',
help='recursively iterate the directories')
args = parser.parse_args()
return args | module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier 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 string string_start string_content string_end keyword_argument identifier binary_operator string string_start string_content string_end identifier 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 string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list return_statement identifier | Parses all the command line arguments using argparse and returns them. |
def zDDEInit(self):
self.pyver = _get_python_version()
if _PyZDDE.liveCh==0:
try:
_PyZDDE.server = _dde.CreateServer()
_PyZDDE.server.Create("ZCLIENT")
except Exception as err:
_sys.stderr.write("{}: DDE server may be in use!".format(str(err)))
return -1
self.conversation = _dde.CreateConversation(_PyZDDE.server)
try:
self.conversation.ConnectTo(self.appName, " ")
except Exception as err:
_sys.stderr.write("{}.\nOpticStudio UI may not be running!\n".format(str(err)))
self.zDDEClose()
return -1
else:
_PyZDDE.liveCh += 1
self.connection = True
return 0 | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list if_statement comparison_operator attribute identifier identifier integer block try_statement block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier return_statement unary_operator integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement unary_operator integer else_clause block expression_statement augmented_assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier true return_statement integer | Initiates link with OpticStudio DDE server |
def _get_program_cmd(name, pconfig, config, default):
if pconfig is None:
return name
elif isinstance(pconfig, six.string_types):
return pconfig
elif "cmd" in pconfig:
return pconfig["cmd"]
elif default is not None:
return default
else:
return name | module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier none block return_statement identifier elif_clause call identifier argument_list identifier attribute identifier identifier block return_statement identifier elif_clause comparison_operator string string_start string_content string_end identifier block return_statement subscript identifier string string_start string_content string_end elif_clause comparison_operator identifier none block return_statement identifier else_clause block return_statement identifier | Retrieve commandline of a program. |
def points_from_xywh(box):
x, y, w, h = box['x'], box['y'], box['w'], box['h']
return "%i,%i %i,%i %i,%i %i,%i" % (
x, y,
x + w, y,
x + w, y + h,
x, y + h
) | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier expression_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement binary_operator string string_start string_content string_end tuple identifier identifier binary_operator identifier identifier identifier binary_operator identifier identifier binary_operator identifier identifier identifier binary_operator identifier identifier | Constructs a polygon representation from a rectangle described as a dict with keys x, y, w, h. |
def info(self):
result = dict()
for name, namespace in self._namespaces.items():
result[name] = namespace.info_all()
return result | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list return_statement identifier | get information about all plugins in registered namespaces |
def _sub_latlon(self, other):
inv = self._pyproj_inv(other)
heading = inv['heading_reverse']
distance = inv['distance']
return GeoVector(initial_heading = heading, distance = distance) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier | Called when subtracting a LatLon object from self |
def corpusindex():
corpora = []
for f in glob.glob(settings.ROOT + "corpora/*"):
if os.path.isdir(f):
corpora.append(os.path.basename(f))
return corpora | module function_definition identifier parameters block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier | Get list of pre-installed corpora |
def replace_col(self, line, ndx):
for row in range(len(line)):
self.set_tile(row, ndx, line[row]) | module function_definition identifier parameters identifier identifier identifier block for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier identifier subscript identifier identifier | replace a grids column at index 'ndx' with 'line' |
def _covar_mstep_diag(gmm, X, responsibilities, weighted_X_sum, norm,
min_covar):
avg_X2 = np.dot(responsibilities.T, X * X) * norm
avg_means2 = gmm.means_ ** 2
avg_X_means = gmm.means_ * weighted_X_sum * norm
return avg_X2 - 2 * avg_X_means + avg_means2 + min_covar | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list attribute identifier identifier binary_operator identifier identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier integer expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier identifier identifier return_statement binary_operator binary_operator binary_operator identifier binary_operator integer identifier identifier identifier | Performing the covariance M step for diagonal cases |
def mock(self, obj=None, attr=None, **kwargs):
rval = Mock(**kwargs)
if obj is not None and attr is not None:
rval._object = obj
rval._attr = attr
if hasattr(obj, attr):
orig = getattr(obj, attr)
self._mocks.append((obj, attr, orig))
setattr(obj, attr, rval)
else:
self._mocks.append((obj, attr))
setattr(obj, attr, rval)
return rval | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list dictionary_splat identifier if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier identifier expression_statement call identifier argument_list identifier identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier expression_statement call identifier argument_list identifier identifier identifier return_statement identifier | Return a mock object. |
def prepare_encoder(inputs, hparams, attention_type="local_1d"):
x = prepare_image(inputs, hparams, name="enc_channels")
x = add_pos_signals(x, hparams, "enc_pos")
x_shape = common_layers.shape_list(x)
if attention_type == "local_1d":
x = tf.reshape(x, [x_shape[0], x_shape[1]*x_shape[2], hparams.hidden_size])
x.set_shape([None, None, hparams.hidden_size])
elif attention_type == "local_2d":
x.set_shape([None, None, None, hparams.hidden_size])
return x | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier list subscript identifier integer binary_operator subscript identifier integer subscript identifier integer attribute identifier identifier expression_statement call attribute identifier identifier argument_list list none none attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list list none none none attribute identifier identifier return_statement identifier | Prepare encoder for images. |
def _encode(msg, head=False, binary=False):
rawstr = str(_MAGICK) + u"{0:s} {1:s} {2:s} {3:s} {4:s}".format(
msg.subject, msg.type, msg.sender, msg.time.isoformat(), msg.version)
if not head and msg.data:
if not binary and isinstance(msg.data, six.string_types):
return (rawstr + ' ' +
'text/ascii' + ' ' + msg.data)
elif not binary:
return (rawstr + ' ' +
'application/json' + ' ' +
json.dumps(msg.data, default=datetime_encoder))
else:
return (rawstr + ' ' +
'binary/octet-stream' + ' ' + msg.data)
return rawstr | module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier false block expression_statement assignment identifier binary_operator call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement boolean_operator not_operator identifier attribute identifier identifier block if_statement boolean_operator not_operator identifier call identifier argument_list attribute identifier identifier attribute identifier identifier block return_statement parenthesized_expression binary_operator binary_operator binary_operator binary_operator identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end attribute identifier identifier elif_clause not_operator identifier block return_statement parenthesized_expression binary_operator binary_operator binary_operator binary_operator identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier else_clause block return_statement parenthesized_expression binary_operator binary_operator binary_operator binary_operator identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end attribute identifier identifier return_statement identifier | Convert a Message to a raw string. |
def from_rankings(cls, data, penalty):
top1 = list()
for ranking in data:
for i, winner in enumerate(ranking[:-1]):
top1.append((winner, ranking[i+1:]))
return cls(top1, penalty) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list subscript identifier slice unary_operator integer block expression_statement call attribute identifier identifier argument_list tuple identifier subscript identifier slice binary_operator identifier integer return_statement call identifier argument_list identifier identifier | Alternative constructor for ranking data. |
def make_request(self, url, params, auth=None):
req = urllib2.Request(url + urllib.urlencode(params))
if auth:
req.add_header('AUTHORIZATION', 'Basic ' + auth)
return urllib2.urlopen(req) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end binary_operator string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier | Prepares a request from a url, params, and optionally authentication. |
def _check_prompts(pre_prompt, post_prompt):
if not isinstance(pre_prompt, str):
raise TypeError("The pre_prompt was not a string!")
if post_prompt is not _NO_ARG and not isinstance(post_prompt, str):
raise TypeError("The post_prompt was given and was not a string!") | module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator identifier identifier not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end | Check that the prompts are strings |
def show(self):
textWidth = max(60, shutil.get_terminal_size((80, 20)).columns)
text = f' {self.step_name() + ":":<21} ' + self.comment
print('\n'.join(
textwrap.wrap(
text,
width=textWidth,
initial_indent='',
subsequent_indent=' ' * 24)))
local_parameters = {
x: y
for x, y in self.parameters.items()
if x not in self.global_parameters
}
if local_parameters:
print(' Workflow Options:')
for name, (value, comment) in local_parameters.items():
par_str = f' {format_par(name, value)}'
print(par_str)
if comment:
print('\n'.join(
textwrap.wrap(
comment,
width=textWidth,
initial_indent=' ' * 24,
subsequent_indent=' ' * 24))) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list integer attribute call attribute identifier identifier argument_list tuple integer integer identifier expression_statement assignment identifier binary_operator string string_start string_content interpolation binary_operator call attribute identifier identifier argument_list string string_start string_content string_end format_specifier string_content string_end attribute identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_end keyword_argument identifier binary_operator string string_start string_content string_end integer expression_statement assignment identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause comparison_operator identifier attribute identifier identifier if_statement identifier block expression_statement call identifier argument_list string string_start string_content string_end for_statement pattern_list identifier tuple_pattern identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier string string_start string_content interpolation call identifier argument_list identifier identifier string_end expression_statement call identifier argument_list identifier if_statement identifier block expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier binary_operator string string_start string_content string_end integer keyword_argument identifier binary_operator string string_start string_content string_end integer | Output for command sos show |
def S(Document, *fields):
result = []
for field in fields:
if isinstance(field, tuple):
field, direction = field
result.append((field, direction))
continue
direction = ASCENDING
if not field.startswith('__'):
field = field.replace('__', '.')
if field[0] == '-':
direction = DESCENDING
if field[0] in ('+', '-'):
field = field[1:]
_field = traverse(Document, field, default=None)
result.append(((~_field) if _field else field, direction))
return result | module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment pattern_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list tuple identifier identifier continue_statement expression_statement assignment identifier identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment identifier identifier if_statement comparison_operator subscript identifier integer tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice integer expression_statement assignment identifier call identifier argument_list identifier identifier keyword_argument identifier none expression_statement call attribute identifier identifier argument_list tuple conditional_expression parenthesized_expression unary_operator identifier identifier identifier identifier return_statement identifier | Generate a MongoDB sort order list using the Django ORM style. |
def validate_pwhash(_self, params):
pwhash, nonce, aead, key_handle = get_pwhash_bits(params)
d_aead = aead.decode('hex')
plaintext_len = len(d_aead) - pyhsm.defines.YSM_AEAD_MAC_SIZE
pw = pwhash.ljust(plaintext_len, chr(0x0))
if hsm.validate_aead(nonce.decode('hex'), key_handle, d_aead, pw):
return "OK pwhash validated"
return "ERR Could not validate pwhash" | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator call identifier argument_list identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier call identifier argument_list integer if_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier block return_statement string string_start string_content string_end return_statement string string_start string_content string_end | Validate password hash using YubiHSM. |
def javascript(filename, type='text/javascript'):
if '?' in filename and len(filename.split('?')) is 2:
filename, params = filename.split('?')
return '<script type="%s" src="%s?%s"></script>' % (type, staticfiles_storage.url(filename), params)
else:
return '<script type="%s" src="%s"></script>' % (type, staticfiles_storage.url(filename)) | module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end integer block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement binary_operator string string_start string_content string_end tuple identifier call attribute identifier identifier argument_list identifier identifier else_clause block return_statement binary_operator string string_start string_content string_end tuple identifier call attribute identifier identifier argument_list identifier | A simple shortcut to render a ``script`` tag to a static javascript file |
def _update_Prxy(self):
self.Prxy = self.Frxy * self.Qxy
_fill_diagonals(self.Prxy, self._diag_indices) | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier | Update `Prxy` using current `Frxy` and `Qxy`. |
def broadcast(self, channel, event, data):
payload = self._server.serialize_event(event, data)
for socket_id in self.subscriptions.get(channel, ()):
rv = self._server.sockets.get(socket_id)
if rv is not None:
rv.socket.send(payload) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list identifier tuple block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Broadcasts an event to all sockets listening on a channel. |
def connect(self):
if self.state == DISCONNECTED:
raise errors.NSQException('connection already closed')
if self.is_connected:
return
stream = Stream(self.address, self.port, self.timeout)
stream.connect()
self.stream = stream
self.state = CONNECTED
self.send(nsq.MAGIC_V2) | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier identifier block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement attribute identifier identifier block return_statement expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier | Initialize connection to the nsqd. |
def _formatter_class(name, value):
__mname = value.__module__
if __mname != '__main__':
return "%s = <type '%s.%s'>" % (name, __mname, value.__name__)
else:
return "%s = <type '%s'>" % (name, value.__name__) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement binary_operator string string_start string_content string_end tuple identifier identifier attribute identifier identifier else_clause block return_statement binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier | Format the "klass" variable and value on class methods. |
def notes(self):
endpoint = '/'.join((self.endpoint, self.id, 'notes'))
return self.noteFactory.find(
endpoint=endpoint,
api_key=self.api_key,
) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list tuple attribute identifier identifier attribute identifier identifier string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier | Query for notes attached to this incident. |
def _get_file_size(path, get_retriever):
integration, config = get_retriever.integration_and_config(path)
if integration:
return integration.file_size(path, config)
elif os.path.exists(path):
return os.path.getsize(path) / (1024.0 * 1024.0) | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement call attribute identifier identifier argument_list identifier identifier elif_clause call attribute attribute identifier identifier identifier argument_list identifier block return_statement binary_operator call attribute attribute identifier identifier identifier argument_list identifier parenthesized_expression binary_operator float float | Return file size in megabytes, including querying remote integrations |
def handle_unauthorized_file_type(error):
url = url_for('api.allowed_extensions', _external=True)
msg = (
'This file type is not allowed.'
'The allowed file type list is available at {url}'
).format(url=url)
return {'message': msg}, 400 | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier true expression_statement assignment identifier call attribute parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list keyword_argument identifier identifier return_statement expression_list dictionary pair string string_start string_content string_end identifier integer | Error occuring when the user try to upload a non-allowed file type |
def default_name(self, separator='-'):
return self.__class__.__name__ + '{}{:03d}'.format(
separator, self._index+1) | module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block return_statement binary_operator attribute attribute identifier identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier binary_operator attribute identifier identifier integer | Return a default name for based on class and index of element |
def create_ticket(self, service):
ticket = AuthTicket(owner=self, service=service)
ticket.authorize()
return ticket | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier | Create an AuthTicket for a given service. |
def eparOptionFactory(master, statusBar, param, defaultParam,
doScroll, fieldWidths,
plugIn=None, editedCallbackObj=None,
helpCallbackObj=None, mainGuiObj=None,
defaultsVerb="Default", bg=None, indent=False,
flagging=False, flaggedColor=None):
if plugIn is not None:
eparOption = plugIn
elif param.choice is not None:
eparOption = EnumEparOption
else:
eparOption = _eparOptionDict.get(param.type, StringEparOption)
eo = eparOption(master, statusBar, param, defaultParam, doScroll,
fieldWidths, defaultsVerb, bg,
indent=indent, helpCallbackObj=helpCallbackObj,
mainGuiObj=mainGuiObj)
eo.setEditedCallbackObj(editedCallbackObj)
eo.setIsFlagging(flagging, False)
if flaggedColor:
eo.setFlaggedColor(flaggedColor)
return eo | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier none default_parameter identifier false default_parameter identifier false default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier identifier elif_clause comparison_operator attribute identifier identifier none block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier false if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Return EparOption item of appropriate type for the parameter param |
def _yield_abbreviations_for_parameter(param, kwargs):
name = param.name
kind = param.kind
ann = param.annotation
default = param.default
not_found = (name, empty, empty)
if kind in (Parameter.POSITIONAL_OR_KEYWORD, Parameter.KEYWORD_ONLY):
if name in kwargs:
value = kwargs.pop(name)
elif ann is not empty:
warn("Using function annotations to implicitly specify interactive controls is deprecated. Use an explicit keyword argument for the parameter instead.", DeprecationWarning)
value = ann
elif default is not empty:
value = default
else:
yield not_found
yield (name, value, default)
elif kind == Parameter.VAR_KEYWORD:
for k, v in kwargs.copy().items():
kwargs.pop(k)
yield k, v, empty | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier tuple identifier identifier identifier if_statement comparison_operator identifier tuple attribute identifier identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier identifier elif_clause comparison_operator identifier identifier block expression_statement assignment identifier identifier else_clause block expression_statement yield identifier expression_statement yield tuple identifier identifier identifier elif_clause comparison_operator identifier attribute identifier identifier block for_statement pattern_list identifier identifier call attribute call attribute identifier identifier argument_list identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier expression_statement yield expression_list identifier identifier identifier | Get an abbreviation for a function parameter. |
def weighted_n(self):
if not self.is_weighted:
return float(self.unweighted_n)
return float(sum(self._cube_dict["result"]["measures"]["count"]["data"])) | module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement call identifier argument_list attribute identifier identifier return_statement call identifier argument_list call identifier argument_list subscript subscript subscript subscript attribute identifier identifier 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 | float count of returned rows adjusted for weighting. |
def _get_struct_clipactions(self):
obj = _make_object("ClipActions")
clipeventflags_size = 2 if self._version <= 5 else 4
clipactionend_size = 2 if self._version <= 5 else 4
all_zero = b"\x00" * clipactionend_size
assert unpack_ui16(self._src) == 0
obj.AllEventFlags = self._src.read(clipeventflags_size)
obj.ClipActionRecords = records = []
while True:
next_bytes = self._src.read(clipactionend_size)
if next_bytes == all_zero:
return
record = _make_object("ClipActionRecord")
records.append(record)
record.EventFlags = next_bytes
record.ActionRecordSize = unpack_ui32(self._src)
record.TheRestTODO = self._src.read(record.ActionRecordSize)
return obj | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier conditional_expression integer comparison_operator attribute identifier identifier integer integer expression_statement assignment identifier conditional_expression integer comparison_operator attribute identifier identifier integer integer expression_statement assignment identifier binary_operator string string_start string_content escape_sequence string_end identifier assert_statement comparison_operator call identifier argument_list attribute identifier identifier integer expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier assignment identifier list while_statement true block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block return_statement expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier return_statement identifier | Get the several CLIPACTIONRECORDs. |
def exhaustive_ontology_ilx_diff_row_only( self, ontology_row: dict ) -> dict:
results = []
header = ['Index'] + list(self.existing_ids.columns)
for row in self.existing_ids.itertuples():
row = {header[i]:val for i, val in enumerate(row)}
check_list = [
{
'external_ontology_row': ontology_row,
'ilx_rows': [row],
},
]
result = self.__exhaustive_diff(check_list)[0][0]
if result['same']:
results.append(result)
return results | module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier list expression_statement assignment identifier binary_operator list string string_start string_content string_end call identifier argument_list attribute attribute identifier identifier identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier dictionary_comprehension pair subscript identifier identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier expression_statement assignment identifier list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end list identifier expression_statement assignment identifier subscript subscript call attribute identifier identifier argument_list identifier integer integer if_statement subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | WARNING RUNTIME IS AWEFUL |
def handle_phone_number_check(self, html: str) -> requests.Response:
action_url = get_base_url(html)
phone_number = input(self.PHONE_PROMPT)
url_params = get_url_params(action_url)
data = {'code': phone_number,
'act': 'security_check',
'hash': url_params['hash']}
post_url = '/'.join((self.LOGIN_URL, action_url))
return self.post(post_url, data) | module function_definition identifier parameters identifier typed_parameter identifier type identifier type attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list tuple attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier | Handling phone number request |
def visit_ExceptHandler(self, node):
if node.name:
self.naming[node.name.id] = [frozenset()]
for stmt in node.body:
self.visit(stmt) | module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier attribute attribute identifier identifier identifier list call identifier argument_list for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier | Exception may declare a new variable. |
def _munge(self, value):
if self.translations and value in self.translations:
value = self.translations[value]
return value | module function_definition identifier parameters identifier identifier block if_statement boolean_operator attribute identifier identifier comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier return_statement identifier | Possibly munges a value. |
def transformer_librispeech_tpu_v1():
hparams = transformer_librispeech_v1()
update_hparams_for_tpu(hparams)
hparams.batch_size = 16
librispeech.set_librispeech_length_hparams(hparams)
return hparams | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement call identifier argument_list identifier expression_statement assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | HParams for training ASR model on Librispeech on TPU v1. |
def modify_kls(self, name):
if self.kls is None:
self.kls = name
else:
self.kls += name | module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier identifier else_clause block expression_statement augmented_assignment attribute identifier identifier identifier | Add a part to what will end up being the kls' superclass |
def enqueue(self, job):
if job.queue_name():
raise EnqueueError("job %s already queued!" % job.job_id)
new_len = self.redis.lpush(self.queue_name, job.serialize())
job.notify_queued(self)
return new_len | module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Enqueue a job for later processing, returns the new length of the queue |
def _aix_cpudata():
grains = {}
cmd = salt.utils.path.which('prtconf')
if cmd:
data = __salt__['cmd.run']('{0}'.format(cmd)) + os.linesep
for dest, regstring in (('cpuarch', r'(?im)^\s*Processor\s+Type:\s+(\S+)'),
('cpu_flags', r'(?im)^\s*Processor\s+Version:\s+(\S+)'),
('cpu_model', r'(?im)^\s*Processor\s+Implementation\s+Mode:\s+(.*)'),
('num_cpus', r'(?im)^\s*Number\s+Of\s+Processors:\s+(\S+)')):
for regex in [re.compile(r) for r in [regstring]]:
res = regex.search(data)
if res and len(res.groups()) >= 1:
grains[dest] = res.group(1).strip().replace("'", '')
else:
log.error('The \'prtconf\' binary was not found in $PATH.')
return grains | module function_definition identifier parameters block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier binary_operator call subscript identifier string string_start string_content string_end argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier for_statement pattern_list identifier identifier tuple tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end block for_statement identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator identifier comparison_operator call identifier argument_list call attribute identifier identifier argument_list integer block expression_statement assignment subscript identifier identifier call attribute call attribute call attribute identifier identifier argument_list integer identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_end else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end return_statement identifier | Return CPU information for AIX systems |
def destroy(self, request, variant_id=None):
variant = ProductVariant.objects.get(id=variant_id)
quantity = int(request.data.get("quantity", 1))
try:
item = BasketItem.objects.get(
basket_id=utils.basket_id(request), variant=variant)
item.decrease_quantity(quantity)
except BasketItem.DoesNotExist:
pass
serializer = BasketItemSerializer(self.get_queryset(request), many=True)
return Response(data=serializer.data,
status=status.HTTP_200_OK) | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier except_clause attribute identifier identifier block pass_statement expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier true return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier | Remove an item from the basket |
def fromexporterror(cls, bundle, exporterid, rsid, exception, endpoint):
return RemoteServiceAdminEvent(
RemoteServiceAdminEvent.EXPORT_ERROR,
bundle,
exporterid,
rsid,
None,
None,
exception,
endpoint,
) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block return_statement call identifier argument_list attribute identifier identifier identifier identifier identifier none none identifier identifier | Creates a RemoteServiceAdminEvent object from an export error |
def add_params_to_qs(query, params):
if isinstance(params, dict):
params = params.items()
queryparams = urlparse.parse_qsl(query, keep_blank_values=True)
queryparams.extend(params)
return urlencode(queryparams) | module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier | Extend a query with a list of two-tuples. |
def process(self):
var_name = self.name_edt.text()
try:
self.var_name = str(var_name)
except UnicodeEncodeError:
self.var_name = to_text_string(var_name)
if self.text_widget.get_as_data():
self.clip_data = self._get_table_data()
elif self.text_widget.get_as_code():
self.clip_data = try_to_eval(
to_text_string(self._get_plain_text()))
else:
self.clip_data = to_text_string(self._get_plain_text())
self.accept() | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list try_statement block expression_statement assignment attribute identifier identifier call identifier argument_list identifier except_clause identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier if_statement call attribute attribute identifier identifier identifier argument_list block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list elif_clause call attribute attribute identifier identifier identifier argument_list block expression_statement assignment attribute identifier identifier call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list else_clause block expression_statement assignment attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | Process the data from clipboard |
def remove_module_docstring(app, what, name, obj, options, lines):
if what == "module" and name == "clusterpolate":
del lines[:] | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block 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 delete_statement subscript identifier slice | Ignore the docstring of the ``clusterpolate`` module. |
def _run_purecn_dx(out, paired):
out_base, out, all_files = _get_purecn_dx_files(paired, out)
if not utils.file_uptodate(out["mutation_burden"], out["rds"]):
with file_transaction(paired.tumor_data, out_base) as tx_out_base:
cmd = ["PureCN_Dx.R", "--rds", out["rds"], "--callable", dd.get_sample_callable(paired.tumor_data),
"--signatures", "--out", tx_out_base]
do.run(cmd, "PureCN Dx mutational burden and signatures")
for f in all_files:
if os.path.exists(os.path.join(os.path.dirname(tx_out_base), f)):
shutil.move(os.path.join(os.path.dirname(tx_out_base), f),
os.path.join(os.path.dirname(out_base), f))
return out | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier identifier if_statement not_operator call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier identifier as_pattern_target identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end for_statement identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement identifier | Extract signatures and mutational burdens from PureCN rds file. |
def sysinit(systype, conf, project):
click.secho(get_config(
systype,
conf=ConfModule(conf).configurations[0],
conf_path=conf,
project_name=project,
)) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier subscript attribute call identifier argument_list identifier identifier integer keyword_argument identifier identifier keyword_argument identifier identifier | Outputs configuration for system initialization subsystem. |
def isdir(self, relpath):
if self._isdir_raw(relpath):
if not self.isignored(relpath, directory=True):
return True
return False | module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list identifier block if_statement not_operator call attribute identifier identifier argument_list identifier keyword_argument identifier true block return_statement true return_statement false | Returns True if path is a directory and is not ignored. |
def post_object_async(self, path, **kwds):
return self.do_request_async(self.api_url + path, 'POST', **kwds) | module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier identifier string string_start string_content string_end dictionary_splat identifier | POST to an object. |
def server_and_prefix(self):
return(host_port_prefix(self.config.host, self.config.port, self.prefix)) | module function_definition identifier parameters identifier block return_statement parenthesized_expression call identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier attribute identifier identifier | Server and prefix from config. |
def db_connect(cls, path):
con = sqlite3.connect(path, isolation_level=None, timeout=2**30)
con.row_factory = StateEngine.db_row_factory
return con | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier none keyword_argument identifier binary_operator integer integer expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement identifier | connect to our chainstate db |
def condition_input(args, kwargs):
ret = []
for arg in args:
if (six.PY3 and isinstance(arg, six.integer_types) and salt.utils.jid.is_jid(six.text_type(arg))) or \
(six.PY2 and isinstance(arg, long)):
ret.append(six.text_type(arg))
else:
ret.append(arg)
if isinstance(kwargs, dict) and kwargs:
kw_ = {'__kwarg__': True}
for key, val in six.iteritems(kwargs):
kw_[key] = val
return ret + [kw_]
return ret | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement boolean_operator parenthesized_expression boolean_operator boolean_operator attribute identifier identifier call identifier argument_list identifier attribute identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier line_continuation parenthesized_expression boolean_operator attribute identifier identifier call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier if_statement boolean_operator call identifier argument_list identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end true for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block expression_statement assignment subscript identifier identifier identifier return_statement binary_operator identifier list identifier return_statement identifier | Return a single arg structure for the publisher to safely use |
def RegisterIntKey(cls, key, atomid, min_value=0, max_value=(2 ** 16) - 1):
def getter(tags, key):
return list(map(text_type, tags[atomid]))
def setter(tags, key, value):
clamp = lambda x: int(min(max(min_value, x), max_value))
tags[atomid] = [clamp(v) for v in map(int, value)]
def deleter(tags, key):
del(tags[atomid])
cls.RegisterKey(key, getter, setter, deleter) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer default_parameter identifier binary_operator parenthesized_expression binary_operator integer integer integer block function_definition identifier parameters identifier identifier block return_statement call identifier argument_list call identifier argument_list identifier subscript identifier identifier function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier lambda lambda_parameters identifier call identifier argument_list call identifier argument_list call identifier argument_list identifier identifier identifier expression_statement assignment subscript identifier identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier identifier function_definition identifier parameters identifier identifier block delete_statement parenthesized_expression subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier | Register a scalar integer key. |
def _read_byte(self):
to_return = ""
if (self._mode == PROP_MODE_SERIAL):
to_return = self._serial.read(1)
elif (self._mode == PROP_MODE_TCP):
to_return = self._socket.recv(1)
elif (self._mode == PROP_MODE_FILE):
to_return = struct.pack("B", int(self._file.readline()))
_LOGGER.debug("READ: " + str(ord(to_return)))
self._logdata.append(ord(to_return))
if (len(self._logdata) > self._logdatalen):
self._logdata = self._logdata[len(self._logdata) - self._logdatalen:]
self._debug(PROP_LOGLEVEL_TRACE, "READ: " + str(ord(to_return)))
return to_return | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end if_statement parenthesized_expression comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list integer elif_clause parenthesized_expression comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list integer elif_clause parenthesized_expression comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier if_statement parenthesized_expression comparison_operator call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier slice binary_operator call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier binary_operator string string_start string_content string_end call identifier argument_list call identifier argument_list identifier return_statement identifier | Read a byte from input. |
def _format_week(self, name, type, a_per):
return '{},{},{}/{},{}/{}'.format(name, type, a_per.st_month, a_per.st_day,
a_per.end_month, a_per.end_day) | module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier | Format an AnalysisPeriod into string for the EPW header. |
def md5sum(filen):
with open(filen, 'rb') as fileh:
md5 = hashlib.md5(fileh.read())
return md5.hexdigest() | module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list | Calculate the md5sum of a file. |
def fibre_channel_wwns():
grains = {'fc_wwn': False}
if salt.utils.platform.is_linux():
grains['fc_wwn'] = _linux_wwns()
elif salt.utils.platform.is_windows():
grains['fc_wwn'] = _windows_wwns()
return grains | module function_definition identifier parameters block expression_statement assignment identifier dictionary pair string string_start string_content string_end false if_statement call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list elif_clause call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list return_statement identifier | Return list of fiber channel HBA WWNs |
def reload_module(module):
try:
reload(module)
except (ImportError, NameError):
import imp
imp.reload(module)
except (ImportError, NameError):
import importlib
importlib.reload(module) | module function_definition identifier parameters identifier block try_statement block expression_statement call identifier argument_list identifier except_clause tuple identifier identifier block import_statement dotted_name identifier expression_statement call attribute identifier identifier argument_list identifier except_clause tuple identifier identifier block import_statement dotted_name identifier expression_statement call attribute identifier identifier argument_list identifier | Reload the Python module |
def print_build_info(self):
if self.static_extension:
build_type = "static extension"
else:
build_type = "dynamic extension"
print("Build type: %s" % build_type)
print("Include path: %s" % " ".join(self.include_dirs))
print("Library path: %s" % " ".join(self.library_dirs))
print("Linked dynamic libraries: %s" % " ".join(self.libraries))
print("Linked static libraries: %s" % " ".join(self.extra_objects))
print("Extra compiler options: %s" % " ".join(self.extra_compile_args))
print("Extra linker options: %s" % " ".join(self.extra_link_args)) | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier | Prints the include and library path being used for debugging purposes. |
def save_composition(self, composition_form, *args, **kwargs):
if composition_form.is_for_update():
return self.update_composition(composition_form, *args, **kwargs)
else:
return self.create_composition(composition_form, *args, **kwargs) | module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement call attribute identifier identifier argument_list block return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier else_clause block return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier | Pass through to provider CompositionAdminSession.update_composition |
def _stab_log_data(self, timestamp, data, logconf):
print('[%d][%s]: %s' % (timestamp, logconf.name, data)) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier identifier | Callback froma the log API when data arrives |
def ignore_exceptions(f):
@functools.wraps(f)
def wrapped(*args, **kwargs):
try:
return f(*args, **kwargs)
except:
logging.exception("Ignoring exception in %r", f)
return wrapped | module function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier except_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier | Decorator catches and ignores any exceptions raised by this function. |
def load(self):
self._readSystemTable()
self._readOntologyTable()
self._readReferenceSetTable()
self._readReferenceTable()
self._readDatasetTable()
self._readReadGroupSetTable()
self._readReadGroupTable()
self._readVariantSetTable()
self._readCallSetTable()
self._readVariantAnnotationSetTable()
self._readFeatureSetTable()
self._readContinuousSetTable()
self._readBiosampleTable()
self._readIndividualTable()
self._readPhenotypeAssociationSetTable()
self._readRnaQuantificationSetTable() | module function_definition identifier parameters identifier block 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 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 expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | Loads this data repository into memory. |
def html_list(data):
if data is None:
return None
as_li = lambda v: "<li>%s</li>" % v
items = [as_li(v) for v in data]
return mark_safe("<ul>%s</ul>" % ''.join(items)) | module function_definition identifier parameters identifier block if_statement comparison_operator identifier none block return_statement none expression_statement assignment identifier lambda lambda_parameters identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier identifier return_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute string string_start string_end identifier argument_list identifier | Convert dict into formatted HTML. |
def client_getname(self, encoding=_NOTSET):
return self.execute(b'CLIENT', b'GETNAME', encoding=encoding) | module function_definition identifier parameters identifier default_parameter identifier identifier block return_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 | Get the current connection name. |
def message_channel(self, message):
self.log(None, message)
super(BaseBot, self).message_channel(message) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list none identifier expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier | We won't receive our own messages, so log them manually. |
def content_type(self):
if hasattr(self, '_content_type'):
return self._content_type
filename, extension = os.path.splitext(self._file_path)
if extension == '.csv':
self._content_type = 'text/csv'
elif extension == '.tsv':
self._content_type = 'text/tab-separated-values'
else:
self._content_type = 'text/plain'
return self._content_type | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier string string_start string_content string_end else_clause block expression_statement assignment attribute identifier identifier string string_start string_content string_end return_statement attribute identifier identifier | Returns the content-type value determined by file extension. |
def current_parameters(self):
current = []
for core_param in range(len(self.q)):
for approx_param in range(self.q[core_param].param_no):
current.append(self.q[core_param].vi_return_param(approx_param))
return np.array(current) | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list call identifier argument_list attribute identifier identifier block for_statement identifier call identifier argument_list attribute subscript attribute identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute subscript attribute identifier identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier | Obtains an array with the current parameters |
def create_character():
traits = character.CharacterCollection(character.fldr)
c = traits.generate_random_character()
print(c)
return c | module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list identifier return_statement identifier | create a random character |
def decompose_code(code):
code = "%-6s" % code
ind1 = code[3:4]
if ind1 == " ": ind1 = "_"
ind2 = code[4:5]
if ind2 == " ": ind2 = "_"
subcode = code[5:6]
if subcode == " ": subcode = None
return (code[0:3], ind1, ind2, subcode) | module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier subscript identifier slice integer integer if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier slice integer integer if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier slice integer integer if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier none return_statement tuple subscript identifier slice integer integer identifier identifier identifier | Decomposes a MARC "code" into tag, ind1, ind2, subcode |
def clean(self):
if not self.urlhash or 'url' in self._get_changed_fields():
self.urlhash = hash_url(self.url)
super(Reuse, self).clean() | module function_definition identifier parameters identifier block if_statement boolean_operator not_operator attribute identifier identifier comparison_operator string string_start string_content string_end call attribute identifier identifier argument_list block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list | Auto populate urlhash from url |
def variable(self):
name = "@py_assert" + str(next(self.variable_counter))
self.variables.append(name)
return name | module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end call identifier argument_list call identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier | Get a new variable. |
def OnTextColor(self, event):
color = event.GetValue().GetRGB()
post_command_event(self, self.TextColorMsg, color=color) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement call identifier argument_list identifier attribute identifier identifier keyword_argument identifier identifier | Text color choice event handler |
def match_repository_configuration(url, page_size=10, page_index=0, sort=""):
content = match_repository_configuration_raw(url, page_size, page_index, sort)
if content:
return utils.format_json_list(content) | module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier string string_start string_end block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier if_statement identifier block return_statement call attribute identifier identifier argument_list identifier | Search for Repository Configurations based on internal or external url with exact match |
def join(self):
self._jobs.join()
try:
return self._results, self._errors
finally:
self._clear() | module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list try_statement block return_statement expression_list attribute identifier identifier attribute identifier identifier finally_clause block expression_statement call attribute identifier identifier argument_list | Wait for all current tasks to be finished |
def geo_location(ip_address):
try:
type(ipaddress.ip_address(ip_address))
except ValueError:
return {}
data = requests.get(
'https://ipapi.co/{}/json/'.format(ip_address), timeout=5).json()
return data | module function_definition identifier parameters identifier block try_statement block expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier except_clause identifier block return_statement dictionary expression_statement assignment identifier call attribute call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier integer identifier argument_list return_statement identifier | Get the Geolocation of an IP address. |
def accounts_spec(self):
formatted_account_id = formatted(valid_account_id(), MergedOptionStringFormatter, expected_type=string_types)
return dictof(string_spec(), formatted_account_id) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier return_statement call identifier argument_list call identifier argument_list identifier | Spec for accounts options |
def rpc_call(payload):
corr_id = RPC_CLIENT.send_request(payload)
while RPC_CLIENT.queue[corr_id] is None:
sleep(0.1)
return RPC_CLIENT.queue[corr_id] | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier while_statement comparison_operator subscript attribute identifier identifier identifier none block expression_statement call identifier argument_list float return_statement subscript attribute identifier identifier identifier | Simple Flask implementation for making asynchronous Rpc calls. |
def render_files(self, root=None):
if root is None:
tmp = os.environ.get('TMP')
root = sys.path[1 if tmp and tmp in sys.path else 0]
items = []
for filename in os.listdir(root):
f,ext = os.path.splitext(filename)
if ext in ['.py', '.enaml']:
items.append(FILE_TMPL.format(
name=filename,
id=filename
))
return "".join(items) | module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier conditional_expression integer boolean_operator identifier comparison_operator identifier attribute identifier identifier integer expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier return_statement call attribute string string_start string_end identifier argument_list identifier | Render the file path as accordions |
def update_trainer(self, trainer, username=None, start_date=None, has_cheated=None, last_cheated=None, currently_cheats=None, statistics=None, daily_goal=None, total_goal=None, prefered=None):
args = locals()
if not isinstance(trainer, Trainer):
raise ValueError
url = api_url+'trainers/'+str(trainer.id)+'/'
payload = {
'last_modified': maya.now().iso8601()
}
for i in args:
if args[i] is not None and i not in ['self', 'trainer', 'start_date']:
payload[i] = args[i]
elif args[i] is not None and i=='start_date':
payload[i] = args[i].date().isoformat()
r = requests.patch(url, data=json.dumps(payload), headers=self.headers)
print(request_status(r))
r.raise_for_status()
return Trainer(r.json()) | module function_definition identifier parameters identifier 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 none block expression_statement assignment identifier call identifier argument_list if_statement not_operator call identifier argument_list identifier identifier block raise_statement identifier expression_statement assignment identifier binary_operator binary_operator binary_operator identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute call attribute identifier identifier argument_list identifier argument_list for_statement identifier identifier block if_statement boolean_operator comparison_operator subscript identifier identifier none comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier identifier subscript identifier identifier elif_clause boolean_operator comparison_operator subscript identifier identifier none comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier identifier call attribute call attribute subscript identifier identifier identifier argument_list identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement call identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement call identifier argument_list call attribute identifier identifier argument_list | Update parts of a trainer in a database |
def _darwin_current_arch(self):
if sys.platform == "darwin":
if sys.maxsize > 2 ** 32:
return platform.mac_ver()[2]
else:
return platform.processor() | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block if_statement comparison_operator attribute identifier identifier binary_operator integer integer block return_statement subscript call attribute identifier identifier argument_list integer else_clause block return_statement call attribute identifier identifier argument_list | Add Mac OS X support. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.