code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def gate_angle(gate0: Gate, gate1: Gate) -> bk.BKTensor:
return fubini_study_angle(gate0.vec, gate1.vec) | module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type attribute identifier identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier | The Fubini-Study angle between gates |
def _list_available_rest_versions(self):
url = "https://{0}/api/api_version".format(self._target)
data = self._request("GET", url, reestablish_session=False)
return data["version"] | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier false return_statement subscript identifier string string_start string_content string_end | Return a list of the REST API versions supported by the array |
def check_rdn_deposits(raiden, user_deposit_proxy: UserDeposit):
while True:
rei_balance = user_deposit_proxy.effective_balance(raiden.address, "latest")
rdn_balance = to_rdn(rei_balance)
if rei_balance < MIN_REI_THRESHOLD:
click.secho(
(
f'WARNING\n'
f'Your account\'s RDN balance of {rdn_balance} is below the '
f'minimum threshold. Provided that you have either a monitoring '
f'service or a path finding service activated, your node is not going '
f'to be able to pay those services which may lead to denial of service or '
f'loss of funds.'
),
fg='red',
)
gevent.sleep(CHECK_RDN_MIN_DEPOSIT_INTERVAL) | module function_definition identifier parameters identifier typed_parameter identifier type identifier block while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list parenthesized_expression concatenated_string string string_start string_content escape_sequence string_end string string_start string_content escape_sequence interpolation identifier string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier | Check periodically for RDN deposits in the user-deposits contract |
def main():
arguments = docopt(__doc__, version=__version__)
if arguments['on']:
print 'Mr. Wolfe is at your service'
print 'If any of your programs run into an error'
print 'use wolfe $l'
print 'To undo the changes made by mr wolfe in your bashrc, do wolfe off'
on()
elif arguments['off']:
off()
print 'Mr. Wolfe says goodbye!'
elif arguments['QUERY']:
last(arguments['QUERY'], arguments['-g'] or arguments['--google'])
else:
print __doc__ | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier if_statement subscript identifier string string_start string_content string_end block print_statement string string_start string_content string_end print_statement string string_start string_content string_end print_statement string string_start string_content string_end print_statement string string_start string_content string_end expression_statement call identifier argument_list elif_clause subscript identifier string string_start string_content string_end block expression_statement call identifier argument_list print_statement string string_start string_content string_end elif_clause subscript identifier string string_start string_content string_end block expression_statement call identifier argument_list subscript identifier string string_start string_content string_end boolean_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end else_clause block print_statement identifier | i am winston wolfe, i solve problems |
def distribution(self, limit=1024):
res = self._qexec("%s, count(*) as __cnt" % self.name(), group="%s" % self.name(),
order="__cnt DESC LIMIT %d" % limit)
dist = []
cnt = self._table.size()
for i, r in enumerate(res):
dist.append(list(r) + [i, r[1] / float(cnt)])
self._distribution = pd.DataFrame(dist, columns=["value", "cnt", "r", "fraction"])
self._distribution.index = self._distribution.r
return self._distribution | module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call attribute identifier identifier argument_list keyword_argument identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list keyword_argument identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list binary_operator call identifier argument_list identifier list identifier binary_operator subscript identifier integer call identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier return_statement attribute identifier identifier | Build the distribution of distinct values |
def _save_token_cache(self, new_cache):
'Write out to the filesystem a cache of the OAuth2 information.'
logging.debug('Looking to write to local authentication cache...')
if not self._check_token_cache_type(new_cache):
logging.error('Attempt to save a bad value: %s', new_cache)
return
try:
logging.debug('About to write to fs cache file: %s',
self.token_cache_file)
with open(self.token_cache_file, 'wb') as f:
cPickle.dump(new_cache, f, protocol=cPickle.HIGHEST_PROTOCOL)
logging.debug('Finished dumping cache_value to fs cache file.')
except:
logging.exception(
'Could not successfully cache OAuth2 secrets on the file '
'system.') | module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement try_statement block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end except_clause block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end | Write out to the filesystem a cache of the OAuth2 information. |
def from_gene_ids_and_names(cls, gene_names: Dict[str, str]):
genes = [ExpGene(id_, name=name) for id_, name in gene_names.items()]
return cls.from_genes(genes) | module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier keyword_argument identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier | Initialize instance from gene IDs and names. |
def _path_to_keys(cls, path):
keys = _BaseFrame._path_to_keys_cache.get(path)
if keys is None:
keys = _BaseFrame._path_to_keys_cache[path] = path.split('.')
return keys | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier | Return a list of keys for a given path |
def delete_email_marketing_campaign(self, email_marketing_campaign):
url = self.api.join('/'.join([
self.EMAIL_MARKETING_CAMPAIGN_URL,
str(email_marketing_campaign.constant_contact_id)]))
response = url.delete()
self.handle_response_status(response)
return response | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list list attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Deletes a Constant Contact email marketing campaign. |
def volume_up(self):
try:
return bool(self.send_get_command(self._urls.command_volume_up))
except requests.exceptions.RequestException:
_LOGGER.error("Connection error: volume up command not sent.")
return False | module function_definition identifier parameters identifier block try_statement block return_statement call identifier argument_list call attribute identifier identifier argument_list attribute attribute identifier identifier identifier except_clause attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement false | Volume up receiver via HTTP get command. |
def bk_cyan(cls):
"Make the text background color cyan."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.BACKGROUND_MASK
wAttributes |= win32.BACKGROUND_CYAN
cls._set_text_attributes(wAttributes) | module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement augmented_assignment identifier unary_operator attribute identifier identifier expression_statement augmented_assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier | Make the text background color cyan. |
def json_loads(data):
try:
return json.loads(data, encoding='utf-8')
except TypeError:
return json.loads(data.decode('utf-8')) | module function_definition identifier parameters identifier block try_statement block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end except_clause identifier block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end | python-version-safe json.loads |
def preLoad(self):
logging.getLogger().debug("Preloading segment '%s'" % (self))
real_url = self.buildUrl()
cache_url = self.buildUrl(cache_friendly=True)
audio_data = self.download(real_url)
assert(audio_data)
__class__.cache[cache_url] = audio_data | module function_definition identifier parameters identifier block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier true expression_statement assignment identifier call attribute identifier identifier argument_list identifier assert_statement parenthesized_expression identifier expression_statement assignment subscript attribute identifier identifier identifier identifier | Store audio data in cache for fast playback. |
def __initialize_ui(self):
self.viewport().installEventFilter(ReadOnlyFilter(self))
if issubclass(type(self), QListView):
super(type(self), self).setUniformItemSizes(True)
elif issubclass(type(self), QTreeView):
super(type(self), self).setUniformRowHeights(True) | module function_definition identifier parameters identifier block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list call identifier argument_list identifier if_statement call identifier argument_list call identifier argument_list identifier identifier block expression_statement call attribute call identifier argument_list call identifier argument_list identifier identifier identifier argument_list true elif_clause call identifier argument_list call identifier argument_list identifier identifier block expression_statement call attribute call identifier argument_list call identifier argument_list identifier identifier identifier argument_list true | Initializes the View ui. |
def sources(self):
def set_bundle(s):
s._bundle = self
return s
return list(set_bundle(s) for s in self.dataset.sources) | module function_definition identifier parameters identifier block function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier identifier return_statement identifier return_statement call identifier generator_expression call identifier argument_list identifier for_in_clause identifier attribute attribute identifier identifier identifier | Iterate over downloadable sources |
def _save_one(self, model, ctx):
assert isinstance(ctx, ResourceQueryContext)
self._orm.add(model)
self._orm.flush() | module function_definition identifier parameters identifier identifier identifier block assert_statement call identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list | Saves the created instance. |
def _set(self, key, value, identity='image'):
if identity == 'image':
s = serialize_image_file(value)
else:
s = serialize(value)
self._set_raw(add_prefix(key, identity), s) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_content string_end block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier identifier | Serializing, prefix wrapper for _set_raw |
def db(self, connection_string=None):
connection_string = connection_string or self.settings["db"]
if not hasattr(self, "_db_conns"):
self._db_conns = {}
if not connection_string in self._db_conns:
self._db_conns[connection_string] = oz.sqlalchemy.session(connection_string=connection_string)
return self._db_conns[connection_string] | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier subscript attribute identifier identifier string string_start string_content string_end if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier dictionary if_statement not_operator comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier return_statement subscript attribute identifier identifier identifier | Gets the SQLALchemy session for this request |
def write_ensemble(ensemble, options):
size = len(ensemble)
filename = '%s_%s_queries.csv' % (options.outname, size)
file = os.path.join(os.getcwd(), filename)
f = open(file, 'w')
out = ', '.join(ensemble)
f.write(out)
f.close() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list | Prints out the ensemble composition at each size |
def to_vec4(self, isPoint):
vec4 = Vector4()
vec4.x = self.x
vec4.y = self.y
vec4.z = self.z
if isPoint:
vec4.w = 1
else:
vec4.w = 0
return vec4 | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement identifier block expression_statement assignment attribute identifier identifier integer else_clause block expression_statement assignment attribute identifier identifier integer return_statement identifier | Converts this vector3 into a vector4 instance. |
def init_db(self):
db_path = self.get_data_file("data.sqlite")
self.db = sqlite3.connect(db_path)
self.cursor = self.db.cursor()
self.db_exec(
) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | Init database and prepare tables |
def characteristics_resolved(self):
self._disconnect_characteristic_signals()
characteristics_regex = re.compile(self._path + '/char[0-9abcdef]{4}$')
managed_characteristics = [
char for char in self._object_manager.GetManagedObjects().items()
if characteristics_regex.match(char[0])]
self.characteristics = [Characteristic(
service=self,
path=c[0],
uuid=c[1]['org.bluez.GattCharacteristic1']['UUID']) for c in managed_characteristics]
self._connect_characteristic_signals() | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list if_clause call attribute identifier identifier argument_list subscript identifier integer expression_statement assignment attribute identifier identifier list_comprehension call identifier argument_list keyword_argument identifier identifier keyword_argument identifier subscript identifier integer keyword_argument identifier subscript subscript subscript identifier integer string string_start string_content string_end string string_start string_content string_end for_in_clause identifier identifier expression_statement call attribute identifier identifier argument_list | Called when all service's characteristics got resolved. |
def _get_sorted_mosaics(dicom_input):
sorted_mosaics = sorted(dicom_input, key=lambda x: x.AcquisitionNumber)
for index in range(0, len(sorted_mosaics) - 1):
if sorted_mosaics[index].AcquisitionNumber >= sorted_mosaics[index + 1].AcquisitionNumber:
raise ConversionValidationError("INCONSISTENT_ACQUISITION_NUMBERS")
return sorted_mosaics | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier for_statement identifier call identifier argument_list integer binary_operator call identifier argument_list identifier integer block if_statement comparison_operator attribute subscript identifier identifier identifier attribute subscript identifier binary_operator identifier integer identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier | Search all mosaics in the dicom directory, sort and validate them |
def _create_body(self, name, flavor=None, volume=None, databases=None,
users=None, version=None, type=None):
if flavor is None:
flavor = 1
flavor_ref = self.api._get_flavor_ref(flavor)
if volume is None:
volume = 1
if databases is None:
databases = []
if users is None:
users = []
body = {"instance": {
"name": name,
"flavorRef": flavor_ref,
"volume": {"size": volume},
"databases": databases,
"users": users,
}}
if type is not None or version is not None:
required = (type, version)
if all(required):
body['instance']['datastore'] = {"type": type, "version": version}
else:
raise exc.MissingCloudDatabaseParameter("Specifying a datastore"
" requires both the datastore type as well as the version.")
return body | 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 block if_statement comparison_operator identifier none block expression_statement assignment identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier integer if_statement comparison_operator identifier none block expression_statement assignment identifier list if_statement comparison_operator identifier none block expression_statement assignment identifier list expression_statement assignment identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none block expression_statement assignment identifier tuple identifier identifier if_statement call identifier argument_list identifier block expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier else_clause block raise_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement identifier | Used to create the dict required to create a Cloud Database instance. |
def dataset_exists(dataset_name):
dataset_dir = os.path.join(LIB_DIR, 'datasets')
dataset_path = os.path.join(dataset_dir, dataset_name)
return dataset_path if os.path.isdir(dataset_path) else None | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement conditional_expression identifier call attribute attribute identifier identifier identifier argument_list identifier none | If a dataset with the given name exists, return its absolute path; otherwise return None |
def post_deploy_assume_role(assume_role_config, context):
if isinstance(assume_role_config, dict):
if assume_role_config.get('post_deploy_env_revert'):
context.restore_existing_iam_env_vars() | module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list | Revert to previous credentials, if necessary. |
def search_function(root1, q, s, f, l, o='g'):
global links
links = search(q, o, s, f, l)
root1.destroy()
root1.quit() | module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier string string_start string_content string_end block global_statement identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | function to get links |
def sagemaker_timestamp():
moment = time.time()
moment_ms = repr(moment).split('.')[1][:3]
return time.strftime("%Y-%m-%d-%H-%M-%S-{}".format(moment_ms), time.gmtime(moment)) | module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript subscript call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end integer slice integer return_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call attribute identifier identifier argument_list identifier | Return a timestamp with millisecond precision. |
def data_filler_detailed_registration(self, number_of_rows, db):
try:
detailed_registration = db
data_list = list()
for i in range(0, number_of_rows):
post_det_reg = {
"id": rnd_id_generator(self),
"email": self.faker.safe_email(),
"password": self.faker.md5(raw_output=False),
"lastname": self.faker.last_name(),
"name": self.faker.first_name(),
"adress": self.faker.address(),
"phone": self.faker.phone_number()
}
detailed_registration.save(post_det_reg)
logger.warning(
'detailed_registration Commits are successful after write job!',
extra=d)
except Exception as e:
logger.error(e, extra=d) | module function_definition identifier parameters identifier identifier identifier block try_statement block expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list for_statement identifier call identifier argument_list integer identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end call identifier argument_list identifier pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list keyword_argument identifier false pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier | creates and fills the table with detailed regis. information |
def init_discrete_hmm_ml(C_full, nstates, reversible=True, stationary=True, active_set=None, P=None,
eps_A=None, eps_B=None, separate=None):
raise NotImplementedError('ML-initialization not yet implemented') | module function_definition identifier parameters identifier identifier default_parameter identifier true default_parameter identifier true default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block raise_statement call identifier argument_list string string_start string_content string_end | Initializes discrete HMM using maximum likelihood of observation counts |
def GenerateDSP(dspfile, source, env):
version_num = 6.0
if 'MSVS_VERSION' in env:
version_num, suite = msvs_parse_version(env['MSVS_VERSION'])
if version_num >= 10.0:
g = _GenerateV10DSP(dspfile, source, env)
g.Build()
elif version_num >= 7.0:
g = _GenerateV7DSP(dspfile, source, env)
g.Build()
else:
g = _GenerateV6DSP(dspfile, source, env)
g.Build() | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier float if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator identifier float block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list elif_clause comparison_operator identifier float block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list | Generates a Project file based on the version of MSVS that is being used |
def frame2expnum(frameid):
result = {}
parts = re.search('(?P<expnum>\d{7})(?P<type>\S)(?P<ccd>\d\d)', frameid)
assert parts is not None
result['expnum'] = parts.group('expnum')
result['ccd'] = parts.group('ccd')
result['version'] = parts.group('type')
return result | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier assert_statement comparison_operator identifier none expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier | Given a standard OSSOS frameid return the expnum, version and ccdnum as a dictionary. |
def yesno(self, s, yesno_callback, casual=False):
self.write(s)
self.yesno_callback = yesno_callback
self.yesno_casual = casual | module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier | Ask a question and prepare to receive a yes-or-no answer. |
def pid_exists(pid):
try:
os.kill(pid, 0)
except OSError as exc:
return exc.errno == errno.EPERM
else:
return True | module function_definition identifier parameters identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier integer except_clause as_pattern identifier as_pattern_target identifier block return_statement comparison_operator attribute identifier identifier attribute identifier identifier else_clause block return_statement true | Determines if a system process identifer exists in process table. |
def _is_protein(pe):
val = isinstance(pe, _bp('Protein')) or \
isinstance(pe, _bpimpl('Protein')) or \
isinstance(pe, _bp('ProteinReference')) or \
isinstance(pe, _bpimpl('ProteinReference'))
return val | module function_definition identifier parameters identifier block expression_statement assignment identifier boolean_operator boolean_operator boolean_operator call identifier argument_list identifier call identifier argument_list string string_start string_content string_end line_continuation call identifier argument_list identifier call identifier argument_list string string_start string_content string_end line_continuation call identifier argument_list identifier call identifier argument_list string string_start string_content string_end line_continuation call identifier argument_list identifier call identifier argument_list string string_start string_content string_end return_statement identifier | Return True if the element is a protein |
def _clean_doc(self, doc=None):
if doc is None:
doc = self.doc
resources = doc['Resources']
for arg in ['startline', 'headerlines', 'encoding']:
for e in list(resources.args):
if e.lower() == arg:
resources.args.remove(e)
for term in resources:
term['startline'] = None
term['headerlines'] = None
term['encoding'] = None
schema = doc['Schema']
for arg in ['altname', 'transform']:
for e in list(schema.args):
if e.lower() == arg:
schema.args.remove(e)
for table in self.doc.find('Root.Table'):
for col in table.find('Column'):
try:
col.value = col['altname'].value
except:
pass
col['altname'] = None
col['transform'] = None
return doc | module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end for_statement identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block for_statement identifier call identifier argument_list attribute identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end none expression_statement assignment subscript identifier string string_start string_content string_end none expression_statement assignment subscript identifier string string_start string_content string_end none expression_statement assignment identifier subscript identifier string string_start string_content string_end for_statement identifier list string string_start string_content string_end string string_start string_content string_end block for_statement identifier call identifier argument_list attribute identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block try_statement block expression_statement assignment attribute identifier identifier attribute subscript identifier string string_start string_content string_end identifier except_clause block pass_statement expression_statement assignment subscript identifier string string_start string_content string_end none expression_statement assignment subscript identifier string string_start string_content string_end none return_statement identifier | Clean the doc before writing it, removing unnecessary properties and doing other operations. |
def _process_get_status(self, data):
status = self._parse_status(data, self.cast_type)
is_new_app = self.app_id != status.app_id and self.app_to_launch
self.status = status
self.logger.debug("Received status: %s", self.status)
self._report_status()
if is_new_app and self.app_to_launch == self.app_id:
self.app_to_launch = None
self.app_launch_event.set()
if self.app_launch_event_function:
self.logger.debug("Start app_launch_event_function...")
self.app_launch_event_function()
self.app_launch_event_function = None | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list if_statement boolean_operator identifier comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier none expression_statement call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier none | Processes a received STATUS message and notifies listeners. |
def _setup_xauth(self):
handle, filename = tempfile.mkstemp(prefix='PyVirtualDisplay.',
suffix='.Xauthority')
self._xauth_filename = filename
os.close(handle)
self._old_xauth = {}
self._old_xauth['AUTHFILE'] = os.getenv('AUTHFILE')
self._old_xauth['XAUTHORITY'] = os.getenv('XAUTHORITY')
os.environ['AUTHFILE'] = os.environ['XAUTHORITY'] = filename
cookie = xauth.generate_mcookie()
xauth.call('add', self.new_display_var, '.', cookie) | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier dictionary expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end assignment subscript attribute identifier identifier string string_start string_content string_end identifier 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 attribute identifier identifier string string_start string_content string_end identifier | Set up the Xauthority file and the XAUTHORITY environment variable. |
def _pullMessage(self):
data = {
"msgs_recv": 0,
"sticky_token": self._sticky,
"sticky_pool": self._pool,
"clientid": self._client_id,
"state": "active" if self._markAlive else "offline",
}
return self._get(self.req_url.STICKY, data, fix_request=True, as_json=True) | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end conditional_expression string string_start string_content string_end attribute identifier identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier keyword_argument identifier true keyword_argument identifier true | Call pull api with seq value to get message data. |
def messages(self):
return int(math.floor(((self.limit.unit_value - self.level) /
self.limit.unit_value) * self.limit.value)) | module function_definition identifier parameters identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator parenthesized_expression binary_operator attribute attribute identifier identifier identifier attribute identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier | Return remaining messages before limiting. |
def getIRThreshold(self):
command = '$GO'
threshold = self.sendCommand(command)
if threshold[0] == 'NK':
return 0
else:
return float(threshold[2])/10 | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator subscript identifier integer string string_start string_content string_end block return_statement integer else_clause block return_statement binary_operator call identifier argument_list subscript identifier integer integer | Returns the IR temperature threshold in degrees Celcius, or 0 if no Threshold is set |
def destroy(self):
self._teardown_features()
focus_registry.unregister(self.widget)
widget = self.widget
if widget is not None:
del self.widget
super(QtGraphicsItem, self).destroy()
del self._widget_action | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block delete_statement attribute identifier identifier expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list delete_statement attribute identifier identifier | Destroy the underlying QWidget object. |
def extract_zipfile(archive_name, destpath):
"Unpack a zip file"
archive = zipfile.ZipFile(archive_name)
archive.extractall(destpath) | module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier | Unpack a zip file |
def create_package_set_from_installed(**kwargs):
if kwargs == {}:
kwargs = {"local_only": False, "skip": ()}
package_set = {}
problems = False
for dist in get_installed_distributions(**kwargs):
name = canonicalize_name(dist.project_name)
try:
package_set[name] = PackageDetails(dist.version, dist.requires())
except RequirementParseError as e:
logging.warning("Error parsing requirements for %s: %s", name, e)
problems = True
return package_set, problems | module function_definition identifier parameters dictionary_splat_pattern identifier block if_statement comparison_operator identifier dictionary block expression_statement assignment identifier dictionary pair string string_start string_content string_end false pair string string_start string_content string_end tuple expression_statement assignment identifier dictionary expression_statement assignment identifier false for_statement identifier call identifier argument_list dictionary_splat identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier try_statement block expression_statement assignment subscript identifier identifier call identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier true return_statement expression_list identifier identifier | Converts a list of distributions into a PackageSet. |
def add_rollback_panels(self):
from wagtailplus.utils.edit_handlers import add_panel_to_edit_handler
from wagtailplus.wagtailrollbacks.edit_handlers import HistoryPanel
for model in self.applicable_models:
add_panel_to_edit_handler(model, HistoryPanel, _(u'History')) | module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier import_from_statement dotted_name identifier identifier identifier dotted_name identifier for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list identifier identifier call identifier argument_list string string_start string_content string_end | Adds rollback panel to applicable model class's edit handlers. |
def check(self, instance):
self.log.debug("Running instance: %s", instance)
custom_tags = instance.get('tags', [])
if not instance or self.PROC_NAME not in instance:
raise GUnicornCheckError("instance must specify: %s" % self.PROC_NAME)
proc_name = instance.get(self.PROC_NAME)
master_procs = self._get_master_proc_by_name(proc_name, custom_tags)
worker_procs = self._get_workers_from_procs(master_procs)
working, idle = self._count_workers(worker_procs)
msg = "%s working and %s idle workers for %s" % (working, idle, proc_name)
status = AgentCheck.CRITICAL if working == 0 and idle == 0 else AgentCheck.OK
tags = ['app:' + proc_name] + custom_tags
self.service_check(self.SVC_NAME, status, tags=tags, message=msg)
self.log.debug("instance %s procs - working:%s idle:%s" % (proc_name, working, idle))
self.gauge("gunicorn.workers", working, tags + self.WORKING_TAGS)
self.gauge("gunicorn.workers", idle, tags + self.IDLE_TAGS) | module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list if_statement boolean_operator not_operator identifier comparison_operator attribute identifier identifier identifier 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 identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier identifier expression_statement assignment identifier conditional_expression attribute identifier identifier boolean_operator comparison_operator identifier integer comparison_operator identifier integer attribute identifier identifier expression_statement assignment identifier binary_operator list binary_operator string string_start string_content string_end identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier binary_operator identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier binary_operator identifier attribute identifier identifier | Collect metrics for the given gunicorn instance. |
def create_gnu_header(self, info, encoding, errors):
info["magic"] = GNU_MAGIC
buf = b""
if len(info["linkname"]) > LENGTH_LINK:
buf += self._create_gnu_long_header(info["linkname"], GNUTYPE_LONGLINK, encoding, errors)
if len(info["name"]) > LENGTH_NAME:
buf += self._create_gnu_long_header(info["name"], GNUTYPE_LONGNAME, encoding, errors)
return buf + self._create_header(info, GNU_FORMAT, encoding, errors) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier string string_start string_end if_statement comparison_operator call identifier argument_list subscript identifier string string_start string_content string_end identifier block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier identifier identifier if_statement comparison_operator call identifier argument_list subscript identifier string string_start string_content string_end identifier block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier identifier identifier return_statement binary_operator identifier call attribute identifier identifier argument_list identifier identifier identifier identifier | Return the object as a GNU header block sequence. |
def itemlist(item, sep, suppress_trailing=True):
return condense(item + ZeroOrMore(addspace(sep + item)) + Optional(sep.suppress() if suppress_trailing else sep)) | module function_definition identifier parameters identifier identifier default_parameter identifier true block return_statement call identifier argument_list binary_operator binary_operator identifier call identifier argument_list call identifier argument_list binary_operator identifier identifier call identifier argument_list conditional_expression call attribute identifier identifier argument_list identifier identifier | Create a list of items seperated by seps. |
def add_function(self, function):
function = self.build_function(function)
if function.name in self.functions:
raise FunctionAlreadyRegistered(function.name)
self.functions[function.name] = function | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list attribute identifier identifier expression_statement assignment subscript attribute identifier identifier attribute identifier identifier identifier | Adds the function to the list of registered functions. |
def compile_path(self, path, write=True, package=None, *args, **kwargs):
path = fixpath(path)
if not isinstance(write, bool):
write = fixpath(write)
if os.path.isfile(path):
if package is None:
package = False
destpath = self.compile_file(path, write, package, *args, **kwargs)
return [destpath] if destpath is not None else []
elif os.path.isdir(path):
if package is None:
package = True
return self.compile_folder(path, write, package, *args, **kwargs)
else:
raise CoconutException("could not find source path", path) | module function_definition identifier parameters identifier identifier default_parameter identifier true default_parameter identifier none list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier false expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier list_splat identifier dictionary_splat identifier return_statement conditional_expression list identifier comparison_operator identifier none list elif_clause call attribute attribute identifier identifier identifier argument_list identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier true return_statement call attribute identifier identifier argument_list identifier identifier identifier list_splat identifier dictionary_splat identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end identifier | Compile a path and returns paths to compiled files. |
def find_closest_match(target_track, tracks):
track = None
tracks_with_match_ratio = [(
track,
get_similarity(target_track.artist, track.artist),
get_similarity(target_track.name, track.name),
) for track in tracks]
sorted_tracks = sorted(
tracks_with_match_ratio,
key=lambda t: (t[1], t[2]),
reverse=True
)
if sorted_tracks:
track = sorted_tracks[0][0]
return track | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none expression_statement assignment identifier list_comprehension tuple identifier call identifier argument_list attribute identifier identifier attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier tuple subscript identifier integer subscript identifier integer keyword_argument identifier true if_statement identifier block expression_statement assignment identifier subscript subscript identifier integer integer return_statement identifier | Return closest match to target track |
def process_casefile(cls, workdir):
record = cls(None, workdir)
obj = {}
with open(os.path.join(workdir, 'frames', 'frames.json')) as f:
obj = json.load(f)
record.device_info = obj['device']
record.frames = obj['frames']
casedir = os.path.join(workdir, 'case')
with open(os.path.join(casedir, 'case.json')) as f:
record.case_draft = json.load(f)
for f in os.listdir(casedir):
if f != 'case.json':
os.remove(os.path.join(casedir, f))
record.generate_script() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list none identifier expression_statement assignment identifier dictionary with_statement with_clause with_item as_pattern call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list | generate code from case.json |
def _parse_chat(self, chat):
if chat.data['type'] == 'chat':
if chat.data['player'] in [p.player_name for i, p in self._players()]:
self._chat.append(chat.data)
elif chat.data['type'] == 'ladder':
self._ladder = chat.data['ladder']
elif chat.data['type'] == 'rating':
if chat.data['rating'] != 1600:
self._ratings[chat.data['player']] = chat.data['rating'] | module function_definition identifier parameters identifier identifier block if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end list_comprehension attribute identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier elif_clause comparison_operator subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end elif_clause comparison_operator subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end integer block expression_statement assignment subscript attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end | Parse a chat message. |
def compute(self, *args, **kwargs)->[Any, None]:
return super().compute(
self.compose, *args, **kwargs
) | module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier type list identifier none block return_statement call attribute call identifier argument_list identifier argument_list attribute identifier identifier list_splat identifier dictionary_splat identifier | Compose and evaluate the function. |
def timeit(func):
@wraps(func)
def timer_wrapper(*args, **kwargs):
with Timer() as timer:
result = func(*args, **kwargs)
return result, timer
return timer_wrapper | module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block with_statement with_clause with_item as_pattern call identifier argument_list as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier return_statement expression_list identifier identifier return_statement identifier | Returns the number of seconds that a function took along with the result |
def mk_travis_config():
t = dedent(
)
jobs = [env for env in parseconfig(None, 'tox').envlist
if not env.startswith('cov-')]
jobs += 'coverage',
print(t.format(jobs=('\n'.join((' - TOX_JOB=' + job)
for job in jobs)))) | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier list_comprehension identifier for_in_clause identifier attribute call identifier argument_list none string string_start string_content string_end identifier if_clause not_operator call attribute identifier identifier argument_list string string_start string_content string_end expression_statement augmented_assignment identifier expression_list string string_start string_content string_end expression_statement call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier parenthesized_expression call attribute string string_start string_content escape_sequence string_end identifier generator_expression parenthesized_expression binary_operator string string_start string_content string_end identifier for_in_clause identifier identifier | Generate configuration for travis. |
def clone_workspace(self) -> None:
def clone_clicked(text):
if text:
command = Workspace.CloneWorkspaceCommand(self, text)
command.perform()
self.document_controller.push_undo_command(command)
self.pose_get_string_message_box(caption=_("Enter a name for the workspace"), text=self.__workspace.name,
accepted_fn=clone_clicked, accepted_text=_("Clone"),
message_box_id="clone_workspace") | module function_definition identifier parameters identifier type none block function_definition identifier parameters identifier block if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end | Pose a dialog to name and clone a workspace. |
def _recurse_config_to_dict(t_data):
if not isinstance(t_data, type(None)):
if isinstance(t_data, list):
t_list = []
for i in t_data:
t_list.append(_recurse_config_to_dict(i))
return t_list
elif isinstance(t_data, dict):
t_dict = {}
for k, v in six.iteritems(t_data):
t_dict[k] = _recurse_config_to_dict(v)
return t_dict
else:
if hasattr(t_data, '__dict__'):
return _recurse_config_to_dict(t_data.__dict__)
else:
return _serializer(t_data) | module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier call identifier argument_list none block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier return_statement identifier else_clause block if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement call identifier argument_list attribute identifier identifier else_clause block return_statement call identifier argument_list identifier | helper function to recurse through a vim object and attempt to return all child objects |
def list_apis(awsclient):
client_api = awsclient.get_client('apigateway')
apis = client_api.get_rest_apis()['items']
for api in apis:
print(json2table(api)) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement call identifier argument_list call identifier argument_list identifier | List APIs in account. |
def _input_handler_decorator(self, data):
input_handler = getattr(self, self.__InputHandler)
input_parts = [
self.Parameters['taxonomy_file'],
input_handler(data),
self.Parameters['training_set_id'],
self.Parameters['taxonomy_version'],
self.Parameters['modification_info'],
self.ModelDir,
]
return self._commandline_join(input_parts) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier list subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list identifier subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier | Adds positional parameters to selected input_handler's results. |
def supported_auth_methods(self) -> List[str]:
return [auth for auth in self.AUTH_METHODS if auth in self.server_auth_methods] | module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block return_statement list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator identifier attribute identifier identifier | Get all AUTH methods supported by the both server and by us. |
def __manage_connections(self, ccallbacks=None):
_logger.info("Running client.")
if self.__message_handler_cls is not None:
self.__message_handler = self.__message_handler_cls(
self.__election,
ccallbacks)
for (context, node) in self.__node_couplets_s:
self.__start_connection(context, node, ccallbacks)
self.__wait_for_one_server_connection()
self.__is_alive = True
self.__ready_ev.set()
self.__audit_connections(ccallbacks)
self.__join_connections()
_logger.info("Connection management has stopped.")
self.__is_alive = False | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier identifier for_statement tuple_pattern identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier false | This runs as the main connection management greenlet. |
def _decode_sensor_data(properties):
b64_input = ""
for s in properties.get('payload'):
b64_input += s
decoded = base64.b64decode(b64_input)
data = zlib.decompress(decoded)
points = []
i = 0
while i < len(data):
points.append({
'timestamp': int(1e3 * ArloBaseStation._parse_statistic(
data[i:(i + 4)], 0)),
'temperature': ArloBaseStation._parse_statistic(
data[(i + 8):(i + 10)], 1),
'humidity': ArloBaseStation._parse_statistic(
data[(i + 14):(i + 16)], 1),
'airQuality': ArloBaseStation._parse_statistic(
data[(i + 20):(i + 22)], 1)
})
i += 22
return points | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list expression_statement assignment identifier integer while_statement comparison_operator identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call identifier argument_list binary_operator float call attribute identifier identifier argument_list subscript identifier slice identifier parenthesized_expression binary_operator identifier integer integer pair string string_start string_content string_end call attribute identifier identifier argument_list subscript identifier slice parenthesized_expression binary_operator identifier integer parenthesized_expression binary_operator identifier integer integer pair string string_start string_content string_end call attribute identifier identifier argument_list subscript identifier slice parenthesized_expression binary_operator identifier integer parenthesized_expression binary_operator identifier integer integer pair string string_start string_content string_end call attribute identifier identifier argument_list subscript identifier slice parenthesized_expression binary_operator identifier integer parenthesized_expression binary_operator identifier integer integer expression_statement augmented_assignment identifier integer return_statement identifier | Decode, decompress, and parse the data from the history API |
def count_discussions_handler(sender, **kwargs):
if kwargs.get('instance') and kwargs.get('created'):
return
comment = 'comment' in kwargs and kwargs['comment'] or kwargs['instance']
entry = comment.content_object
if isinstance(entry, Entry):
entry.comment_count = entry.comments.count()
entry.pingback_count = entry.pingbacks.count()
entry.trackback_count = entry.trackbacks.count()
entry.save(update_fields=[
'comment_count', 'pingback_count', 'trackback_count']) | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block return_statement expression_statement assignment identifier boolean_operator boolean_operator comparison_operator string string_start string_content string_end identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list keyword_argument identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end | Update the count of each type of discussion on an entry. |
def doi_uri_to_doi(value):
"Strip the uri schema from the start of DOI URL strings"
if value is None:
return value
replace_values = ['http://dx.doi.org/', 'https://dx.doi.org/',
'http://doi.org/', 'https://doi.org/']
for replace_value in replace_values:
value = value.replace(replace_value, '')
return value | module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement comparison_operator identifier none block return_statement identifier expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_end return_statement identifier | Strip the uri schema from the start of DOI URL strings |
def current_ime(self):
dumpout = self.adb_shell(['dumpsys', 'input_method'])
m = _INPUT_METHOD_RE.search(dumpout)
if m:
return m.group(1) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement call attribute identifier identifier argument_list integer | Get current input method |
def _deserialize(self, value, attr, data):
if value:
value = self._format_phone_number(value, attr)
return super(PhoneNumberField, self)._deserialize(value, attr, data) | module function_definition identifier parameters identifier identifier identifier identifier block if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier identifier | Format and validate the phone number using libphonenumber. |
def build_single(mode):
if mode == 'force':
amode = ['-a']
else:
amode = []
if executable.endswith('uwsgi'):
_executable = executable[:-5] + 'python'
else:
_executable = executable
p = subprocess.Popen([_executable, '-m', 'nikola', 'build'] + amode,
stderr=subprocess.PIPE)
p.wait()
rl = p.stderr.readlines()
try:
out = ''.join(rl)
except TypeError:
out = ''.join(l.decode('utf-8') for l in rl)
return (p.returncode == 0), out | module function_definition identifier parameters identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier list string string_start string_content string_end else_clause block expression_statement assignment identifier list if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier binary_operator subscript identifier slice unary_operator integer string string_start string_content string_end else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator list identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute string string_start string_end identifier argument_list identifier except_clause identifier block expression_statement assignment identifier call attribute string string_start string_end identifier generator_expression call attribute identifier identifier argument_list string string_start string_content string_end for_in_clause identifier identifier return_statement expression_list parenthesized_expression comparison_operator attribute identifier identifier integer identifier | Build, in the single-user mode. |
def retrieve_records(self, timeperiod, include_running,
include_processed, include_noop, include_failed, include_disabled):
resp = dict()
try:
query = unit_of_work_dao.QUERY_GET_FREERUN_SINCE(timeperiod, include_running,
include_processed, include_noop, include_failed)
records_list = self.uow_dao.run_query(query)
if len(records_list) == 0:
self.logger.warning('MX: no Freerun UOW records found since {0}.'.format(timeperiod))
for uow_record in records_list:
handler_key = split_schedulable_name(uow_record.process_name)
if handler_key not in self.freerun_handlers:
continue
thread_handler = self.freerun_handlers[handler_key]
if not include_disabled and not thread_handler.process_entry.is_on:
continue
resp[uow_record.key] = uow_record.document
except Exception as e:
self.logger.error('MX Dashboard FreerunStatements error: {0}'.format(e))
return resp | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block continue_statement expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement boolean_operator not_operator identifier not_operator attribute attribute identifier identifier identifier block continue_statement expression_statement assignment subscript identifier attribute identifier identifier attribute identifier identifier 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 identifier return_statement identifier | method looks for suitable UOW records and returns them as a dict |
def translate_gitlab_exception(func):
@functools.wraps(func)
def _wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except gitlab.GitlabError as e:
status_to_exception = {
401: UnauthorizedError,
404: NotFoundError,
}
exc_class = status_to_exception.get(e.response_code, GitClientError)
raise exc_class(str(e), status_code=e.response_code)
return _wrapper | module function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement assignment identifier dictionary pair integer identifier pair integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier raise_statement call identifier argument_list call identifier argument_list identifier keyword_argument identifier attribute identifier identifier return_statement identifier | Decorator to catch GitLab-specific exceptions and raise them as GitClientError exceptions. |
def encrypt_file(file_path, sender, recipients):
"Returns encrypted binary file content if successful"
for recipient_key in recipients:
crypto.assert_type_and_length('recipient_key', recipient_key, (str, crypto.UserLock))
crypto.assert_type_and_length("sender_key", sender, crypto.UserLock)
if (not os.path.exists(file_path)) or (not os.path.isfile(file_path)):
raise OSError("Specified path does not point to a valid file: {}".format(file_path))
_, filename = os.path.split(file_path)
with open(file_path, "rb") as I:
crypted = crypto.MiniLockFile.new(filename, I.read(), sender, recipients)
return crypted.contents | module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier tuple identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier attribute identifier identifier if_statement boolean_operator parenthesized_expression not_operator call attribute attribute identifier identifier identifier argument_list identifier parenthesized_expression not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier return_statement attribute identifier identifier | Returns encrypted binary file content if successful |
def add_sparql_line_nums(sparql):
lines = sparql.split("\n")
return "\n".join(["%s %s" % (i + 1, line) for i, line in enumerate(lines)]) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list list_comprehension binary_operator string string_start string_content string_end tuple binary_operator identifier integer identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier | Returns a sparql query with line numbers prepended |
def setReturnParameter(self, name, type, namespace=None, element_type=0):
parameter = ParameterInfo(name, type, namespace, element_type)
self.retval = parameter
return parameter | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier integer block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier | Set the return parameter description for the call info. |
def arg_name(self):
if self.constraint is bool and self.value:
return '--no-%s' % self.name.replace('_', '-')
return '--%s' % self.name.replace('_', '-') | module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator attribute identifier identifier identifier attribute identifier identifier block return_statement binary_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement binary_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end | Returns the name of the parameter as a command line flag |
def unwraplist(v):
if is_list(v):
if len(v) == 0:
return None
elif len(v) == 1:
return unwrap(v[0])
else:
return unwrap(v)
else:
return unwrap(v) | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier block if_statement comparison_operator call identifier argument_list identifier integer block return_statement none elif_clause comparison_operator call identifier argument_list identifier integer block return_statement call identifier argument_list subscript identifier integer else_clause block return_statement call identifier argument_list identifier else_clause block return_statement call identifier argument_list identifier | LISTS WITH ZERO AND ONE element MAP TO None AND element RESPECTIVELY |
def load_key_file(self):
self.client_key = None
if self.key_file_path:
key_file_path = self.key_file_path
else:
key_file_path = self._get_key_file_path()
key_dict = {}
logger.debug('load keyfile from %s', key_file_path);
if os.path.isfile(key_file_path):
with open(key_file_path, 'r') as f:
raw_data = f.read()
if raw_data:
key_dict = json.loads(raw_data)
logger.debug('getting client_key for %s from %s', self.ip, key_file_path);
if self.ip in key_dict:
self.client_key = key_dict[self.ip] | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier none if_statement attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement call attribute attribute identifier identifier identifier argument_list 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 if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier subscript identifier attribute identifier identifier | Try to load the client key for the current ip. |
def print_violations(self, violations):
for v in violations:
line_nr = v.line_nr if v.line_nr else "-"
self.display.e(u"{0}: {1}".format(line_nr, v.rule_id), exact=True)
self.display.ee(u"{0}: {1} {2}".format(line_nr, v.rule_id, v.message), exact=True)
if v.content:
self.display.eee(u"{0}: {1} {2}: \"{3}\"".format(line_nr, v.rule_id, v.message, v.content),
exact=True)
else:
self.display.eee(u"{0}: {1} {2}".format(line_nr, v.rule_id, v.message), exact=True) | module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment identifier conditional_expression attribute identifier identifier attribute identifier identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier keyword_argument identifier true expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier true if_statement attribute identifier 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 identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier true else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier true | Print a given set of violations to the standard error output |
def _parse_tokenize(self, rule):
for token in self._TOKENIZE_RE.split(rule):
if not token or token.isspace():
continue
clean = token.lstrip('(')
for i in range(len(token) - len(clean)):
yield '(', '('
if not clean:
continue
else:
token = clean
clean = token.rstrip(')')
trail = len(token) - len(clean)
lowered = clean.lower()
if lowered in ('and', 'or', 'not'):
yield lowered, clean
elif clean:
if len(token) >= 2 and ((token[0], token[-1]) in
[('"', '"'), ("'", "'")]):
yield 'string', token[1:-1]
else:
yield 'check', self._parse_check(clean)
for i in range(trail):
yield ')', ')' | module function_definition identifier parameters identifier identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list identifier block if_statement boolean_operator not_operator identifier call attribute identifier identifier argument_list block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier call identifier argument_list binary_operator call identifier argument_list identifier call identifier argument_list identifier block expression_statement yield expression_list string string_start string_content string_end string string_start string_content string_end if_statement not_operator identifier block continue_statement else_clause block expression_statement assignment identifier 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 call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement yield expression_list identifier identifier elif_clause identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier integer parenthesized_expression comparison_operator tuple subscript identifier integer subscript identifier unary_operator integer list 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 expression_statement yield expression_list string string_start string_content string_end subscript identifier slice integer unary_operator integer else_clause block expression_statement yield expression_list string string_start string_content string_end call attribute identifier identifier argument_list identifier for_statement identifier call identifier argument_list identifier block expression_statement yield expression_list string string_start string_content string_end string string_start string_content string_end | Tokenizer for the policy language. |
def circ_permutation(items):
permutations = []
for i in range(len(items)):
permutations.append(items[i:] + items[:i])
return permutations | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list binary_operator subscript identifier slice identifier subscript identifier slice identifier return_statement identifier | Calculate the circular permutation for a given list of items. |
def multi_iter(iterable, count=2):
if not isinstance(
iterable,
(
list, tuple, set,
FutureChainResults,
collections.Sequence, collections.Set, collections.Mapping, collections.MappingView
)):
iterable = SafeTee(iterable, n=count)
return (iter(iterable) for _ in range(count)) | module function_definition identifier parameters identifier default_parameter identifier integer block if_statement not_operator call identifier argument_list identifier tuple identifier identifier identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier return_statement generator_expression call identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier | Return `count` independent, thread-safe iterators for `iterable` |
def start(self):
self._useV2 = self.cf.platform.get_protocol_version() >= 4
logger.debug('[%d]: Using V2 protocol: %d', self.port, self._useV2)
logger.debug('[%d]: Start fetching...', self.port)
self.cf.add_port_callback(self.port, self._new_packet_cb)
self.state = GET_TOC_INFO
pk = CRTPPacket()
pk.set_header(self.port, TOC_CHANNEL)
if self._useV2:
pk.data = (CMD_TOC_INFO_V2,)
self.cf.send_packet(pk, expected_reply=(CMD_TOC_INFO_V2,))
else:
pk.data = (CMD_TOC_INFO,)
self.cf.send_packet(pk, expected_reply=(CMD_TOC_INFO,)) | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier comparison_operator call attribute attribute attribute identifier identifier identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier tuple identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier tuple identifier else_clause block expression_statement assignment attribute identifier identifier tuple identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier tuple identifier | Initiate fetching of the TOC. |
def compiled_init_func(self):
def get_column_assignment(column_name):
return ALCHEMY_TEMPLATES.col_assignment.safe_substitute(col_name=column_name)
def get_compiled_args(arg_name):
return ALCHEMY_TEMPLATES.func_arg.safe_substitute(arg_name=arg_name)
join_string = "\n" + self.tab + self.tab
column_assignments = join_string.join([get_column_assignment(n) for n in self.columns])
init_args = ", ".join(get_compiled_args(n) for n in self.columns)
return ALCHEMY_TEMPLATES.init_function.safe_substitute(col_assignments=column_assignments,
init_args=init_args) | module function_definition identifier parameters identifier block function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier binary_operator binary_operator string string_start string_content escape_sequence string_end attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension call identifier argument_list identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier attribute identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier | Returns compiled init function |
def parse_config(config_file):
try:
with open(config_file, 'r') as f:
return yaml.load(f)
except IOError:
print "Configuration file {} not found or not readable.".format(config_file)
raise | module function_definition identifier parameters identifier block try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier except_clause identifier block print_statement call attribute string string_start string_content string_end identifier argument_list identifier raise_statement | Parse a YAML configuration file |
def expand_models(self, target, data):
if isinstance(data, dict):
data = data.values()
for chunk in data:
if target in chunk:
yield self.init_target_object(target, chunk)
else:
for key, item in chunk.items():
yield self.init_single_object(key, item) | module function_definition identifier parameters identifier identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement yield call attribute identifier identifier argument_list identifier identifier else_clause block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement yield call attribute identifier identifier argument_list identifier identifier | Generates all objects from given data. |
def _selectedRepoRow(self):
selectedModelIndexes = \
self.reposTableWidget.selectionModel().selectedRows()
for index in selectedModelIndexes:
return index.row() | module function_definition identifier parameters identifier block expression_statement assignment identifier line_continuation call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list for_statement identifier identifier block return_statement call attribute identifier identifier argument_list | Return the currently select repo |
def collect(self, name, arr):
name = py_str(name)
if self.include_layer is not None and not self.include_layer(name):
return
handle = ctypes.cast(arr, NDArrayHandle)
arr = NDArray(handle, writable=False).copyto(cpu())
if self.logger is not None:
self.logger.info("Collecting layer %s output of shape %s" % (name, arr.shape))
if name in self.nd_dict:
self.nd_dict[name].append(arr)
else:
self.nd_dict[name] = [arr] | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator comparison_operator attribute identifier identifier none not_operator call attribute identifier identifier argument_list identifier block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute call identifier argument_list identifier keyword_argument identifier false identifier argument_list call identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier else_clause block expression_statement assignment subscript attribute identifier identifier identifier list identifier | Callback function for collecting layer output NDArrays. |
def transitions(accountable):
transitions = accountable.issue_transitions().get('transitions')
headers = ['id', 'name']
if transitions:
rows = [[v for k, v in sorted(t.items()) if k in headers]
for t in transitions]
rows.insert(0, headers)
print_table(SingleTable(rows))
else:
click.secho(
'No transitions found for {}'.format(accountable.issue_key),
fg='red'
) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end if_statement identifier block expression_statement assignment identifier list_comprehension list_comprehension identifier for_in_clause pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list if_clause comparison_operator identifier identifier for_in_clause identifier identifier expression_statement call attribute identifier identifier argument_list integer identifier expression_statement call identifier argument_list call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier keyword_argument identifier string string_start string_content string_end | List all possible transitions for a given issue. |
def _draw_tile_layer(self, tile, layer_name, c_filters, colour, t_filters, x, y, bg):
left = (x + self._screen.width // 4) * 2
top = y + self._screen.height // 2
if (left > self._screen.width or left + self._size * 2 < 0 or
top > self._screen.height or top + self._size < 0):
return 0
try:
_layer = tile[layer_name]
_extent = float(_layer["extent"])
except KeyError:
return 0
for _feature in _layer["features"]:
try:
if c_filters and _feature["properties"]["class"] not in c_filters:
continue
if (t_filters and _feature["type"] not in t_filters and
_feature["properties"]["type"] not in t_filters):
continue
self._draw_feature(
_feature, _extent, colour, bg,
(x + self._screen.width // 4) * 2, y + self._screen.height // 2)
except KeyError:
pass
return 1 | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier binary_operator attribute attribute identifier identifier identifier integer integer expression_statement assignment identifier binary_operator identifier binary_operator attribute attribute identifier identifier identifier integer if_statement parenthesized_expression boolean_operator boolean_operator boolean_operator comparison_operator identifier attribute attribute identifier identifier identifier comparison_operator binary_operator identifier binary_operator attribute identifier identifier integer integer comparison_operator identifier attribute attribute identifier identifier identifier comparison_operator binary_operator identifier attribute identifier identifier integer block return_statement integer try_statement block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end except_clause identifier block return_statement integer for_statement identifier subscript identifier string string_start string_content string_end block try_statement block if_statement boolean_operator identifier comparison_operator subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier block continue_statement if_statement parenthesized_expression boolean_operator boolean_operator identifier comparison_operator subscript identifier string string_start string_content string_end identifier comparison_operator subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier block continue_statement expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier binary_operator parenthesized_expression binary_operator identifier binary_operator attribute attribute identifier identifier identifier integer integer binary_operator identifier binary_operator attribute attribute identifier identifier identifier integer except_clause identifier block pass_statement return_statement integer | Draw the visible geometry in the specified map tile. |
def dot_format(out, graph, name="digraph"):
out.write("digraph %s {\n" % name)
for step, deps in each_step(graph):
for dep in deps:
out.write(" \"%s\" -> \"%s\";\n" % (step, dep))
out.write("}\n") | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end tuple identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end | Outputs the graph using the graphviz "dot" format. |
def remove_overlaps(self, ufos, glyph_filter=lambda g: len(g)):
from booleanOperations import union, BooleanOperationsError
for ufo in ufos:
font_name = self._font_name(ufo)
logger.info("Removing overlaps for " + font_name)
for glyph in ufo:
if not glyph_filter(glyph):
continue
contours = list(glyph)
glyph.clearContours()
try:
union(contours, glyph.getPointPen())
except BooleanOperationsError:
logger.error(
"Failed to remove overlaps for %s: %r", font_name, glyph.name
)
raise | module function_definition identifier parameters identifier identifier default_parameter identifier lambda lambda_parameters identifier call identifier argument_list identifier block import_from_statement dotted_name identifier dotted_name identifier dotted_name identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier for_statement identifier identifier block if_statement not_operator call identifier argument_list identifier block continue_statement expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list try_statement block expression_statement call identifier argument_list identifier call attribute identifier identifier argument_list except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier attribute identifier identifier raise_statement | Remove overlaps in UFOs' glyphs' contours. |
def save_resource(self, name, resource, pushable=False):
'Saves an object such that it can be used by other tests.'
if pushable:
self.pushable_resources[name] = resource
else:
self.resources[name] = resource | module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block expression_statement string string_start string_content string_end if_statement identifier block expression_statement assignment subscript attribute identifier identifier identifier identifier else_clause block expression_statement assignment subscript attribute identifier identifier identifier identifier | Saves an object such that it can be used by other tests. |
def add_relation(app_f, app_t, weight=1):
recs = TabRel.select().where(
(TabRel.post_f_id == app_f) & (TabRel.post_t_id == app_t)
)
if recs.count() > 1:
for record in recs:
MRelation.delete(record.uid)
if recs.count() == 0:
uid = tools.get_uuid()
entry = TabRel.create(
uid=uid,
post_f_id=app_f,
post_t_id=app_t,
count=1,
)
return entry.uid
elif recs.count() == 1:
MRelation.update_relation(app_f, app_t, weight)
else:
return False | module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list binary_operator parenthesized_expression comparison_operator attribute identifier identifier identifier parenthesized_expression comparison_operator attribute identifier identifier identifier if_statement comparison_operator call attribute identifier identifier argument_list integer block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator call attribute identifier identifier argument_list integer block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier integer return_statement attribute identifier identifier elif_clause comparison_operator call attribute identifier identifier argument_list integer block expression_statement call attribute identifier identifier argument_list identifier identifier identifier else_clause block return_statement false | Adding relation between two posts. |
def clean(self):
return Text(self.__text_cleaner.clean(self[TEXT]), **self.__kwargs) | module function_definition identifier parameters identifier block return_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript identifier identifier dictionary_splat attribute identifier identifier | Return a copy of this Text instance with invalid characters removed. |
def _op(self, _, obj, app):
if obj.responses == None: return
tmp = {}
for k, v in six.iteritems(obj.responses):
if isinstance(k, six.integer_types):
tmp[str(k)] = v
else:
tmp[k] = v
obj.update_field('responses', tmp) | module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator attribute identifier identifier none block return_statement expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment subscript identifier call identifier argument_list identifier identifier else_clause block expression_statement assignment subscript identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier | convert status code in Responses from int to string |
def _generate_SAX(self):
sections = {}
self.value_min = self.time_series.min()
self.value_max = self.time_series.max()
section_height = (self.value_max - self.value_min) / self.precision
for section_number in range(self.precision):
sections[section_number] = self.value_min + section_number * section_height
self.sax = ''.join(self._generate_SAX_single(sections, value) for value in self.time_series.values) | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment subscript identifier identifier binary_operator attribute identifier identifier binary_operator identifier identifier expression_statement assignment attribute identifier identifier call attribute string string_start string_end identifier generator_expression call attribute identifier identifier argument_list identifier identifier for_in_clause identifier attribute attribute identifier identifier identifier | Generate SAX representation for all values of the time series. |
def contents(self):
data = find_dataset_path(
self.name, data_home=self.data_home, ext=None
)
return os.listdir(data) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier none return_statement call attribute identifier identifier argument_list identifier | Contents returns a list of the files in the data directory. |
def url(url: str, method: str):
try:
url_rule, params = (current_app.url_map.bind('localhost')
.match(url, method=method, return_rule=True))
except (NotFound, MethodNotAllowed)\
as e:
click.secho(str(e), fg='white', bg='red')
else:
headings = ('Method(s)', 'Rule', 'Params', 'Endpoint', 'View', 'Options')
print_table(headings,
[(_get_http_methods(url_rule),
url_rule.rule if url_rule.strict_slashes
else url_rule.rule + '[/]',
_format_dict(params),
url_rule.endpoint,
_get_rule_view(url_rule),
_format_rule_options(url_rule))],
['<' if i > 0 else '>' for i, col in enumerate(headings)],
primary_column_idx=1) | module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier block try_statement block expression_statement assignment pattern_list identifier identifier parenthesized_expression call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier true except_clause as_pattern tuple identifier identifier line_continuation as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end else_clause block expression_statement assignment identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call identifier argument_list identifier list tuple call identifier argument_list identifier conditional_expression attribute identifier identifier attribute identifier identifier binary_operator attribute identifier identifier string string_start string_content string_end call identifier argument_list identifier attribute identifier identifier call identifier argument_list identifier call identifier argument_list identifier list_comprehension conditional_expression string string_start string_content string_end comparison_operator identifier integer string string_start string_content string_end for_in_clause pattern_list identifier identifier call identifier argument_list identifier keyword_argument identifier integer | Show details for a specific URL. |
def _sync_tasks(self, tasks_json):
for task_json in tasks_json:
task_id = task_json['id']
project_id = task_json['project_id']
if project_id not in self.projects:
continue
project = self.projects[project_id]
self.tasks[task_id] = Task(task_json, project) | module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block continue_statement expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list identifier identifier | Populate the user's tasks from a JSON encoded list. |
def detectEncodingMeta(self):
buffer = self.rawStream.read(self.numBytesMeta)
assert isinstance(buffer, bytes)
parser = EncodingParser(buffer)
self.rawStream.seek(0)
encoding = parser.getEncoding()
if encoding is not None and encoding.name in ("utf-16be", "utf-16le"):
encoding = lookupEncoding("utf-8")
return encoding | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier assert_statement call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator identifier none comparison_operator attribute identifier identifier tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end return_statement identifier | Report the encoding declared by the meta element |
def find_all(self, string, callback):
for index, output in self.iter(string):
callback(index, output) | module function_definition identifier parameters identifier identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block expression_statement call identifier argument_list identifier identifier | Wrapper on iter method, callback gets an iterator result |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.