code stringlengths 51 2.34k | sequence stringlengths 1.16k 13.1k | docstring stringlengths 11 171 |
|---|---|---|
def update_misc(uid, **kwargs):
if 'rating' in kwargs:
MPost.__update_rating(uid, kwargs['rating'])
elif 'kind' in kwargs:
MPost.__update_kind(uid, kwargs['kind'])
elif 'keywords' in kwargs:
MPost.__update_keywords(uid, kwargs['keywords'])
elif 'count'... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_misc'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | update rating, kind, or count |
def from_path(cls, path):
f = GitFile(path, 'rb')
try:
ret = cls.from_file(f)
ret.path = path
return ret
finally:
f.close() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cl... | Read configuration from a file on disk. |
def bwrite(stream, obj):
handle = None
if not hasattr(stream, "write"):
stream = handle = open(stream, "wb")
try:
stream.write(bencode(obj))
finally:
if handle:
handle.close() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bwrite'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'strea... | Encode a given object to a file or stream. |
def update(self, path):
self._reset()
self.path = path
self._refresh_synced()
if self.is_synced:
self._refresh_path()
self._refresh_signed()
self._refresh_nvr() | {'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'... | Update the attributes of this CartItem. |
def scope(cls, f):
if not hasattr(cls, "scopes"):
cls.scopes = copy(STANDARD_SCOPES)
cls.scopes.append(f)
def create_builder(self, *args, **kwargs):
bldr = ScopeBuilder(cls, cls.scopes)
return getattr(bldr, f.__name__)(*args, **kwargs)
setattr(cls, f._... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scope'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'};... | Decorator which can dynamically attach a query scope to the model. |
def _parse_datetime_default_value(property_name, default_value_string):
parsed_value = time.strptime(default_value_string, ORIENTDB_DATETIME_FORMAT)
return datetime.datetime(
parsed_value.tm_year, parsed_value.tm_mon, parsed_value.tm_mday,
parsed_value.tm_hour, parsed_value.tm_min, parsed_value.... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_datetime_default_value'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'childre... | Parse and return the default value for a datetime property. |
async def flexible_api_handler(service, action_type, payload, props, **kwds):
if action_type == intialize_service_action():
model = json.loads(payload) if isinstance(payload, str) else payload
models = service._external_service_data['models']
connections = service._external_service_data['con... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flexible_api_handler'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', '... | This query handler builds the dynamic picture of availible services. |
def split_css_classes(css_classes):
classes_list = text_value(css_classes).split(" ")
return [c for c in classes_list if c] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'split_css_classes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Turn string into a list of CSS classes |
def _main():
usage = "usage: %prog [options] cmd [arg] ..."
optprs = OptionParser(usage=usage, version=version)
optprs.add_option("--debug", dest="debug", default=False,
action="store_true",
help="Enter the pdb debugger on main()")
optprs.add_option("--host", ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_main'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '9', '21', '40', '59', '81'... | Run from command line. |
def changed_action(mapper, connection, target):
action_history = get_history(target, 'action')
argument_history = get_history(target, 'argument')
owner_history = get_history(
target,
'user' if isinstance(target, ActionUsers) else
'role' if isinstance(target, ActionRoles) else 'role_n... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'changed_action'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Remove the action from cache when an item is updated. |
def simplify_scalar(self, func=sympy.simplify):
def element_simplify(v):
if isinstance(v, sympy.Basic):
return func(v)
elif isinstance(v, QuantumExpression):
return v.simplify_scalar(func=func)
else:
return v
return self... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'simplify_scalar'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Simplify all scalar expressions appearing in the Matrix. |
def ensure_state(default_getter, exc_class, default_msg=None):
def decorator(getter=default_getter, msg=default_msg):
def ensure_decorator(f):
@wraps(f)
def inner(self, *args, **kwargs):
if not getter(self):
raise exc_class(msg) if msg else exc_cla... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ensure_state'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Create a decorator factory function. |
def _wait_for_tasks(tasks, service_instance):
log.trace('Waiting for vsan tasks: {0}',
', '.join([six.text_type(t) for t in tasks]))
try:
vsanapiutils.WaitForTasks(tasks, service_instance)
except vim.fault.NoPermission as exc:
log.exception(exc)
raise VMwareApiError('No... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_wait_for_tasks'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Wait for tasks created via the VSAN API |
def setLevel(self, level):
if isinstance(level, int):
self.logger.setLevel(level)
return
level = level.lower()
if level == "debug":
self.logger.setLevel(logging.DEBUG)
elif level == "info":
self.logger.setLevel(logging.INFO)
elif level == "warning" or level == "warning":
self.logger.setLevel(lo... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setLevel'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Changement du niveau du Log |
def author_preview_view(self, context):
children_contents = []
fragment = Fragment()
for child_id in self.children:
child = self.runtime.get_block(child_id)
child_fragment = self._render_child_fragment(child, context, 'preview_view')
fragment.add_frag_resource... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'author_preview_view'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | View for previewing contents in studio. |
def _generate_create_callable(name, display_name, arguments, regex, doc, supported, post_arguments, is_action):
def f(self, *args, **kwargs):
for key, value in args[-1].items():
if type(value) == file:
return self._put_or_post_multipart('POST', self._generate_url(regex, args[:-1]... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_generate_create_callable'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11']}; {'id': '4', '... | Returns a callable which conjures the URL for the resource and POSTs data |
def element_contains(self, element_id, value):
elements = ElementSelector(
world.browser,
str('id("{id}")[contains(., "{value}")]'.format(
id=element_id, value=value)),
filter_displayed=True,
)
if not elements:
raise AssertionError("Expected element not found.") | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'element_contains'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Assert provided content is contained within an element found by ``id``. |
def _pfp__show(self, level=0, include_offset=False):
res = []
res.append("{}{} {{".format(
"{:04x} ".format(self._pfp__offset) if include_offset else "",
self._pfp__show_name
))
for child in self._pfp__children:
res.append("{}{}{:10s} = {}".format(
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_pfp__show'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Show the contents of the struct |
def _structure_tuple(self, obj, tup):
tup_params = tup.__args__
has_ellipsis = tup_params and tup_params[-1] is Ellipsis
if tup_params is None or (has_ellipsis and tup_params[0] is Any):
return tuple(obj)
if has_ellipsis:
tup_type = tup_params[0]
conv ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_structure_tuple'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Deal with converting to a tuple. |
def use_plenary_catalog_view(self):
self._catalog_view = PLENARY
for session in self._get_provider_sessions():
try:
session.use_plenary_catalog_view()
except AttributeError:
pass | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'use_plenary_catalog_view'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Pass through to provider CatalogLookupSession.use_plenary_catalog_view |
def create_single(cls, value, idx='default'):
return LabelList(idx=idx, labels=[
Label(value=value)
]) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_single'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Create a label-list with a single label containing the given value. |
def _iterate_to_update_x_transforms(self):
self._inner_iters = 0
self._last_inner_error = float('inf')
while self._inner_error_is_decreasing():
print(' Starting inner iteration {0:03d}. Current err = {1:12.5E}'
''.format(self._inner_iters, self._last_inner_error))
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_iterate_to_update_x_transforms'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children':... | Perform the inner iteration. |
def drive(self, event, *args):
maps = self.base.get(event, self.step)
for handle, data in maps[:]:
params = args + data
try:
handle(self, *params)
except Stop:
break
except StopIteration:
pass
exc... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'drive'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Used to dispatch events. |
def _GenerateStopTimesTuples(self):
stoptimes = self.GetStopTimes()
for i, st in enumerate(stoptimes):
yield st.GetFieldValuesTuple(self.trip_id) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_GenerateStopTimesTuples'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Generator for rows of the stop_times file |
def _get_data_from_list_of_dicts(source, fields='*', first_row=0, count=-1, schema=None):
if schema is None:
schema = google.datalab.bigquery.Schema.from_data(source)
fields = get_field_list(fields, schema)
gen = source[first_row:first_row + count] if count >= 0 else source
rows = [{'c': [{'v': row[c]} if c... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_data_from_list_of_dicts'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '15']}; {'id': '4', 'type': 'iden... | Helper function for _get_data that handles lists of dicts. |
def check_important_variables(self):
if len(self.important_variables - set(self.args.keys())):
raise TypeError("Some important variables are not set") | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_important_variables'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Check all the variables needed are defined |
def hog(concurrency, requests, limit, timeout,
params, paramfile, headers, headerfile, method, url):
params = parse_from_list_and_file(params, paramfile)
headers = parse_from_list_and_file(headers, headerfile)
click.echo(HR)
click.echo("Hog is running with {} threads, ".format(concurrency) +
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hog'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12', '13']}; {'id': '4', 'type': 'id... | Sending multiple `HTTP` requests `ON` `GREEN` thread |
def bgseq(code):
if isinstance(code, str):
code = nametonum(code)
if code == -1:
return ""
s = termcap.get('setab', code) or termcap.get('setb', code)
return s | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bgseq'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'code'}; {'i... | Returns the background color terminal escape sequence for the given color code number. |
def best_fit(li, value):
index = min(bisect_left(li, value), len(li) - 1)
if index in (0, len(li)):
return index
if li[index] - value < value - li[index-1]:
return index
else:
return index-1 | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'best_fit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'li'... | For a sorted list li, returns the closest item to value |
def _get_next_buffered_row(self):
if self._iter_row == self._iter_nrows:
raise StopIteration
if self._row_buffer_index >= self._iter_row_buffer:
self._buffer_iter_rows(self._iter_row)
data = self._row_buffer[self._row_buffer_index]
self._iter_row += 1
self... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_next_buffered_row'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Get the next row for iteration. |
def load_stream(filename):
rawfile = pkg_resources.resource_stream(__name__, filename)
if six.PY2:
return rawfile
return io.TextIOWrapper(rawfile, 'utf-8') | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_stream'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'filen... | Load a file stream from the package resources. |
def fn_device_dependency(name, device=""):
key = name + "_" + device
outs = []
def body():
with tf.control_dependencies(fn_device_dependency_dict()[key]):
yield outs
assert outs
deps = outs
if isinstance(outs[0], (list, tuple)):
assert len(outs) == 1
deps = outs[0]
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fn_device_dependency'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Add control deps for name and device. |
def substrate_a(self, **kwargs):
if self.substrate is not None:
return self.substrate.a(**kwargs)
else:
return (self.unstrained.a(**kwargs) /
(1. - self.strain_in_plane(**kwargs))) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'substrate_a'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Returns the substrate's lattice parameter. |
def _execute(self, worker):
self._assert_status_is(TaskStatus.RUNNING)
operation = worker.look_up(self.operation)
operation.invoke(self, [], worker=worker) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_execute'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | This method is ASSIGNED during the evaluation to control how to resume it once it has been paused |
def prepare_infrastructure():
runner = ForemastRunner()
runner.write_configs()
runner.create_app()
archaius = runner.configs[runner.env]['app']['archaius_enabled']
eureka = runner.configs[runner.env]['app']['eureka_enabled']
deploy_type = runner.configs['pipeline']['type']
if deploy_type not... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prepare_infrastructure'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '17'... | Entry point for preparing the infrastructure in a specific env. |
def read_geo(fid, key):
dsid = GEO_NAMES[key.name]
add_epoch = False
if "time" in key.name:
days = fid["/L1C/" + dsid["day"]].value
msecs = fid["/L1C/" + dsid["msec"]].value
data = _form_datetimes(days, msecs)
add_epoch = True
dtype = np.float64
else:
data... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_geo'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fid... | Read geolocation and related datasets. |
def make(parser):
mgr_parser = parser.add_subparsers(dest='subcommand')
mgr_parser.required = True
mgr_create = mgr_parser.add_parser(
'create',
help='Deploy Ceph MGR on remote host(s)'
)
mgr_create.add_argument(
'mgr',
metavar='HOST[:NAME]',
nargs='+',
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'... | Ceph MGR daemon management |
def loads(inputStr):
inCat = json.loads(inputStr)
assert CATALOGUE_TYPE in _values(inCat[CATALOGUE_METADATA], ISCONTENTTYPE_RELATION)
desc = _values(inCat[CATALOGUE_METADATA], DESCRIPTION_RELATION)[0]
outCat = Hypercat(desc)
for i in inCat[ITEMS]:
href = i[HREF]
contentType = _values... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'loads'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'inputStr'};... | Takes a string and converts it into an internal hypercat object, with some checking |
def generate(self, name: str, **kwargs):
path = self.urlmapper.generate(name, **kwargs)
return self.make_full_qualified_url(path) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | generate full qualified url for named url pattern with kwargs |
def chain(request):
bars = foobar_models.Bar.objects.all()
bazs = foobar_models.Baz.objects.all()
qsc = XmlQuerySetChain(bars, bazs)
return HttpResponse(tree.xml(qsc), mimetype='text/xml') | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'chain'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'request'}; ... | shows how the XmlQuerySetChain can be used instead of @toxml decorator |
def __select_autocomplete_identities(self, sources):
MIN_PRIORITY = 99999999
checked = {}
for source in sources:
uids = api.unique_identities(self.db, source=source)
for uid in uids:
if uid.uuid in checked:
continue
max_... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__select_autocomplete_identities'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'chil... | Select the identities used for autocompleting |
def write_forward_run(self):
with open(os.path.join(self.m.model_ws,self.forward_run_file),'w') as f:
f.write("import os\nimport numpy as np\nimport pandas as pd\nimport flopy\n")
f.write("import pyemu\n")
for ex_imp in self.extra_forward_imports:
f.write('imp... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_forward_run'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | write the forward run script forward_run.py |
def add_dicts(d1, d2):
if d1 is None:
return d2
if d2 is None:
return d1
keys = set(d1)
keys.update(set(d2))
ret = {}
for key in keys:
v1 = d1.get(key)
v2 = d2.get(key)
if v1 is None:
ret[key] = v2
elif v2 is None:
ret[key] ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_dicts'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'd1... | Merge two dicts of addable values |
def add_barplot(self):
cats = OrderedDict()
cats['n_nondups'] = {'name': 'Non-duplicates'}
cats['n_dups'] = {'name': 'Duplicates'}
pconfig = {
'id': 'samblaster_duplicates',
'title': 'Samblaster: Number of duplicate reads',
'ylab': 'Number of reads'
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_barplot'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Generate the Samblaster bar plot. |
def _get_struct_shape(self):
obj = _make_object("Shape")
bc = BitConsumer(self._src)
obj.NumFillBits = n_fill_bits = bc.u_get(4)
obj.NumLineBits = n_line_bits = bc.u_get(4)
obj.ShapeRecords = self._get_shaperecords(
n_fill_bits, n_line_bits, 0)
return obj | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_struct_shape'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Get the values for the SHAPE record. |
def sample_lonlat(self, n):
radius = self.sample_radius(n)
a = radius; b = self.jacobian * radius
t = 2. * np.pi * np.random.rand(n)
cost,sint = np.cos(t),np.sin(t)
phi = np.pi/2. - np.deg2rad(self.theta)
cosphi,sinphi = np.cos(phi),np.sin(phi)
x = a*cost*cosphi -... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sample_lonlat'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Sample 2D distribution of points in lon, lat |
def add_caption(self, image, caption, colour=None):
if colour is None:
colour = "white"
width, height = image.size
draw = ImageDraw.Draw(image)
draw.font = self.font
draw.font = self.font
draw.text((width // 10, height//20), caption,
fill=col... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_caption'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [],... | Add a caption to the image |
def major(self):
url = self._subfeed("major")
if "major" in self.url or "minor" in self.url:
return self
if self._major is None:
self._major = self.__class__(url, pypump=self._pump)
return self._major | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'major'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Major inbox feed, contains major activities such as notes and images. |
def add_behave_arguments(parser):
conflicts = [
'--no-color',
'--version',
'-c',
'-k',
'-v',
'-S',
'--simple',
]
parser.add_argument(
'paths',
action='store',
nargs='*',
help="Feature directory, file or file location (FI... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_behave_arguments'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Additional command line arguments extracted directly from behave |
def login(self):
self._username = input("Username:")
self._password = getpass.getpass("Password:")
if self.get_auth_token():
_LOGGER.debug("Login successful!")
return True
_LOGGER.warning("Unable to login with %s.", self._username)
return False | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'login'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Prompt user for username and password. |
def calibrate_refl(array, attributes, index):
offset = np.float32(attributes["reflectance_offsets"][index])
scale = np.float32(attributes["reflectance_scales"][index])
array = (array - offset) * scale * 100
return array | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calibrate_refl'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Calibration for reflective channels. |
def gen_decode(iterable):
"A generator for de-unsynchronizing a byte iterable."
sync = False
for b in iterable:
if sync and b & 0xE0:
warn("Invalid unsynched data", Warning)
if not (sync and b == 0x00):
yield b
sync = (b == 0xFF... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gen_decode'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'iterab... | A generator for de-unsynchronizing a byte iterable. |
def setNumWorkers(self, num_workers):
cur_num = len(self.workers)
if cur_num > num_workers:
self.dismissWorkers(cur_num - num_workers)
else:
self.createWorkers(num_workers - cur_num) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setNumWorkers'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Set number of worker threads to num_workers |
def dtstr_to_datetime(dtstr, to_tz=None, fail_silently=True):
try:
dt = datetime.datetime.utcfromtimestamp(int(dtstr, 36) / 1e3)
if to_tz:
dt = timezone.make_aware(dt, timezone=pytz.UTC)
if to_tz != pytz.UTC:
dt = dt.astimezone(to_tz)
return dt
exc... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dtstr_to_datetime'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': []... | Convert result from datetime_to_dtstr to datetime in timezone UTC0. |
def addVariantSearchOptions(parser):
addVariantSetIdArgument(parser)
addReferenceNameArgument(parser)
addCallSetIdsArgument(parser)
addStartArgument(parser)
addEndArgument(parser)
addPageSizeArgument(parser) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'addVariantSearchOptions'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Adds common options to a variant searches command line parser. |
def public_copy(self):
return self.__class__(
chain_code=self.chain_code,
depth=self.depth,
parent_fingerprint=self.parent_fingerprint,
child_number=self.child_number,
public_pair=self.public_key.to_public_pair(),
network=self.network) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'public_copy'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Clone this wallet and strip it of its private information. |
def _replace_variables(data, variables):
formatter = string.Formatter()
return [formatter.vformat(item, [], variables) for item in data] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_replace_variables'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Replace the format variables in all items of data. |
def to_raw_address(addr, section):
return addr - section.header.VirtualAddress + section.header.PointerToRawData | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_raw_address'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Converts the addr from a rva to a pointer to raw data in the file |
def calculate_category_probability(self):
total_tally = 0.0
probs = {}
for category, bayes_category in \
self.categories.get_categories().items():
count = bayes_category.get_tally()
total_tally += count
probs[category] = count
for categ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calculate_category_probability'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': ... | Caches the individual probabilities for each category |
def Parse(self, stat, file_object, knowledge_base):
_, _ = stat, knowledge_base
packages = []
sw_data = utils.ReadFileBytesAsUnicode(file_object)
try:
for pkg in self._deb822.Packages.iter_paragraphs(sw_data.splitlines()):
if self.installed_re.match(pkg["Status"]):
packages.appen... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Parse'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Parse the status file. |
def _check_inference(self, inference):
if inference=='GP2KronSum':
assert self.n_randEffs==2, 'VarianceDecomposition: for fast inference number of random effect terms must be == 2'
assert not sp.isnan(self.Y).any(), 'VarianceDecomposition: fast inference available only for complete pheno... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_inference'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Internal method for checking that the selected inference scheme is compatible with the specified model |
def unpack_ip_addr(addr):
if isinstance(addr, bytearray):
addr = bytes(addr)
return (socket.inet_ntoa(addr[0:4]), struct.unpack('!H', addr[4:6])[0]) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unpack_ip_addr'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ad... | Given a six-octet BACnet address, return an IP address tuple. |
def diskwarp_multi_fn(src_fn_list, res='first', extent='intersection', t_srs='first', r='cubic', verbose=True, outdir=None, dst_ndv=None):
if not iolib.fn_list_check(src_fn_list):
sys.exit('Missing input file(s)')
src_ds_list = [gdal.Open(fn, gdal.GA_ReadOnly) for fn in src_fn_list]
return diskwarp_... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'diskwarp_multi_fn'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23']}; {'id': '4', 'type'... | Helper function for diskwarp of multiple input filenames |
def process_python_symbol_data(oedata):
symbol_list = []
for key in oedata:
val = oedata[key]
if val and key != 'found_cell_separators':
if val.is_class_or_function():
symbol_list.append((key, val.def_name, val.fold_level,
val.get_t... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_python_symbol_data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Returns a list with line number, definition name, fold and token. |
def import_data(self, fname):
if self.count():
nsb = self.current_widget()
nsb.refresh_table()
nsb.import_data(filenames=fname)
if self.dockwidget and not self.ismaximized:
self.dockwidget.setVisible(True)
self.dockwidget.rai... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'import_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Import data in current namespace |
def extern_get_type_for(self, context_handle, val):
c = self._ffi.from_handle(context_handle)
obj = self._ffi.from_handle(val[0])
type_id = c.to_id(type(obj))
return TypeId(type_id) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extern_get_type_for'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [... | Return a representation of the object's type. |
def tiered_alignment(in_bam, tier_num, multi_mappers, extra_args,
genome_build, pair_stats,
work_dir, dirs, config):
nomap_fq1, nomap_fq2 = select_unaligned_read_pairs(in_bam, "tier{}".format(tier_num),
work_dir, config... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tiered_alignment'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12']}; {'id': '4', 'typ... | Perform the alignment of non-mapped reads from previous tier. |
def _save_group(self, group_id, result):
self.TaskSetModel._default_manager.store_result(group_id, result)
return result | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_save_group'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Store the result of an executed group. |
def complete(self):
if Part.count(self) != self.last_part_number + 1:
raise MultipartMissingParts()
with db.session.begin_nested():
self.completed = True
self.file.readable = True
self.file.writable = False
return self | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'complete'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Mark a multipart object as complete. |
def jarSources(target, source, env, for_signature):
try:
env['JARCHDIR']
except KeyError:
jarchdir_set = False
else:
jarchdir_set = True
jarchdir = env.subst('$JARCHDIR', target=target, source=source)
if jarchdir:
jarchdir = env.fs.Dir(jarchdir)
result... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'jarSources'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Only include sources that are not a manifest file. |
def watch_source(self, source_id):
source_id = int(source_id)
r = yield from self._send_cmd(
"WATCH S[%d] ON" % (source_id, ))
self._watched_source.add(source_id)
return r | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'watch_source'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Add a souce to the watchlist. |
def with_debug_id(debug_id):
ctx = SpanContext(
trace_id=None, span_id=None, parent_id=None, flags=None
)
ctx._debug_id = debug_id
return ctx | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'with_debug_id'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'deb... | Deprecated, not used by Jaeger. |
def _build_provider_list():
registry = None
if appsettings.FLUENT_OEMBED_SOURCE == 'basic':
registry = bootstrap_basic()
elif appsettings.FLUENT_OEMBED_SOURCE == 'embedly':
params = {}
if appsettings.MICAWBER_EMBEDLY_KEY:
params['key'] = appsettings.MICAWBER_EMBEDLY_KEY
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_build_provider_list'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '9', '109', ... | Construct the provider registry, using the app settings. |
def _check_release_done_processing(release):
if release.status != models.Release.PROCESSING:
logging.info('Release not in processing state yet: build_id=%r, '
'name=%r, number=%d', release.build_id, release.name,
release.number)
return False
query = mode... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_release_done_processing'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': ... | Moves a release candidate to reviewing if all runs are done. |
def sync_one(self, aws_syncr, amazon, bucket):
if bucket.permission.statements:
permission_document = bucket.permission.document
else:
permission_document = ""
bucket_info = amazon.s3.bucket_info(bucket.name)
if not bucket_info.creation_date:
amazon.s3... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sync_one'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Make sure this bucket exists and has only attributes we want it to have |
def _get_inherited_field_types(class_to_field_type_overrides, schema_graph):
inherited_field_type_overrides = dict()
for superclass_name, field_type_overrides in class_to_field_type_overrides.items():
for subclass_name in schema_graph.get_subclass_set(superclass_name):
inherited_field_type_o... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_inherited_field_types'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':... | Return a dictionary describing the field type overrides in subclasses. |
def add_bonus(worker_dict):
" Adds DB-logged worker bonus to worker list data "
try:
unique_id = '{}:{}'.format(worker_dict['workerId'], worker_dict['assignmentId'])
worker = Participant.query.filter(
Participant.uniqueid == unique_id).one()
worker_dic... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_bonus'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'worker_... | Adds DB-logged worker bonus to worker list data |
async def announce(self):
await self.event_broker.send(
action_type=intialize_service_action(),
payload=json.dumps(self.summarize())
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'announce'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | This method is used to announce the existence of the service |
def topic_over_time(self, k, mode='counts', slice_kwargs={}):
return self.corpus.feature_distribution('topics', k, mode=mode,
**slice_kwargs) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'topic_over_time'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children':... | Calculate the representation of topic ``k`` in the corpus over time. |
def send_zone_event(self, zone_id, event_name, *args):
cmd = "EVENT %s!%s %s" % (
zone_id.device_str(), event_name,
" ".join(str(x) for x in args))
return (yield from self._send_cmd(cmd)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_zone_event'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': ... | Send an event to a zone. |
def print_token(self, token_node_index):
err_msg = "The given node is not a token node."
assert isinstance(self.nodes[token_node_index], TokenNode), err_msg
onset = self.nodes[token_node_index].onset
offset = self.nodes[token_node_index].offset
return self.text[onset:offset] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_token'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | returns the string representation of a token. |
def __deactivate_shared_objects(self, plugin, *args, **kwargs):
shared_objects = self.get()
for shared_object in shared_objects.keys():
self.unregister(shared_object) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__deactivate_shared_objects'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier',... | Callback, which gets executed, if the signal "plugin_deactivate_post" was send by the plugin. |
def _remap_dirname(local, remote):
def do(x):
return x.replace(local, remote, 1)
return do | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_remap_dirname'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Remap directory names from local to remote. |
def rws_call(ctx, method, default_attr=None):
try:
response = ctx.obj['RWS'].send_request(method)
if ctx.obj['RAW']:
result = ctx.obj['RWS'].last_result.text
elif default_attr is not None:
result = ""
for item in response:
result = result +... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rws_call'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Make request to RWS |
def compile_sass(self, sass_filename, sass_fileurl):
compile_kwargs = {
'filename': sass_filename,
'include_paths': SassProcessor.include_paths + APPS_INCLUDE_DIRS,
'custom_functions': get_custom_functions(),
}
if self.sass_precision:
compile_kwarg... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compile_sass'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Compile the given SASS file into CSS |
def python_sidebar_navigation(python_input):
def get_text_fragments():
tokens = []
tokens.extend([
('class:sidebar', ' '),
('class:sidebar.key', '[Arrows]'),
('class:sidebar', ' '),
('class:sidebar.description', 'Navigate'),
('class:side... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'python_sidebar_navigation'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Create the `Layout` showing the navigation information for the sidebar. |
def getDMCframe(f, iFrm: int, finf: dict, verbose: bool=False):
currByte = iFrm * finf['bytesperframe']
if verbose:
print(f'seeking to byte {currByte}')
assert isinstance(iFrm, (int, int64)), 'int32 will fail on files > 2GB'
try:
f.seek(currByte, 0)
except IOError as e:
raise... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getDMCframe'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '13']}; {'id': '4', 'type': 'identifier', 'children': []... | f is open file handle |
def provStacks(self, offs, size):
for _, iden in self.provseq.slice(offs, size):
stack = self.getProvStack(iden)
if stack is None:
continue
yield (iden, stack) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'provStacks'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Returns a stream of provenance stacks at the given offset |
def create_information(self):
info = self._info_type()(origin=self, contents=self._contents())
return info | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_information'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Create new infos on demand. |
def _write_vvr(self, f, data):
f.seek(0, 2)
byte_loc = f.tell()
block_size = CDF.VVR_BASE_SIZE64 + len(data)
section_type = CDF.VVR_
vvr1 = bytearray(12)
vvr1[0:8] = struct.pack('>q', block_size)
vvr1[8:12] = struct.pack('>i', section_type)
f.write(vvr1)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_write_vvr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Writes a vvr to the end of file "f" with the byte stream "data". |
def delete(self, name):
if isinstance(name, (list, tuple)):
for xx in name:
self.delete(xx)
else:
if name in self._record_map:
del self._record_map[name]
self._record_list = [
r for r in self._record_list if r['n... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Delete the specified entry if it exists. |
def _import_plugins(self):
if self.detected:
return
self.scanLock.acquire()
if self.detected:
return
try:
import_apps_submodule("content_plugins")
self.detected = True
finally:
self.scanLock.release() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_import_plugins'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Internal function, ensure all plugin packages are imported. |
def boston(display=False):
d = sklearn.datasets.load_boston()
df = pd.DataFrame(data=d.data, columns=d.feature_names)
return df, d.target | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'boston'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id... | Return the boston housing data in a nice package. |
def pull(image, tag=None):
if tag:
image = ":".join([image, tag])
utils.xrun("docker pull", [image]) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pull'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'image'}... | pull a docker image |
def add_path(self, path):
if not os.path.exists(path):
raise RuntimeError('Path does not exists: %s.' % path)
self.paths.append(path) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Load translations from an existing path. |
def _clean(self, seed):
seed = deepcopy(seed)
self._inherit(*array(get(seed, 'inherit', [])))
if '&arguments' in seed:
self.arguments = merge(self.arguments, seed.pop('&arguments'))
elif 'arguments' in seed:
self.arguments = seed.pop('arguments')
self.seed... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_clean'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Takes a seed and applies it to the garden |
def find_on_path(importer, path_item, only=False):
path_item = _normalize_cached(path_item)
if _is_unpacked_egg(path_item):
yield Distribution.from_filename(
path_item, metadata=PathMetadata(
path_item, os.path.join(path_item, 'EGG-INFO')
)
)
retur... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_on_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Yield distributions accessible on a sys.path directory |
def versions_report(include_salt_cloud=False):
ver_info = versions_information(include_salt_cloud)
lib_pad = max(len(name) for name in ver_info['Dependency Versions'])
sys_pad = max(len(name) for name in ver_info['System Versions'])
padding = max(lib_pad, sys_pad) + 1
fmt = '{0:>{pad}}: {1}'
inf... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'versions_report'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6... | Yield each version properly formatted for console output. |
def saveToClipboard(sheet, rows, filetype=None):
'copy rows from sheet to system clipboard'
filetype = filetype or options.save_filetype
vs = copy(sheet)
vs.rows = rows
status('copying rows to clipboard')
clipboard().save(vs, filetype) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'saveToClipboard'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '... | copy rows from sheet to system clipboard |
def runtime_to_build(runtime_deps):
build_deps = copy.deepcopy(runtime_deps)
for dep in build_deps:
if len(dep) > 0:
dep[0] = 'BuildRequires'
return build_deps | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'runtime_to_build'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Adds all runtime deps to build deps |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.