code stringlengths 51 2.34k | sequence stringlengths 1.16k 13.1k | docstring stringlengths 11 171 |
|---|---|---|
def root(self):
drive = self.drive
for device in self._daemon:
if device.is_drive:
continue
if device.is_toplevel and device.drive == drive:
return device
return None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'root'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Get the top level block device in the ancestry of this device. |
def variance_K(K, verbose=False):
c = SP.sum((SP.eye(len(K)) - (1.0 / len(K)) * SP.ones(K.shape)) * SP.array(K))
scalar = (len(K) - 1) / c
return 1.0/scalar | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'variance_K'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'K... | estimate the variance explained by K |
def sort_catalogue_chronologically(self):
dec_time = self.get_decimal_time()
idx = np.argsort(dec_time)
if np.all((idx[1:] - idx[:-1]) > 0.):
return
self.select_catalogue_events(idx) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_catalogue_chronologically'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': ... | Sorts the catalogue into chronological order |
def local_within_block_attention(x,
self_attention_bias,
hparams,
attention_type="local_within_block_mask_right",
q_padding="VALID",
kv_padding="VALID"):
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'local_within_block_attention'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': ... | Local within block self attention. |
def str2int(string_with_int):
return int("".join([char for char in string_with_int if char in string.digits]) or 0) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'str2int'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'string_wi... | Collect digits from a string |
def namer(cls, imageUrl, pageUrl):
index = int(compile(r'id=(\d+)').search(pageUrl).group(1))
ext = imageUrl.rsplit('.', 1)[1]
return "SnowFlakes-%d.%s" % (index, ext) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'namer'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'c... | Use strip index number for image name. |
def remove_group_roles(request, group, domain=None, project=None):
client = keystoneclient(request, admin=True)
roles = client.roles.list(group=group, domain=domain, project=project)
for role in roles:
remove_group_role(request, role=role.id, group=group,
domain=domain, pro... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_group_roles'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'childre... | Removes all roles from a group on a domain or project. |
def all(self):
self._check_layout()
return LayoutSlice(self.layout, slice(0, len(self.layout.fields), 1)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'all'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id'... | Returns all layout objects of first level of depth |
def printmp(msg):
filler = (80 - len(msg)) * ' '
print(msg + filler, end='\r')
sys.stdout.flush() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'printmp'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'... | Print temporarily, until next print overrides it. |
def getParamsByName(elem, name):
name = StripParamName(name)
return elem.getElements(lambda e: (e.tagName == ligolw.Param.tagName) and (e.Name == name)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getParamsByName'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Return a list of params with name name under elem. |
def _request_helper(self, url, params, method):
try:
if method == 'POST':
return self._request_post_helper(url, params)
elif method == 'GET':
return self._request_get_helper(url, params)
raise VultrError('Unsupported method %s' % method)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_request_helper'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': ... | API request helper method |
def swagger(request):
generator = schemas.SchemaGenerator(title='django-user-tasks REST API')
return response.Response(generator.get_schema()) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'swagger'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'request'}... | Render Swagger UI and the underlying Open API schema JSON file. |
def append(self, item):
if self.url:
raise TypeError('Menu items with URL cannot have childrens')
if not item.is_leaf():
for current_item in self.items:
if item.name == current_item.name:
for children in item.items:
curr... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'append'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Add the given item as children |
def dispatch(self,request,*args,**kwargs):
lessonSession = request.session.get(PRIVATELESSON_VALIDATION_STR,{})
try:
self.lesson = PrivateLessonEvent.objects.get(id=lessonSession.get('lesson'))
except (ValueError, ObjectDoesNotExist):
messages.error(request,_('Invalid les... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dispatch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Handle the session data passed by the prior view. |
def on_task_status(self, task):
try:
procesok = task['track']['process']['ok']
if not self.projects[task['project']].task_queue.done(task['taskid']):
logging.error('not processing pack: %(project)s:%(taskid)s %(url)s', task)
return None
except KeyE... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_task_status'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Called when a status pack is arrived |
def batch_flatten(x):
shape = x.get_shape().as_list()[1:]
if None not in shape:
return tf.reshape(x, [-1, int(np.prod(shape))])
return tf.reshape(x, tf.stack([tf.shape(x)[0], -1])) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'batch_flatten'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'x'}... | Flatten the tensor except the first dimension. |
def add_udev_trigger(self, trigger_action, subsystem):
if self._py3_wrapper.udev_monitor.subscribe(self, trigger_action, subsystem):
if trigger_action == "refresh_and_freeze":
self.module_class.cache_timeout = PY3_CACHE_FOREVER | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_udev_trigger'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Subscribe to the requested udev subsystem and apply the given action. |
def merge(left, right, how='inner', key=None, left_key=None, right_key=None,
left_as='left', right_as='right'):
return join(left, right, how, key, left_key, right_key,
join_fn=make_union_join(left_as, right_as)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '24']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21']}; {'id': '4', 'type': 'identifier... | Performs a join using the union join function. |
def _add_sections(self):
for section in self.template_sections:
try:
sec_start = self._get_section_start_index(section)
except NonextantSectionException:
if section in self.sections_not_required:
continue
raise
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_sections'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Add the found and required sections to the templ_dict. |
def _evaluate(self):
if self._elements:
for element in self._elements:
yield element
else:
for user_id in self.__user_ids:
element = self._swimlane.users.get(id=user_id)
self._elements.append(element)
yield element | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_evaluate'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Lazily retrieve and build User instances from returned data |
def get():
pkgnames = find_packages()
if len(pkgnames) == 0:
raise ValueError("Can't find any packages")
pkgname = pkgnames[0]
content = open(join(pkgname, '__init__.py')).read()
c = re.compile(r"__version__ *= *('[^']+'|\"[^\"]+\")")
m = c.search(content)
if m is None:
raise... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '24', '30', '45', '54',... | Returns the current version without importing pymds. |
def split_model(model:nn.Module=None, splits:Collection[Union[nn.Module,ModuleList]]=None):
"Split `model` according to the layers in `splits`."
splits = listify(splits)
if isinstance(splits[0], nn.Module):
layers = flatten_model(model)
idxs = [layers.index(first_layer(s)) for s in splits]
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '28']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'split_model'}; {'id': '3', 'type': 'parameters', 'children': ['4', '11']}; {'id': '4', 'type': 'typed_default_parameter', 'children':... | Split `model` according to the layers in `splits`. |
def MergeMessage(
self, source, destination,
replace_message, replace_repeated):
_MergeMessage(
self._root, source, destination, replace_message, replace_repeated) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'MergeMessage'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children'... | Merge all fields specified by this tree from source to destination. |
def cli_progress(addr, offset, size):
width = 25
done = offset * width // size
print("\r0x{:08x} {:7d} [{}{}] {:3d}% "
.format(addr, size, '=' * done, ' ' * (width - done),
offset * 100 // size), end="")
try:
sys.stdout.flush()
except OSError:
pass
if ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cli_progress'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Prints a progress report suitable for use on the command line. |
def _draw(self, context, opacity):
fresh_draw = len(self.__new_instructions or []) > 0
if fresh_draw:
self.paths = []
self.__instruction_cache = self.__new_instructions
self.__new_instructions = []
else:
if not self.__instruction_cache:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_draw'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | draw accumulated instructions in context |
def iteritems(self):
for n,v in self.msgobj.__dict__["_headers"]:
yield n.lower(), v
return | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iteritems'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Present the email headers |
def __get_default_layouts_settings(self):
LOGGER.debug("> Accessing '{0}' default layouts settings file!".format(UiConstants.layouts_file))
self.__default_layouts_settings = QSettings(umbra.ui.common.get_resource_path(UiConstants.layouts_file),
QSettin... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__get_default_layouts_settings'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': ... | Gets the default layouts settings. |
def move_vobject(self, uuid, from_project, to_project):
if to_project not in self.get_filesnames():
return
uuid = uuid.split('@')[0]
with self._lock:
run(['task', 'rc.verbose=nothing', 'rc.data.location={self._data_location}'.format(**locals()), 'rc.confirmation=no', uuid... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'move_vobject'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [],... | Update the project of the task with the UID uuid |
def equal(self, path_a, path_b):
content_a, _ = self.get_bytes(path_a)
content_b, _ = self.get_bytes(path_b)
return content_a == content_b | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'equal'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | compare if a and b have the same bytes |
def fail(item, fail_type=None, max_tries=None, ttl=None):
if fail_type is not None and fail_type == _c.FSQ_FAIL_TMP:
return fail_tmp(item, max_tries=max_tries, ttl=ttl)
return fail_perm(item) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fail'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Fail a work item, either temporarily or permanently |
def _end_del(self):
text = self.edit_text[:self.edit_pos]
self.set_edit_text(text) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_end_del'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Deletes the line content after the cursor |
def filter(self, request, queryset, view):
summary_queryset = queryset
filtered_querysets = []
for queryset in summary_queryset.querysets:
filter_class = self._get_filter(queryset)
queryset = filter_class(request.query_params, queryset=queryset).qs
filtered_qu... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Filter each resource separately using its own filter |
def cluster_forget(self, node_id):
fut = self.execute(b'CLUSTER', b'FORGET', node_id)
return wait_ok(fut) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cluster_forget'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Remove a node from the nodes table. |
def DeleteCronJob(self, cronjob_id):
if cronjob_id not in self.cronjobs:
raise db.UnknownCronJobError("Cron job %s not known." % cronjob_id)
del self.cronjobs[cronjob_id]
try:
del self.cronjob_leases[cronjob_id]
except KeyError:
pass
for job_run in self.ReadCronJobRuns(cronjob_id):... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'DeleteCronJob'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Deletes a cronjob along with all its runs. |
def selection(x_bounds,
x_types,
clusteringmodel_gmm_good,
clusteringmodel_gmm_bad,
minimize_starting_points,
minimize_constraints_fun=None):
results = lib_acquisition_function.next_hyperparameter_lowest_mu(\
_ratio_scores, [c... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'selection'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'childr... | Select the lowest mu value |
def system_status(self):
flag, timestamp, status = self._query(('GETDAT? 1', (Integer, Float, Integer)))
return {
'timestamp': datetime.datetime.fromtimestamp(timestamp),
'temperature': STATUS_TEMPERATURE[status & 0xf],
'magnet': STATUS_MAGNET[(status >> 4) & 0xf],
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'system_status'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | The system status codes. |
def settled(self, block_identifier: BlockSpecification) -> bool:
return self.token_network.channel_is_settled(
participant1=self.participant1,
participant2=self.participant2,
block_identifier=block_identifier,
channel_identifier=self.channel_identifier,
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'settled'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Returns if the channel is settled. |
def check (self):
if self.aggregate.config["trace"]:
trace.trace_on()
try:
self.local_check()
except (socket.error, select.error):
etype, value = sys.exc_info()[:2]
if etype == errno.EINTR:
raise KeyboardInterrupt(value)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Main check function for checking this URL. |
def __register_driver(self, channel, webdriver):
"Register webdriver to a channel."
if not self.__registered_drivers.has_key(channel):
self.__registered_drivers[channel] = []
self.__registered_drivers[channel].append(webdriver)
self.__webdriver[channel] = webdriver | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__register_driver'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | Register webdriver to a channel. |
def parser_feed(parser, text):
encoded_text = text.encode('utf-8')
return _cmark.lib.cmark_parser_feed(
parser, encoded_text, len(encoded_text)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parser_feed'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Direct wrapper over cmark_parser_feed. |
def read_band_blocks(self, blocksize=CHUNK_SIZE):
band = self.filehandle
shape = band.shape
token = tokenize(blocksize, band)
name = 'read_band-' + token
dskx = dict()
if len(band.block_shapes) != 1:
raise NotImplementedError('Bands with multiple shapes not su... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_band_blocks'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Read the band in native blocks. |
def withdict(parser, token):
bits = token.split_contents()
if len(bits) != 2:
raise TemplateSyntaxError("{% withdict %} expects one argument")
nodelist = parser.parse(('endwithdict',))
parser.delete_first_token()
return WithDictNode(
nodelist=nodelist,
context_expr=parser.com... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'withdict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'par... | Take a complete context dict as extra layer. |
def undecorate(func):
orig_call_wrapper = lambda x: x
for call_wrapper, unwrap in SUPPORTED_DECORATOR.items():
if isinstance(func, call_wrapper):
func = unwrap(func)
orig_call_wrapper = call_wrapper
break
return orig_call_wrapper, func | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'undecorate'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func'}... | Returns the decorator and the undecorated function of given object. |
def _openai_logging(self, epoch_result):
for key in sorted(epoch_result.keys()):
if key == 'fps':
openai_logger.record_tabular(key, int(epoch_result[key]))
else:
openai_logger.record_tabular(key, epoch_result[key])
openai_logger.dump_tabular() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_openai_logging'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Use OpenAI logging facilities for the same type of logging |
def parse_options(self, prog_name, arguments):
if '--version' in arguments:
self.exit_status(self.version, fh=sys.stdout)
parser = self.create_parser(prog_name)
options, args = parser.parse_args(arguments)
return options, args | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_options'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Parse the available options. |
def obj2str(obj):
if isinstance(obj, str_types):
return obj.encode("utf-8")
elif isinstance(obj, pathlib.Path):
return obj2str(str(obj))
elif isinstance(obj, (bool, int, float)):
return str(obj).encode("utf-8")
elif obj is None:
return b"none"
elif isinstance(obj, np.... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'obj2str'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'... | String representation of an object for hashing |
def Pop(self, key):
node = self._hash.get(key)
if node:
del self._hash[key]
self._age.Unlink(node)
return node.data | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Pop'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Remove the object from the cache completely. |
def _gwf_channel(path, series_class=TimeSeries, verbose=False):
channels = list(io_gwf.iter_channel_names(file_path(path)))
if issubclass(series_class, StateVector):
regex = DQMASK_CHANNEL_REGEX
else:
regex = STRAIN_CHANNEL_REGEX
found, = list(filter(regex.match, channels))
if verbos... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_gwf_channel'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Find the right channel name for a LOSC GWF file |
def _from_dict(cls, _dict):
args = {}
if 'name' in _dict:
args['name'] = _dict.get('name')
else:
raise ValueError(
'Required property \'name\' not present in ClassifierResult JSON'
)
if 'classifier_id' in _dict:
args['classi... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_from_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'c... | Initialize a ClassifierResult object from a json dictionary. |
def data(self):
d = {}
self.token = ''
try:
d = self.viz.data
self.token = d.get('token')
except Exception as e:
logging.exception(e)
d['error'] = str(e)
return {
'datasource': self.datasource_name,
'descript... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Data used to render slice in templates |
def raise_figure_window(f=0):
if _fun.is_a_number(f): f = _pylab.figure(f)
f.canvas.manager.window.raise_() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'raise_figure_window'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5'... | Raises the supplied figure number or figure window. |
def _only_main(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
if not self.is_main:
return getattr(self.main, func.__name__)(*args, **kwargs)
return func(self, *args, **kwargs)
return wrapper | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_only_main'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func'}... | Call the given `func` only from the main project |
def Run(self, request):
self.request = request
filters = self.BuildChecks(request)
files_checked = 0
for f in self.ListDirectory(request.pathspec):
self.Progress()
if not any((check(f) for check in filters)):
self.SendReply(f)
files_checked += 1
if files_checked >= self.M... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Run'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Runs the Find action. |
def stack_push(self, thing):
sp = self.regs.sp + self.arch.stack_change
self.regs.sp = sp
return self.memory.store(sp, thing, endness=self.arch.memory_endness) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stack_push'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Push 'thing' to the stack, writing the thing to memory and adjusting the stack pointer. |
def pop_result(self, key):
self.pending_callbacks.remove(key)
return self.results.pop(key) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pop_result'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Returns the result for ``key`` and unregisters it. |
def _convert_trigger(self, trigger_def, parent):
if trigger_def.explicit_stream is None:
stream = parent.resolve_identifier(trigger_def.named_event, DataStream)
trigger = TrueTrigger()
else:
stream = trigger_def.explicit_stream
trigger = trigger_def.explic... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_trigger'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Convert a TriggerDefinition into a stream, trigger pair. |
def filter_query(self, query):
for filter_class in list(self.filter_classes):
query = filter_class().filter_query(self.request, query, self)
return query | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter_query'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Filter the given query using the filter classes specified on the view if any are specified. |
def _get_verdict(result):
verdict = result.get("verdict")
if not verdict:
return None
verdict = verdict.strip().lower()
if verdict not in Verdicts.PASS + Verdicts.FAIL + Verdicts.SKIP + Verdicts.WAIT:
return None
return verdict | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_verdict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'resu... | Gets verdict of the testcase. |
def subnet_create_event(self, subnet_info):
subnet = subnet_info.get('subnet')
if subnet:
self.create_subnet(subnet)
else:
subnets = subnet_info.get('subnets')
if subnets:
for subnet in subnets:
self.create_subnet(subnet) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'subnet_create_event'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Process subnet create event. |
def parse_MML(self, mml):
hashes_c = []
mentions_c = []
soup = BeautifulSoup(mml, "lxml")
hashes = soup.find_all('hash', {"tag": True})
for hashe in hashes:
hashes_c.append(hashe['tag'])
mentions = soup.find_all('mention', {"uid": True})
for mention in... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_MML'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | parse the MML structure |
def _create_hidden_port(self, context, network_id, device_id, fixed_ips,
port_type=DEVICE_OWNER_ROUTER_INTF):
port = {'port': {
'tenant_id': '',
'network_id': network_id,
'mac_address': ATTR_NOT_SPECIFIED,
'fixed_ips': fixed_ips,
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_hidden_port'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier... | Creates port used specially for HA purposes. |
def _get_val(record, keys):
data = record
for key in keys:
if key in data:
data = data[key]
else:
return None
return data | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_val'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'rec... | Internal, get value from record |
def fit_transform(self,
X,
num_epochs=10,
updates_epoch=10,
stop_param_updates=dict(),
batch_size=1,
show_progressbar=False,
show_epoch=False):
self.fit(X,
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fit_transform'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '17', '20', '23']}; {'id': '4', 'type': 'id... | First fit, then transform. |
def convert_relational(relational):
rel = relational.rel_op
if rel in ['==', '>=', '>']:
return relational.lhs-relational.rhs
elif rel in ['<=', '<']:
return relational.rhs-relational.lhs
else:
raise Exception("The relational operation ' + rel + ' is not "
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_relational'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Convert all inequalities to >=0 form. |
def collection(data, bins=10, *args, **kwargs):
from physt.histogram_collection import HistogramCollection
if hasattr(data, "columns"):
data = {column: data[column] for column in data.columns}
return HistogramCollection.multi_h1(data, bins, **kwargs) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'collection'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '10']}; {'id': '4', 'type': 'identifier', 'children': [],... | Create histogram collection with shared binnning. |
def verify_cert(self):
log.debug('Verifying the %s certificate, keyfile: %s',
self.certificate, self.keyfile)
try:
ssl.create_default_context().load_cert_chain(self.certificate, keyfile=self.keyfile)
except ssl.SSLError:
error_string = 'SSL certificate a... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'verify_cert'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Checks that the provided cert and key are valid and usable |
def import_object(path):
spl = path.split('.')
if len(spl) == 1:
return importlib.import_module(path)
cls = spl[-1]
mods = '.'.join(spl[:-1])
mm = importlib.import_module(mods)
try:
obj = getattr(mm, cls)
return obj
except AttributeError:
pass
rr = importl... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'import_object'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pat... | Import an object given its fully qualified name. |
def map_id(self,id, prefix, closure_list):
prefixc = prefix + ':'
ids = [eid for eid in closure_list if eid.startswith(prefixc)]
if len(ids) == 0:
return id
return ids[0] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'map_id'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Map identifiers based on an equivalence closure list. |
def _gen_get_more_command(cursor_id, coll, batch_size, max_await_time_ms):
cmd = SON([('getMore', cursor_id),
('collection', coll)])
if batch_size:
cmd['batchSize'] = batch_size
if max_await_time_ms is not None:
cmd['maxTimeMS'] = max_await_time_ms
return cmd | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_gen_get_more_command'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'child... | Generate a getMore command document. |
def processing_block_list():
pb_list = ProcessingBlockList()
return dict(active=pb_list.active,
completed=pb_list.completed,
aborted=pb_list.aborted) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'processing_block_list'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11']}; {'i... | Return the list of processing blocks known to SDP. |
def comments(self, extra_params=None):
params = {
'per_page': settings.MAX_PER_PAGE,
}
if extra_params:
params.update(extra_params)
return self.api._get_json(
TicketComment,
space=self,
rel_path=self.space._build_rel_path(
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'comments'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | All Comments in this Ticket |
def arg_to_json(arg):
conversion = json_conversions.get(type(arg))
if conversion:
return conversion(arg)
for type_ in subclass_conversions:
if isinstance(arg, type_):
return json_conversions[type_](arg)
return json_conversions[str](arg) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'arg_to_json'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arg'}... | Perform necessary JSON conversion on the arg. |
def row2table(soup, table, row):
tr = Tag(soup, name="tr")
table.append(tr)
for attr in row:
td = Tag(soup, name="td")
tr.append(td)
td.append(attr) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'row2table'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | ad a row to the table |
def display_dataset(self):
header = self.dataset.header
self.parent.setWindowTitle(basename(self.filename))
short_filename = short_strings(basename(self.filename))
self.idx_filename.setText(short_filename)
self.idx_s_freq.setText(str(header['s_freq']))
self.idx_n_chan.set... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'display_dataset'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Update the widget with information about the dataset. |
def gc_stop():
global gc_thread
if gc_thread:
log.info("Shutting down GC thread")
gc_thread.signal_stop()
gc_thread.join()
log.info("GC thread joined")
gc_thread = None
else:
log.info("GC thread already joined") | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gc_stop'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '7']}; {'id': '5', 'type'... | Stop a the optimistic GC thread |
def pub_poll(request, docid):
try:
r = flat.comm.get(request, '/poll/pub/' + docid + '/', False)
except URLError:
return HttpResponseForbidden("Unable to connect to the document server [viewer/poll]")
return HttpResponse(r, content_type='application/json') | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pub_poll'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'req... | The initial viewer, does not provide the document content yet |
def logs(self):
if not self.parent.loaded: self.parent.load()
logs = self.parent.p.logs_dir.flat_directories
logs.sort(key=lambda x: x.mod_time)
return logs | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'logs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Find the log directory and return all the logs sorted. |
def create_index(config):
filename = pathlib.Path(config.cache_path) / "index.json"
index = {"version": __version__}
with open(filename, "w") as out:
out.write(json.dumps(index, indent=2)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_index'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'conf... | Create the root index. |
def _update_events(self):
events = self._skybell.dev_cache(self, CONST.EVENT) or {}
for activity in self._activities:
event = activity.get(CONST.EVENT)
created_at = activity.get(CONST.CREATED_AT)
old_event = events.get(event)
if old_event and created_at < ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_events'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Update our cached list of latest activity events. |
def fetch(self):
entries = []
for activity in self.activities['entries']:
entries.append(
[element for element in [activity['title'],
activity['content'][0]['value']]])
return entries[0:self.max_entries] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetch'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | returns a list of html snippets fetched from github actitivy feed |
def to_escpos(self):
cmd = ''
ordered_cmds = self.cmds.keys()
ordered_cmds.sort(lambda x,y: cmp(self.cmds[x]['_order'], self.cmds[y]['_order']))
for style in ordered_cmds:
cmd += self.cmds[style][self.get(style)]
return cmd | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_escpos'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | converts the current style to an escpos command string |
def update(self, f):
for p in self.__mapper__.attrs:
if p.key == 'oid':
continue
try:
setattr(self, p.key, getattr(f, p.key))
except AttributeError:
continue | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Copy another files properties into this one. |
def extract_lzma(archive, compression, cmd, verbosity, interactive, outdir):
return _extract(archive, compression, cmd, 'alone', verbosity, outdir) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_lzma'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'chi... | Extract an LZMA archive with the lzma Python module. |
def _default_hparams():
return hparam.HParams(
loss_multiplier=1.0,
batch_size_multiplier=1,
stop_at_eos=False,
modality={},
vocab_size={},
input_space_id=SpaceID.GENERIC,
target_space_id=SpaceID.GENERIC) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_default_hparams'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5']}; {'id': '5', 't... | A set of basic model hyperparameters. |
def lines2mecab(lines, **kwargs):
sents = []
for line in lines:
sent = txt2mecab(line, **kwargs)
sents.append(sent)
return sents | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lines2mecab'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Use mecab to parse many lines |
def on_backward_begin(self, smooth_loss:Tensor, **kwargs:Any)->None:
"Record the loss before any other callback has a chance to modify it."
self.losses.append(smooth_loss)
if self.pbar is not None and hasattr(self.pbar,'child'):
self.pbar.child.comment = f'{smooth_loss:.4f}' | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_backward_begin'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'childre... | Record the loss before any other callback has a chance to modify it. |
def setOrderedRegisterNumbers(order, start):
for i, node in enumerate(order):
node.reg.n = start + i
return start + len(order) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setOrderedRegisterNumbers'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': ... | Given an order of nodes, assign register numbers. |
def revoke_token(self, token, headers=None, **kwargs):
self._check_configuration("site", "revoke_uri")
url = "%s%s" % (self.site, quote(self.revoke_url))
data = {'token': token}
data.update(kwargs)
return self._make_request(url, data=data, headers=headers) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'revoke_token'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': []... | Revoke an access token |
def GetValuesForAttribute(self, attribute, only_one=False):
if not only_one and self.age_policy == NEWEST_TIME:
raise ValueError("Attempting to read all attribute versions for an "
"object opened for NEWEST_TIME. This is probably "
"not what you want.")
if att... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetValuesForAttribute'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children':... | Returns a list of values from this attribute. |
def Get(self):
args = user_pb2.ApiGetHuntApprovalArgs(
hunt_id=self.hunt_id,
approval_id=self.approval_id,
username=self.username)
result = self._context.SendRequest("GetHuntApproval", args)
return HuntApproval(
data=result, username=self._context.username, context=self._cont... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Get'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id'... | Fetch and return a proper HuntApproval object. |
def dump(self, file, sort_keys: bool = True, **kwargs) -> None:
json.dump(self.to_json(), file, sort_keys=sort_keys, **kwargs) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dump'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '11']}; {'id': '4', 'type': 'identifier', 'children': [],... | Dump this seeding container to a file as JSON. |
def aws_env_args(subparsers):
env_parser = subparsers.add_parser('aws_environment')
env_parser.add_argument('vault_path',
help='Full path(s) to the AWS secret')
export_arg(env_parser)
base_args(env_parser) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'aws_env_args'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'subp... | Add command line options for the aws_environment operation |
def merge(self, frame):
for column, values in frame.iteritems():
counter = self._counters.get(column)
for value in values:
if counter is not None:
counter.merge(value) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Add another DataFrame to the PStatCounter. |
def RunSphinxAPIDoc(_):
current_directory = os.path.abspath(os.path.dirname(__file__))
module = os.path.join(current_directory, '..', 'plaso')
api_directory = os.path.join(current_directory, 'sources', 'api')
apidoc.main(['-o', api_directory, module, '--force']) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'RunSphinxAPIDoc'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '_... | Runs sphinx-apidoc to auto-generate documentation. |
def config_at(self, i):
selections = {}
for key in self.store:
value = self.store[key]
if isinstance(value, list):
selected = i % len(value)
i = i // len(value)
selections[key]= value[selected]
else:
selections[key]= value
return ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'config_at'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Gets the ith config |
def retrieve_authorization_code(self, redirect_func=None):
request_param = {
"client_id": self.client_id,
"redirect_uri": self.redirect_uri,
}
if self.scope:
request_param['scope'] = self.scope
if self._extra_auth_params:
request_param.... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'retrieve_authorization_code'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children'... | retrieve authorization code to get access token |
def add(self, name, desc, func=None, args=None, krgs=None):
self.entries.append(MenuEntry(name, desc, func, args or [], krgs or {})) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': 'identifier', 'children':... | Add a menu entry. |
def _get_distance_scaling_term(self, C, rval, mag):
r_adj = np.sqrt(rval ** 2.0 + C["h"] ** 2.0)
return (
(C["c1"] + C["c2"] * (mag - self.CONSTS["Mref"])) *
np.log10(r_adj / self.CONSTS["Rref"]) -
(C["c3"] * (r_adj - self.CONSTS["Rref"]))) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_distance_scaling_term'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', '... | Returns the distance scaling term of the GMPE described in equation 2 |
def laea2cf(area):
proj_dict = area.proj_dict
args = dict(latitude_of_projection_origin=proj_dict.get('lat_0'),
longitude_of_projection_origin=proj_dict.get('lon_0'),
grid_mapping_name='lambert_azimuthal_equal_area',
)
return args | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'laea2cf'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'area'}; {... | Return the cf grid mapping for the laea projection. |
def install_virtualenv_p3(root, python_version):
import venv
builder = venv.EnvBuilder(system_site_packages=False, clear=True, symlinks=False, upgrade=False)
builder.create(root)
ret_code = subprocess.call([VE_SCRIPT, PROJECT_ROOT, root, python_version])
sys.exit(ret_code) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'install_virtualenv_p3'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Install virtual environment for Python 3.3+; removing the old one if it exists |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.