code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def device_mounted(self, device):
if not self._mounter.is_handleable(device):
return
browse_action = ('browse', _('Browse directory'),
self._mounter.browse, device)
terminal_action = ('terminal', _('Open terminal'),
self._mounter.terminal, device)
self._show_notification(
'device_mounted',
_('Device mounted'),
_('{0.ui_label} mounted on {0.mount_paths[0]}', device),
device.icon_name,
self._mounter._browser and browse_action,
self._mounter._terminal and terminal_action) | module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block return_statement expression_statement assignment identifier tuple string string_start string_content string_end call identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier identifier expression_statement assignment identifier tuple string string_start string_content string_end call identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end identifier attribute identifier identifier boolean_operator attribute attribute identifier identifier identifier identifier boolean_operator attribute attribute identifier identifier identifier identifier | Show mount notification for specified device object. |
def runGetFeatureSet(self, id_):
compoundId = datamodel.FeatureSetCompoundId.parse(id_)
dataset = self.getDataRepository().getDataset(compoundId.dataset_id)
featureSet = dataset.getFeatureSet(id_)
return self.runGetRequest(featureSet) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier | Runs a getFeatureSet request for the specified ID. |
def read_file(self, fasta_path):
fasta_dictionary = {}
for (identifier, sequence) in self.iterate_over_file(fasta_path):
fasta_dictionary[identifier] = sequence
return fasta_dictionary | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement tuple_pattern identifier identifier call attribute identifier identifier argument_list identifier block expression_statement assignment subscript identifier identifier identifier return_statement identifier | Read the contents of a FASTA file into a dictionary |
def keep_longest(head, update, down_path):
if update is None:
return 'f'
if head is None:
return 's'
return 'f' if len(head) >= len(update) else 's' | module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier none block return_statement string string_start string_content string_end if_statement comparison_operator identifier none block return_statement string string_start string_content string_end return_statement conditional_expression string string_start string_content string_end comparison_operator call identifier argument_list identifier call identifier argument_list identifier string string_start string_content string_end | Keep longest field among `head` and `update`. |
def log_wrapper(self):
log = logging.getLogger('client.py')
try:
debug = self.params["debug"]
log.setLevel(logging.DEBUG)
except KeyError:
log.setLevel(logging.INFO)
stream = logging.StreamHandler()
logformat = logging.Formatter(
'%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt='%b %d %H:%M:%S')
stream.setFormatter(logformat)
log.addHandler(stream)
return log | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Wrapper to set logging parameters for output |
def update_keys(self):
self.keys = self.queue_model.get_waiting_keys(self.queues)
if not self.keys:
self.log('No queues yet', level='warning')
self.last_update_keys = datetime.utcnow() | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list | Update the redis keys to listen for new jobs priorities. |
def isAuthorized(self, request):
restrictions = self.get_view_restrictions()
if restrictions and request is None:
return False
else:
return all(restriction.accept_request(request)
for restriction in restrictions) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator identifier comparison_operator identifier none block return_statement false else_clause block return_statement call identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier identifier | Is the user authorized for the requested action with this event? |
def copyHdfsFileToLocal(hdfsFilePath, localFilePath, hdfsClient, override=True):
if not hdfsClient.exists(hdfsFilePath):
raise Exception('HDFS file {} does not exist!'.format(hdfsFilePath))
try:
file_status = hdfsClient.get_file_status(hdfsFilePath)
if file_status.type != 'FILE':
raise Exception('HDFS file path {} is not a file'.format(hdfsFilePath))
except Exception as exception:
nni_log(LogType.Error, 'Get hdfs file {0} status error: {1}'.format(hdfsFilePath, str(exception)))
raise exception
if os.path.exists(localFilePath) and override:
os.remove(localFilePath)
try:
hdfsClient.copy_to_local(hdfsFilePath, localFilePath)
except Exception as exception:
nni_log(LogType.Error, 'Copy hdfs file {0} to {1} error: {2}'.format(hdfsFilePath, localFilePath, str(exception)))
raise exception
nni_log(LogType.Info, 'Successfully copied hdfs file {0} to {1}, {2} bytes'.format(hdfsFilePath, localFilePath, file_status.length)) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier true block if_statement not_operator call attribute 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 try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier call identifier argument_list identifier raise_statement identifier if_statement boolean_operator call attribute attribute identifier identifier identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier call identifier argument_list identifier raise_statement identifier expression_statement call identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier attribute identifier identifier | Copy file from HDFS to local |
def process_lists(self):
for l1_idx, obj1 in enumerate(self.l1):
for l2_idx, obj2 in enumerate(self.l2):
if self.equal(obj1, obj2):
self.matches.add((l1_idx, l2_idx)) | module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block if_statement call attribute identifier identifier argument_list identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier | Do any preprocessing of the lists. |
def add_user(config, group, username):
client = Client()
client.prepare_connection()
group_api = API(client)
try:
group_api.add_user(group, username)
except ldap_tools.exceptions.NoGroupsFound:
print("Group ({}) not found".format(group))
except ldap_tools.exceptions.TooManyResults:
print("Query for group ({}) returned multiple results.".format(
group))
except ldap3.TYPE_OR_VALUE_EXISTS:
print("{} already exists in {}".format(username, group)) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier except_clause attribute attribute identifier identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier except_clause attribute attribute identifier identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier except_clause attribute identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier | Add specified user to specified group. |
def insert_values(self):
if self._insert_values is None:
self._insert_values = self._prepare_insert(
tmpl=self._insert_values_tmpl,
placeholder_for_id=True,
record_class=self.record_class,
field_names=self.field_names,
)
return self._insert_values | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier true keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier return_statement attribute identifier identifier | SQL statement that inserts records without ID. |
def visit_boolean_query(self, node):
left = node.left.accept(self)
right = node.right.accept(self)
is_journal_keyword_op = isinstance(left, KeywordOp) and left.left == Keyword('journal')
if is_journal_keyword_op:
journal_and_volume_conjunction = _restructure_if_volume_follows_journal(left, right)
if journal_and_volume_conjunction:
return journal_and_volume_conjunction
return AndOp(left, right) if isinstance(node.bool_op, And) else OrOp(left, right) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier boolean_operator call identifier argument_list identifier identifier comparison_operator attribute identifier identifier call identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement identifier block return_statement identifier return_statement conditional_expression call identifier argument_list identifier identifier call identifier argument_list attribute identifier identifier identifier call identifier argument_list identifier identifier | Convert BooleanRule into AndOp or OrOp nodes. |
def reset_actions(self):
if self._driver.w3c:
self.w3c_actions.clear_actions()
self._actions = [] | module function_definition identifier parameters identifier block if_statement attribute attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier list | Clears actions that are already stored locally and on the remote end |
def do_list():
dirs = os.walk(CONFIG_ROOT).next()[1]
if dirs:
print "List of available configurations:\n"
for d in dirs:
print " * {}".format(d)
else:
print "No configurations available." | module function_definition identifier parameters block expression_statement assignment identifier subscript call attribute call attribute identifier identifier argument_list identifier identifier argument_list integer if_statement identifier block print_statement string string_start string_content escape_sequence string_end for_statement identifier identifier block print_statement call attribute string string_start string_content string_end identifier argument_list identifier else_clause block print_statement string string_start string_content string_end | CLI action "list configurations". |
def similarity_transformation(rot, mat):
return np.dot(rot, np.dot(mat, np.linalg.inv(rot))) | module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list identifier | R x M x R^-1 |
def put(self):
cred_payload = utils.uni_to_str(json.loads(request.get_data()))
return self.manager.update_credential(cred_payload) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement call attribute attribute identifier identifier identifier argument_list identifier | Update a credential by file path |
def _split_docker_uuid(uuid):
if uuid:
uuid = uuid.split(':')
if len(uuid) == 2:
tag = uuid[1]
repo = uuid[0]
return repo, tag
return None, None | module function_definition identifier parameters identifier block if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier integer return_statement expression_list identifier identifier return_statement expression_list none none | Split a smartos docker uuid into repo and tag |
def play(self):
if self.state == STATE_PAUSED:
self._player.set_state(Gst.State.PLAYING)
self.state = STATE_PLAYING | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier | Change state to playing. |
def diff_dict(dict1, dict2, ignore_missing=False):
unidict1 = dict_unicodeize(dict1)
unidict2 = dict_unicodeize(dict2)
if ((not ignore_missing) and (len(unidict1) != len(unidict2))) or \
(ignore_missing and (len(unidict1) >= len(unidict2))):
return True
for comp_k, comp_v in iteritems(unidict1):
if comp_k not in unidict2:
return True
else:
if comp_v != unidict2[comp_k]:
return True
return False | module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator parenthesized_expression boolean_operator parenthesized_expression not_operator identifier parenthesized_expression comparison_operator call identifier argument_list identifier call identifier argument_list identifier line_continuation parenthesized_expression boolean_operator identifier parenthesized_expression comparison_operator call identifier argument_list identifier call identifier argument_list identifier block return_statement true for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator identifier identifier block return_statement true else_clause block if_statement comparison_operator identifier subscript identifier identifier block return_statement true return_statement false | Performs a base type comparison between two dicts |
def getcolor(spec):
if isinstance(spec, str):
from matplotlib import colors
return asarray(colors.hex2color(colors.cnames[spec]))
else:
return spec | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block import_from_statement dotted_name identifier dotted_name identifier return_statement call identifier argument_list call attribute identifier identifier argument_list subscript attribute identifier identifier identifier else_clause block return_statement identifier | Turn optional color string spec into an array. |
def _erads2bt(self, data, channel_name):
cal_info = CALIB[self.platform_id][channel_name]
alpha = cal_info["ALPHA"]
beta = cal_info["BETA"]
wavenumber = CALIB[self.platform_id][channel_name]["VC"]
return (self._tl15(data, wavenumber) - beta) / alpha | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript subscript identifier attribute identifier identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript subscript subscript identifier attribute identifier identifier identifier string string_start string_content string_end return_statement binary_operator parenthesized_expression binary_operator call attribute identifier identifier argument_list identifier identifier identifier identifier | Computation based on effective radiance. |
def numlistbetween(num1, num2, option='list', listoption='string'):
if option == 'list':
if listoption == 'string':
output = ''
output += str(num1)
for currentnum in range(num1 + 1, num2 + 1):
output += ','
output += str(currentnum)
elif listoption == 'list':
output = []
for currentnum in range(num1, num2 + 1):
output.append(str(currentnum))
return output
elif option == 'count':
return num2 - num1 | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block if_statement comparison_operator 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 string string_start string_end expression_statement augmented_assignment identifier call identifier argument_list identifier for_statement identifier call identifier argument_list binary_operator identifier integer binary_operator identifier integer block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier call identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier list for_statement identifier call identifier argument_list identifier binary_operator identifier integer block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement binary_operator identifier identifier | List Or Count The Numbers Between Two Numbers |
def _discover_uri_type(uri):
parsed_uri = urlparse(uri)
if not parsed_uri.netloc:
if parsed_uri.scheme == 'data':
type_ = INLINE_REFERENCE_TYPE
else:
type_ = INTERNAL_REFERENCE_TYPE
else:
type_ = EXTERNAL_REFERENCE_TYPE
return type_ | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator attribute identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier identifier return_statement identifier | Given a ``uri``, determine if it is internal or external. |
def _handle_streamer_finished(self, index, succeeded, highest_ack):
self._logger.debug("Rolling back streamer %d after streaming, highest ack from streaming subsystem was %d", index, highest_ack)
self.acknowledge_streamer(index, highest_ack, False) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier false | Callback when a streamer finishes processing. |
def delete_record(self, record_id):
self._delete(
urljoin(self.base_url, "informationobjects/{}".format(record_id)),
expected_response=204,
)
return {"status": "Deleted"} | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier integer return_statement dictionary pair string string_start string_content string_end string string_start string_content string_end | Delete a record with record_id. |
def event_handler(msg: EventMsgDict) -> Event:
e = create_event_from_msg(msg)
if e.currentTarget is None:
if e.type not in ['mount', 'unmount']:
id = msg['currentTarget']['id']
logger.warning('No such element: wdom_id={}'.format(id))
return e
e.currentTarget.on_event_pre(e)
e.currentTarget.dispatchEvent(e)
return e | module function_definition identifier parameters typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block if_statement comparison_operator attribute identifier identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier | Handle events emitted on browser. |
async def message_fetcher_coroutine(self, loop):
Global.LOGGER.debug('registering callbacks for message fetcher coroutine')
self.isrunning = True
while self.isrunning:
loop.call_soon(self._fetch_messages)
loop.call_soon(self._perform_system_check)
await asyncio.sleep(Global.CONFIG_MANAGER.message_fetcher_sleep_interval)
Global.LOGGER.debug('message fetcher stopped') | 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 expression_statement assignment attribute identifier identifier true while_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement await call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end | Register callback for message fetcher coroutines |
def init_module(filesystem):
FakePath.filesystem = filesystem
FakePathlibModule.PureWindowsPath._flavour = _FakeWindowsFlavour(
filesystem)
FakePathlibModule.PurePosixPath._flavour = _FakePosixFlavour(filesystem) | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier call identifier argument_list identifier expression_statement assignment attribute attribute identifier identifier identifier call identifier argument_list identifier | Initializes the fake module with the fake file system. |
def live_chat_banner(context):
context = copy(context)
oldchat = LiveChat.chat_finder.get_last_live_chat()
if oldchat:
context['last_live_chat'] = {
'title': oldchat.title,
'chat_ends_at': oldchat.chat_ends_at,
'expert': oldchat.expert,
'url': reverse('livechat:show_archived_livechat')
}
chat = LiveChat.chat_finder.upcoming_live_chat()
if chat is not None:
context['live_chat_advert'] = {
'title': chat.title,
'description': chat.description,
'expert': chat.expert,
'commenting_closed': chat.comments_closed,
'cancelled': chat.is_cancelled,
'archived': chat.is_archived,
'in_progress': chat.is_in_progress(),
'url': reverse(
'livechat:show_livechat',
kwargs={
'slug': chat.slug}),
'archive_url':reverse('livechat:show_archived_livechat')
}
context['live_chat_advert']['datetime'] = {
'time': chat.chat_starts_at.time,
'date': chat.chat_starts_at.date
}
return context | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end dictionary 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 call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end dictionary 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 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 call attribute identifier identifier argument_list pair string string_start string_content string_end call identifier argument_list string string_start string_content string_end keyword_argument identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call identifier argument_list string string_start string_content string_end 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 attribute attribute identifier identifier identifier pair string string_start string_content string_end attribute attribute identifier identifier identifier return_statement identifier | Display any available live chats as advertisements. |
def _get_current_output(self):
output = []
for item in self.items:
out = self.py3.get_output(item)
if out and "separator" not in out[-1]:
out[-1]["separator"] = True
output += out
return output | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement boolean_operator identifier comparison_operator string string_start string_content string_end subscript identifier unary_operator integer block expression_statement assignment subscript subscript identifier unary_operator integer string string_start string_content string_end true expression_statement augmented_assignment identifier identifier return_statement identifier | Get child modules output. |
def short_path(path, cwd=None):
if not isinstance(path, str):
return path
if cwd is None:
cwd = os.getcwd()
abspath = os.path.abspath(path)
relpath = os.path.relpath(path, cwd)
if len(abspath) <= len(relpath):
return abspath
return relpath | module function_definition identifier parameters identifier default_parameter identifier none block if_statement not_operator call identifier argument_list identifier identifier block return_statement identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block return_statement identifier return_statement identifier | Return relative or absolute path name, whichever is shortest. |
def delete(self, item):
uri = "/%s/%s" % (self.uri_base, utils.get_id(item))
return self._delete(uri) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier | Deletes the specified item. |
def resample(grid, wl, flux):
flux_rs = (interpolate.interp1d(wl, flux))(grid)
return flux_rs | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call parenthesized_expression call attribute identifier identifier argument_list identifier identifier argument_list identifier return_statement identifier | Resample spectrum onto desired grid |
def refresh(self):
kwd = {
'pager': '',
'title': '',
}
self.render('list/post_list.html',
kwd=kwd,
userinfo=self.userinfo,
view=MPost.query_dated(10),
postrecs=MPost.query_dated(10),
format_date=tools.format_date,
cfg=CMS_CFG) | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end string string_start string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list integer keyword_argument identifier call attribute identifier identifier argument_list integer keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier | List the post of dated. |
def list_qos_policies(self, retrieve_all=True, **_params):
return self.list('policies', self.qos_policies_path,
retrieve_all, **_params) | module function_definition identifier parameters identifier default_parameter identifier true dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier dictionary_splat identifier | Fetches a list of all qos policies for a project. |
def dipole_moment(r_array, charge_array):
return np.sum(r_array * charge_array[:, np.newaxis], axis=0) | module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list binary_operator identifier subscript identifier slice attribute identifier identifier keyword_argument identifier integer | Return the dipole moment of a neutral system. |
def insert(self, item):
'Insert a new item. If equal keys are found, add to the left'
k = self._key(item)
i = bisect_left(self._keys, k)
self._keys.insert(i, k)
self._items.insert(i, item) | 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 assignment identifier call identifier argument_list attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier | Insert a new item. If equal keys are found, add to the left |
def redeem(self, account_code):
redemption_path = '%s/redeem' % (self.redemption_code)
if hasattr(self, '_url'):
url = urljoin(self._url, '/redeem')
else:
url = urljoin(recurly.base_uri(), self.collection_path + '/' + redemption_path)
recipient_account = _RecipientAccount(account_code=account_code)
return self.post(url, recipient_account) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end parenthesized_expression attribute identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list binary_operator binary_operator attribute identifier identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier | Redeem this gift card on the specified account code |
def download(self):
self.page = requests.get(self.url)
self.tree = html.fromstring(self.page.text) | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier | Downloads HTML from url. |
def _distance(self, x0, y0, x1, y1):
dx = x1-x0
dy = y1-y0
if self.pix:
dx[ dx > self.Lx/2 ] -= self.Lx
dx[ dx < -self.Lx/2 ] += self.Lx
if self.piy:
dy[ dy > self.Ly/2 ] -= self.Ly
dy[ dy < -self.Ly/2 ] += self.Ly
return dx, dy | module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier identifier if_statement attribute identifier identifier block expression_statement augmented_assignment subscript identifier comparison_operator identifier binary_operator attribute identifier identifier integer attribute identifier identifier expression_statement augmented_assignment subscript identifier comparison_operator identifier binary_operator unary_operator attribute identifier identifier integer attribute identifier identifier if_statement attribute identifier identifier block expression_statement augmented_assignment subscript identifier comparison_operator identifier binary_operator attribute identifier identifier integer attribute identifier identifier expression_statement augmented_assignment subscript identifier comparison_operator identifier binary_operator unary_operator attribute identifier identifier integer attribute identifier identifier return_statement expression_list identifier identifier | Utitlity function to compute distance between points. |
def cmd_dropobject(self, obj):
latlon = self.module('map').click_position
if self.last_click is not None and self.last_click == latlon:
return
self.last_click = latlon
if latlon is not None:
obj.setpos(latlon[0], latlon[1])
self.aircraft.append(obj) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier identifier block return_statement expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list subscript identifier integer subscript identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier | drop an object on the map |
def afx_adafactor():
hparams = afx_adam()
hparams.optimizer = "Adafactor"
hparams.learning_rate_schedule = "rsqrt_decay"
hparams.learning_rate_warmup_steps = 10000
return hparams | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier integer return_statement identifier | Adafactor with recommended learning rate schedule. |
def run_simulation(c1, c2):
print('running simulation...')
traits = character.CharacterCollection(character.fldr)
c1 = traits.generate_random_character()
c2 = traits.generate_random_character()
print(c1)
print(c2)
rules = battle.BattleRules(battle.rules_file)
b = battle.Battle(c1, c2, traits, rules, print_console='Yes')
print(b.status) | module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list identifier expression_statement call identifier argument_list 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 identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier | using character and planet, run the simulation |
def handle_cmd_options():
parser = OptionParser()
parser.add_option("-s", "--silent", action="store_true", dest="silent",
help="print any warnings", default=False)
(options, args) = parser.parse_args()
return options, args | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier false expression_statement assignment tuple_pattern identifier identifier call attribute identifier identifier argument_list return_statement expression_list identifier identifier | Get the options from the command line. |
def _get_response(self, **kwargs):
url = self.read_url + "?output=JSON&token=%s" % self.read_token
for key in kwargs:
if key and kwargs[key]:
val = kwargs[key]
if isinstance(val, (list, tuple)):
val = ",".join(val)
url += "&%s=%s" % (key, val)
self._api_url = url
req = urllib2.urlopen(url)
data = simplejson.loads(req.read())
self._api_raw_data = data
if data and data.get('error', None):
exceptions.BrightcoveError.raise_exception(
data['error'])
if data == None:
raise exceptions.NoDataFoundError(
"No data found for %s" % repr(kwargs))
return data | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier binary_operator attribute identifier identifier binary_operator string string_start string_content string_end attribute identifier identifier for_statement identifier identifier block if_statement boolean_operator identifier subscript identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier if_statement boolean_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end none block expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator identifier none block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier return_statement identifier | Make the GET request. |
def extern_clone_val(self, context_handle, val):
c = self._ffi.from_handle(context_handle)
return c.to_value(self._ffi.from_handle(val[0])) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript identifier integer | Clone the given Handle. |
def _get_thumbnail_url(image):
lhs, rhs = splitext(image.url)
lhs += THUMB_EXT
thumb_url = f'{lhs}{rhs}'
return thumb_url | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list attribute identifier identifier expression_statement augmented_assignment identifier identifier expression_statement assignment identifier string string_start interpolation identifier interpolation identifier string_end return_statement identifier | Given a large image, return the thumbnail url |
def mouseMoveEvent(self, event):
text = self.get_line_at(event.pos())
if get_error_match(text):
if not self.__cursor_changed:
QApplication.setOverrideCursor(QCursor(Qt.PointingHandCursor))
self.__cursor_changed = True
event.accept()
return
if self.__cursor_changed:
QApplication.restoreOverrideCursor()
self.__cursor_changed = False
self.QT_CLASS.mouseMoveEvent(self, event) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_statement call identifier argument_list identifier block if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list return_statement if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier false expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier | Show Pointing Hand Cursor on error messages |
def printout(*args, **kwargs):
color = kwargs.pop('color', {})
style = kwargs.pop('style', {})
prefx = kwargs.pop('prefix', '')
suffx = kwargs.pop('suffix', '')
ind = kwargs.pop('indent', 0)
print_args = []
for arg in args:
arg = str(arg)
arg = colorize(arg, **color)
arg = stylize(arg, **style)
arg = prefix(arg, prefx)
arg = indent(arg, ind)
arg += str(suffx)
print_args.append(arg)
print(*print_args, **kwargs) | module function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier dictionary_splat identifier expression_statement assignment identifier call identifier argument_list identifier dictionary_splat identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement augmented_assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list list_splat identifier dictionary_splat identifier | Print function with extra options for formating text in terminals. |
def init_edge_number(self) -> int:
return len(frozenset(frozenset(edge) for edge in self.initial_edges())) | module function_definition identifier parameters identifier type identifier block return_statement call identifier argument_list call identifier generator_expression call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list | Return the number of edges present in the non-compressed graph |
def spin_sx(self):
return conversions.secondary_spin(self.mass1, self.mass2, self.spin1x,
self.spin2x) | module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier | Returns the x-component of the spin of the secondary mass. |
def fix_e303(self, result):
delete_linenum = int(result['info'].split('(')[1].split(')')[0]) - 2
delete_linenum = max(1, delete_linenum)
cnt = 0
line = result['line'] - 2
modified_lines = []
while cnt < delete_linenum and line >= 0:
if not self.source[line].strip():
self.source[line] = ''
modified_lines.append(1 + line)
cnt += 1
line -= 1
return modified_lines | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list subscript call attribute subscript call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end integer identifier argument_list string string_start string_content string_end integer integer expression_statement assignment identifier call identifier argument_list integer identifier expression_statement assignment identifier integer expression_statement assignment identifier binary_operator subscript identifier string string_start string_content string_end integer expression_statement assignment identifier list while_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier integer block if_statement not_operator call attribute subscript attribute identifier identifier identifier identifier argument_list block expression_statement assignment subscript attribute identifier identifier identifier string string_start string_end expression_statement call attribute identifier identifier argument_list binary_operator integer identifier expression_statement augmented_assignment identifier integer expression_statement augmented_assignment identifier integer return_statement identifier | Remove extra blank lines. |
def build_directory():
if os.path.exists('locale'):
pass
else:
os.mkdir('locale')
if os.path.exists(WHOOSH_DB_DIR):
pass
else:
os.makedirs(WHOOSH_DB_DIR) | module function_definition identifier parameters block if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block pass_statement else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list identifier block pass_statement else_clause block expression_statement call attribute identifier identifier argument_list identifier | Build the directory for Whoosh database, and locale. |
def author_name_from_json(author_json):
"concatenate an author name from json data"
author_name = None
if author_json.get('type'):
if author_json.get('type') == 'group' and author_json.get('name'):
author_name = author_json.get('name')
elif author_json.get('type') == 'person' and author_json.get('name'):
if author_json.get('name').get('preferred'):
author_name = author_json.get('name').get('preferred')
return author_name | module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier none if_statement call attribute identifier identifier argument_list string string_start string_content string_end block if_statement boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end elif_clause boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block if_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end return_statement identifier | concatenate an author name from json data |
def profile(request):
serializer_class = registration_settings.PROFILE_SERIALIZER_CLASS
if request.method in ['POST', 'PUT', 'PATCH']:
partial = request.method == 'PATCH'
serializer = serializer_class(
instance=request.user,
data=request.data,
partial=partial,
)
serializer.is_valid(raise_exception=True)
serializer.save()
else:
serializer = serializer_class(instance=request.user)
return Response(serializer.data) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier comparison_operator attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier true expression_statement call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier return_statement call identifier argument_list attribute identifier identifier | Get or set user profile. |
def update_selected(self, linenum):
self.parents = _get_parents(self.funcs, linenum)
update_selected_cb(self.parents, self.method_cb)
self.parents = _get_parents(self.classes, linenum)
update_selected_cb(self.parents, self.class_cb) | module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier identifier expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier identifier expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier | Updates the dropdowns to reflect the current class and function. |
def geometryType(self):
if self._geomType is None:
if self.geometry is not None:
self._geomType = self.geometry.type
else:
self._geomType = "Table"
return self._geomType | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier else_clause block expression_statement assignment attribute identifier identifier string string_start string_content string_end return_statement attribute identifier identifier | returns the feature's geometry type |
def home(self) -> str:
self.hardware.home()
self.current_position = self._position()
return 'Homed' | module function_definition identifier parameters identifier type identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list return_statement string string_start string_content string_end | Return the robot to the home position and update the position tracker |
def publish(self, topic, payload = None, qos = 0, retain = False):
payloadlen = len(payload)
if topic is None or qos < 0 or qos > 2:
print "PUBLISH:err inval"
return NC.ERR_INVAL
if payloadlen > (250 * 1024 * 1204):
self.logger.error("PUBLISH:err payload len:%d", payloadlen)
return NC.ERR_PAYLOAD_SIZE
mid = self.mid_generate()
if qos in (0,1,2):
return self.send_publish(mid, topic, payload, qos, retain, False)
else:
self.logger.error("Unsupport QoS= %d", qos)
return NC.ERR_NOT_SUPPORTED | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier integer default_parameter identifier false block expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator boolean_operator comparison_operator identifier none comparison_operator identifier integer comparison_operator identifier integer block print_statement string string_start string_content string_end return_statement attribute identifier identifier if_statement comparison_operator identifier parenthesized_expression binary_operator binary_operator integer integer integer block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier return_statement attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier tuple integer integer integer block return_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier false else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier return_statement attribute identifier identifier | Publish some payload to server. |
def element(self, inp=None):
if inp is not None:
if isinstance(inp, np.ndarray):
return complex(inp.reshape([1])[0])
else:
return complex(inp)
else:
return complex(0.0, 0.0) | module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block if_statement call identifier argument_list identifier attribute identifier identifier block return_statement call identifier argument_list subscript call attribute identifier identifier argument_list list integer integer else_clause block return_statement call identifier argument_list identifier else_clause block return_statement call identifier argument_list float float | Return a complex number from ``inp`` or from scratch. |
def search(self, start_ts, end_ts):
for meta_collection_name in self._meta_collections():
meta_coll = self.meta_database[meta_collection_name]
for ts_ns_doc in meta_coll.find(
{"_ts": {"$lte": end_ts, "$gte": start_ts}}
):
yield ts_ns_doc | module function_definition identifier parameters identifier identifier identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier subscript attribute identifier identifier identifier for_statement identifier call attribute identifier identifier argument_list 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 block expression_statement yield identifier | Called to query Mongo for documents in a time range. |
def _get_taxids(self, taxids=None):
taxid_keys = set(self.taxid2asscs.keys())
return taxid_keys if taxids is None else set(taxids).intersection(taxid_keys) | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list return_statement conditional_expression identifier comparison_operator identifier none call attribute call identifier argument_list identifier identifier argument_list identifier | Return user-specified taxids or taxids in self.taxid2asscs |
def mr_dim_ind(self):
mr_dim_ind = self._cube.mr_dim_ind
if self._cube.ndim == 3:
if isinstance(mr_dim_ind, int):
if mr_dim_ind == 0:
return None
return mr_dim_ind - 1
elif isinstance(mr_dim_ind, tuple):
mr_dim_ind = tuple(i - 1 for i in mr_dim_ind if i)
return mr_dim_ind if len(mr_dim_ind) > 1 else mr_dim_ind[0]
return mr_dim_ind | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement comparison_operator attribute attribute identifier identifier identifier integer block if_statement call identifier argument_list identifier identifier block if_statement comparison_operator identifier integer block return_statement none return_statement binary_operator identifier integer elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier generator_expression binary_operator identifier integer for_in_clause identifier identifier if_clause identifier return_statement conditional_expression identifier comparison_operator call identifier argument_list identifier integer subscript identifier integer return_statement identifier | Get the correct index of the MR dimension in the cube slice. |
def graphql_impl(
schema,
source,
root_value,
context_value,
variable_values,
operation_name,
field_resolver,
type_resolver,
middleware,
execution_context_class,
) -> AwaitableOrValue[ExecutionResult]:
schema_validation_errors = validate_schema(schema)
if schema_validation_errors:
return ExecutionResult(data=None, errors=schema_validation_errors)
try:
document = parse(source)
except GraphQLError as error:
return ExecutionResult(data=None, errors=[error])
except Exception as error:
error = GraphQLError(str(error), original_error=error)
return ExecutionResult(data=None, errors=[error])
from .validation import validate
validation_errors = validate(schema, document)
if validation_errors:
return ExecutionResult(data=None, errors=validation_errors)
return execute(
schema,
document,
root_value,
context_value,
variable_values,
operation_name,
field_resolver,
type_resolver,
middleware,
execution_context_class,
) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block return_statement call identifier argument_list keyword_argument identifier none keyword_argument identifier identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block return_statement call identifier argument_list keyword_argument identifier none keyword_argument identifier list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier return_statement call identifier argument_list keyword_argument identifier none keyword_argument identifier list identifier import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier identifier if_statement identifier block return_statement call identifier argument_list keyword_argument identifier none keyword_argument identifier identifier return_statement call identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier | Execute a query, return asynchronously only if necessary. |
def running_apps(device_id):
if not is_valid_device_id(device_id):
abort(403)
if device_id not in devices:
abort(404)
return jsonify(running_apps=devices[device_id].running_apps) | module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier block expression_statement call identifier argument_list integer if_statement comparison_operator identifier identifier block expression_statement call identifier argument_list integer return_statement call identifier argument_list keyword_argument identifier attribute subscript identifier identifier identifier | Get running apps via HTTP GET. |
def _token_to_ids(self, token):
cache_location = hash(token) % self._cache_size
cache_key, cache_value = self._token_to_ids_cache[cache_location]
if cache_key == token:
return cache_value
subwords = self._token_to_subwords(token)
ids = []
for subword in subwords:
if subword == _UNDERSCORE_REPLACEMENT:
ids.append(len(self._subwords) + ord("_"))
continue
subword_id = self._subword_to_id.get(subword)
if subword_id is None:
ids.extend(self._byte_encode(subword))
else:
ids.append(subword_id)
self._token_to_ids_cache[cache_location] = (token, ids)
return ids | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator call identifier argument_list attribute identifier identifier call identifier argument_list string string_start string_content string_end continue_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier identifier tuple identifier identifier return_statement identifier | Convert a single token to a list of integer ids. |
def _read_checkpoint_vars(model_path):
reader = tf.train.NewCheckpointReader(model_path)
reader = CheckpointReaderAdapter(reader)
ckpt_vars = reader.get_variable_to_shape_map().keys()
return reader, set(ckpt_vars) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list return_statement expression_list identifier call identifier argument_list identifier | return a set of strings |
def remover(file_path):
if os.path.isfile(file_path):
os.remove(file_path)
return True
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
return True
else:
return False | module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement true elif_clause call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement true else_clause block return_statement false | Delete a file or directory path only if it exists. |
async def sdiff(self, keys, *args):
"Return the difference of sets specified by ``keys``"
args = list_or_args(keys, args)
return await self.execute_command('SDIFF', *args) | module function_definition identifier parameters identifier identifier list_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier return_statement await call attribute identifier identifier argument_list string string_start string_content string_end list_splat identifier | Return the difference of sets specified by ``keys`` |
def _delete_duplicates(l, keep_last):
seen=set()
result=[]
if keep_last:
l.reverse()
for i in l:
try:
if i not in seen:
result.append(i)
seen.add(i)
except TypeError:
result.append(i)
if keep_last:
result.reverse()
return result | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier list if_statement identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier identifier block try_statement block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list return_statement identifier | Delete duplicates from a sequence, keeping the first or last. |
def _parseAttrs(self, attrsStr):
attributes = dict()
for attrStr in self.SPLIT_ATTR_COL_RE.split(attrsStr):
name, vals = self._parseAttrVal(attrStr)
if name in attributes:
raise GFF3Exception(
"duplicated attribute name: {}".format(name),
self.fileName, self.lineNumber)
attributes[name] = vals
return attributes | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier attribute identifier identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier | Parse the attributes and values |
def delete(self, mail):
self.stats['mail_deleted'] += 1
if self.conf.dry_run:
logger.info("Skip deletion of {!r}.".format(mail))
return
logger.debug("Deleting {!r}...".format(mail))
os.unlink(mail.path)
logger.info("{} deleted.".format(mail.path)) | module function_definition identifier parameters identifier identifier block expression_statement augmented_assignment subscript attribute identifier identifier string string_start string_content string_end integer if_statement attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier | Delete a mail from the filesystem. |
def num2bytes(value, size):
res = []
for _ in range(size):
res.append(value & 0xFF)
value = value >> 8
assert value == 0
return bytes(bytearray(list(reversed(res)))) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list binary_operator identifier integer expression_statement assignment identifier binary_operator identifier integer assert_statement comparison_operator identifier integer return_statement call identifier argument_list call identifier argument_list call identifier argument_list call identifier argument_list identifier | Convert an unsigned integer to MSB-first bytes with specified size. |
def from_dict(ddict):
d = Definition(ddict['name'], ddict['line'], ddict['column'],
ddict['icon'], ddict['description'],
ddict['user_data'], ddict['path'])
for child_dict in ddict['children']:
d.children.append(Definition.from_dict(child_dict))
return d | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end for_statement identifier subscript identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement identifier | Deserializes a definition from a simple dict. |
def deploy(self, environment, target_name, stream_output=None):
try:
remote_server_command(
[
"rsync", "-lrv", "--safe-links", "--munge-links",
"--delete", "--inplace", "--chmod=ugo=rwX",
"--exclude=.datacats-environment",
"--exclude=.git",
"/project/.",
environment.deploy_target + ':' + target_name
],
environment, self,
include_project_dir=True,
stream_output=stream_output,
clean_up=True,
)
except WebCommandError as e:
raise DatacatsError(
"Unable to deploy `{0}` to remote server for some reason:\n"
" datacats was not able to copy data to the remote server"
.format((target_name,)),
parent_exception=e
)
try:
remote_server_command(
[
"ssh", environment.deploy_target, "install", target_name,
],
environment, self,
clean_up=True,
)
return True
except WebCommandError as e:
raise DatacatsError(
"Unable to deploy `{0}` to remote server for some reason:\n"
"datacats copied data to the server but failed to register\n"
"(or `install`) the new catalog"
.format((target_name,)),
parent_exception=e
) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block try_statement block expression_statement call identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end 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 binary_operator binary_operator attribute identifier identifier string string_start string_content string_end identifier identifier identifier keyword_argument identifier true keyword_argument identifier identifier keyword_argument identifier true except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content escape_sequence string_end string string_start string_content string_end identifier argument_list tuple identifier keyword_argument identifier identifier try_statement block expression_statement call identifier argument_list list string string_start string_content string_end attribute identifier identifier string string_start string_content string_end identifier identifier identifier keyword_argument identifier true return_statement true except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end string string_start string_content string_end identifier argument_list tuple identifier keyword_argument identifier identifier | Return True if deployment was successful |
def output_notebook(
d3js_url="//d3js.org/d3.v3.min",
requirejs_url="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js",
html_template=None
):
if html_template is None:
html_template = read_lib('html', 'setup')
setup_html = populate_template(
html_template,
d3js=d3js_url,
requirejs=requirejs_url
)
display_html(setup_html)
return | module function_definition identifier parameters default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call identifier argument_list identifier return_statement | Import required Javascript libraries to Jupyter Notebook. |
def contents_list_pairs(self):
return (tuple(getattr(self.generator, name) for name in names)
for names in self.info.get('contents_lists', [])) | module function_definition identifier parameters identifier block return_statement generator_expression call identifier generator_expression call identifier argument_list attribute identifier identifier identifier for_in_clause identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end list | Iterator over pairs of normal and hidden contents |
def similarity(self, other):
if len(self.items) > len(other.items):
first, second = self, other
else:
first, second = other, self
items = list(first.items)
length = len(items)
sim = self.Similarity(0.0 if length else 1.0)
cname = self.__class__.__name__
for num, perm in enumerate(permutations(items, length), start=1):
first.items = perm
aname = 'items-p{}'.format(num)
self.log(first, second, '%', cname=cname, aname=aname)
permutation_sim = super(Group, first).similarity(second)
self.log(first, second, '%', cname=cname, aname=aname,
result=permutation_sim)
sim = max(sim, permutation_sim)
logging.debug("highest similarity: %s", sim)
first.items = items
return sim | module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list identifier identifier else_clause block expression_statement assignment pattern_list identifier identifier expression_list identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list conditional_expression float identifier float expression_statement assignment identifier attribute attribute identifier identifier identifier for_statement pattern_list identifier identifier call identifier argument_list call identifier argument_list identifier identifier keyword_argument identifier integer block expression_statement assignment attribute identifier identifier identifier 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 identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier | Calculate similarity based on best matching permutation of items. |
def warp_object(self, tileMapObj):
print "Collision"
if tileMapObj.can_warp:
if self.map_association != self.exitWarp.map_association:
TileMapManager.load(exitWarp.map_association)
tileMapObj.parent.coords = self.exitWarp.coords | module function_definition identifier parameters identifier identifier block print_statement string string_start string_content string_end if_statement attribute identifier identifier block if_statement comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier | Warp the tile map object from one warp to another. |
def favstar(self, class_name, obj_id, action):
session = db.session()
FavStar = models.FavStar
count = 0
favs = session.query(FavStar).filter_by(
class_name=class_name, obj_id=obj_id,
user_id=g.user.get_id()).all()
if action == 'select':
if not favs:
session.add(
FavStar(
class_name=class_name,
obj_id=obj_id,
user_id=g.user.get_id(),
dttm=datetime.now(),
),
)
count = 1
elif action == 'unselect':
for fav in favs:
session.delete(fav)
else:
count = len(favs)
session.commit()
return json_success(json.dumps({'count': count})) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier integer expression_statement assignment identifier call attribute call attribute call attribute identifier identifier argument_list identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list identifier argument_list if_statement comparison_operator identifier string string_start string_content string_end block if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list expression_statement assignment identifier integer elif_clause comparison_operator identifier string string_start string_content string_end block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement call identifier argument_list call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier | Toggle favorite stars on Slices and Dashboard |
def fan_speed(self, value):
if value not in range(1, 10):
raise exceptions.RoasterValueError
self._fan_speed.value = value | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier call identifier argument_list integer integer block raise_statement attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier | Verifies the value is between 1 and 9 inclusively. |
def save(self):
with open(self.filename, 'w') as plist_file:
plist_file.write(str(self.soup)) | module function_definition identifier parameters identifier block 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 call identifier argument_list attribute identifier identifier | Save current property list representation to the original file. |
def Set(self, value, context=None):
if self.has_error: return
if self.value is None:
self.value = value
self._context["old_value"] = value
self._context.update({"old_" + k: v for k, v in context.items()})
elif self.value != value:
self.has_error = True
self._context["new_value"] = value
self._context.update({"new_" + k: v for k, v in context.items()}) | module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement attribute identifier identifier block return_statement if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list dictionary_comprehension pair binary_operator string string_start string_content string_end identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list elif_clause comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier true expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list dictionary_comprehension pair binary_operator string string_start string_content string_end identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list | Receives a value for the object and some context on its source. |
def update_fileserver(self, interval, backends):
def _do_update():
log.debug(
'Performing fileserver updates for items with an update '
'interval of %d', interval
)
for backend, update_args in six.iteritems(backends):
backend_name, update_func = backend
try:
if update_args:
log.debug(
'Updating %s fileserver cache for the following '
'targets: %s', backend_name, update_args
)
args = (update_args,)
else:
log.debug('Updating %s fileserver cache', backend_name)
args = ()
update_func(*args)
except Exception as exc:
log.exception(
'Uncaught exception while updating %s fileserver '
'cache', backend_name
)
log.debug(
'Completed fileserver updates for items with an update '
'interval of %d, waiting %d seconds', interval, interval
)
condition = threading.Condition()
_do_update()
while True:
with condition:
condition.wait(interval)
_do_update() | module function_definition identifier parameters identifier identifier identifier block function_definition identifier parameters 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 identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier identifier try_statement block if_statement identifier 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 identifier identifier expression_statement assignment identifier tuple identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier tuple expression_statement call identifier argument_list list_splat identifier except_clause as_pattern identifier as_pattern_target identifier 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 identifier expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list while_statement true block with_statement with_clause with_item identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list | Threading target which handles all updates for a given wait interval |
def _ods2code(self):
ods = ODSReader(self.ods_file, clonespannedcolumns=True)
tables = ods.sheets
for tab_id, table in enumerate(tables):
for row_id in xrange(len(table)):
for col_id in xrange(len(table[row_id])):
key = row_id, col_id, tab_id
text = unicode(table[row_id][col_id])
self.code_array[key] = text | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier keyword_argument identifier true expression_statement assignment identifier attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block for_statement identifier call identifier argument_list call identifier argument_list identifier block for_statement identifier call identifier argument_list call identifier argument_list subscript identifier identifier block expression_statement assignment identifier expression_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list subscript subscript identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier | Updates code in code_array |
def open(self, update=False):
filename = os.path.basename(self.source_path)
folder, _ext = os.path.splitext(filename)
self.path = os.path.sep.join([self.directory, folder, filename])
if not os.path.exists(os.path.dirname(self.path)):
os.makedirs(os.path.dirname(self.path))
if not os.path.isfile(self.path) or update:
with open(self.path, "wb") as fobj:
fobj.write(read(self.source_path))
self.file = open(self.path, 'rb')
self.pdf = CustomPDFReader(self.file) | module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list list attribute identifier identifier identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement boolean_operator not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier block 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 call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier | Opens pdf file to read from. |
def update_security_of_password(self, ID, data):
log.info('Update security of password %s with %s' % (ID, data))
self.put('passwords/%s/security.json' % ID, data) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier identifier | Update security of a password. |
def _ParseWtmp():
users = {}
wtmp_struct_size = UtmpStruct.GetSize()
filenames = glob.glob("/var/log/wtmp*") + ["/var/run/utmp"]
for filename in filenames:
try:
wtmp = open(filename, "rb").read()
except IOError:
continue
for offset in range(0, len(wtmp), wtmp_struct_size):
try:
record = UtmpStruct(wtmp[offset:offset + wtmp_struct_size])
except utils.ParsingError:
break
if record.ut_type != 7:
continue
try:
if users[record.ut_user] < record.tv_sec:
users[record.ut_user] = record.tv_sec
except KeyError:
users[record.ut_user] = record.tv_sec
return users | module function_definition identifier parameters block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list string string_start string_content string_end list string string_start string_content string_end for_statement identifier identifier block try_statement block expression_statement assignment identifier call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list except_clause identifier block continue_statement for_statement identifier call identifier argument_list integer call identifier argument_list identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list subscript identifier slice identifier binary_operator identifier identifier except_clause attribute identifier identifier block break_statement if_statement comparison_operator attribute identifier identifier integer block continue_statement try_statement block if_statement comparison_operator subscript identifier attribute identifier identifier attribute identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier attribute identifier identifier except_clause identifier block expression_statement assignment subscript identifier attribute identifier identifier attribute identifier identifier return_statement identifier | Parse wtmp and utmp and extract the last logon time. |
def received_message(self, m):
m = str(m)
logger.debug("Incoming upstream WS: %s", m)
uwsgi.websocket_send(m)
logger.debug("Send ok") | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end | Push upstream messages to downstream. |
def read_rcfile():
files = [
'{}/.millipederc'.format(os.environ.get('HOME')),
'/usr/local/etc/millipederc',
'/etc/millipederc',
]
for filepath in files:
if os.path.isfile(filepath):
with open(filepath) as rcfile:
return parse_rcfile(rcfile)
return {} | module function_definition identifier parameters block expression_statement assignment identifier list call attribute string string_start string_content string_end identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block 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 as_pattern_target identifier block return_statement call identifier argument_list identifier return_statement dictionary | Try to read a rcfile from a list of paths |
def getTextWords(page):
CheckParent(page)
dl = page.getDisplayList()
tp = dl.getTextPage()
l = tp._extractTextWords_AsList()
del dl
del tp
return l | module function_definition identifier parameters identifier block expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list delete_statement identifier delete_statement identifier return_statement identifier | Return the text words as a list with the bbox for each word. |
def apply(self, data, data_type='point', reference=None, **kwargs):
if data_type == 'point':
return self.apply_to_point(data)
elif data_type == 'vector':
return self.apply_to_vector(data)
elif data_type == 'image':
return self.apply_to_image(data, reference, **kwargs) | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier none dictionary_splat_pattern identifier block if_statement comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier | Apply transform to data |
def write_array_empty(self, key, value):
arr = np.empty((1,) * value.ndim)
self._handle.create_array(self.group, key, arr)
getattr(self.group, key)._v_attrs.value_type = str(value.dtype)
getattr(self.group, key)._v_attrs.shape = value.shape | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator tuple integer attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier identifier expression_statement assignment attribute attribute call identifier argument_list attribute identifier identifier identifier identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute attribute call identifier argument_list attribute identifier identifier identifier identifier identifier attribute identifier identifier | write a 0-len array |
async def insert(self, task: Task) -> None:
if not isinstance(task, Task):
task = task()
if task.name not in self.all_tasks:
task.tasky = self
self.all_tasks[task.name] = task
await task.init()
elif task != self.all_tasks[task.name]:
raise Exception('Duplicate task %s' % task.name)
if task.enabled:
task.task = asyncio.ensure_future(self.start_task(task))
self.running_tasks.add(task)
else:
task.task = None
return task | module function_definition identifier parameters identifier typed_parameter identifier type identifier type none block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier attribute identifier identifier identifier expression_statement await call attribute identifier identifier argument_list elif_clause comparison_operator identifier subscript attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment attribute identifier identifier none return_statement identifier | Insert the given task class into the Tasky event loop. |
def initialize(dirs):
if biolite and dirs.get("work"):
base_dir = utils.safe_makedir(os.path.join(dirs["work"], "provenance"))
p_db = os.path.join(base_dir, "biolite.db")
biolite.config.resources["database"] = p_db
biolite.database.connect() | module function_definition identifier parameters identifier block if_statement boolean_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment subscript attribute attribute identifier identifier identifier string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list | Initialize the biolite database to load provenance information. |
def mag_calibration(self):
self.calibration_state = self.CAL_MAG
self.mag_dialog = SK8MagDialog(self.sk8.get_imu(self.spinIMU.value()), self)
if self.mag_dialog.exec_() == QDialog.Rejected:
return
self.calculate_mag_calibration(self.mag_dialog.samples) | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block return_statement expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier | Perform magnetometer calibration for current IMU. |
def unlearnValue(self):
defaultValue = self.defaultParamInfo.get(field = "p_filename",
native = 0, prompt = 0)
self.choice.set(defaultValue) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier | Unlearn a parameter value by setting it back to its default |
def catch_no_credentials(message, **info):
try:
yield
except NoCredentialsError as error:
if hasattr(error, "response"):
info['error_code'] = error.response["ResponseMetadata"]["HTTPStatusCode"]
info['error_message'] = error.response["Error"]["Message"]
else:
info['error_message'] = error.fmt
raise BadAmazon(message, **info) | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block try_statement block expression_statement yield except_clause as_pattern identifier as_pattern_target identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier raise_statement call identifier argument_list identifier dictionary_splat identifier | Turn a NoCredentialsError into a BadAmazon |
def getConfigDirectory():
if platform.system() == 'Windows':
return os.path.join(os.environ['APPDATA'], 'ue4cli')
else:
return os.path.join(os.environ['HOME'], '.config', 'ue4cli') | module function_definition identifier parameters block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end else_clause block return_statement call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end | Determines the platform-specific config directory location for ue4cli |
def check_venv(self):
if self.zappa:
venv = self.zappa.get_current_venv()
else:
venv = Zappa.get_current_venv()
if not venv:
raise ClickException(
click.style("Zappa", bold=True) + " requires an " + click.style("active virtual environment", bold=True, fg="red") + "!\n" +
"Learn more about virtual environments here: " + click.style("http://docs.python-guide.org/en/latest/dev/virtualenvs/", bold=False, fg="cyan")) | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator identifier block raise_statement call identifier argument_list binary_operator binary_operator binary_operator binary_operator binary_operator call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true keyword_argument identifier string string_start string_content string_end string string_start string_content escape_sequence string_end string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier false keyword_argument identifier string string_start string_content string_end | Ensure we're inside a virtualenv. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.