code stringlengths 51 2.34k | sequence stringlengths 1.16k 13.1k | docstring stringlengths 11 171 |
|---|---|---|
def _number_of_set_bits(x):
x -= (x >> 1) & 0x55555555
x = ((x >> 2) & 0x33333333) + (x & 0x33333333)
x = ((x >> 4) + x) & 0x0f0f0f0f
x += x >> 8
x += x >> 16
return x & 0x0000003f | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_number_of_set_bits'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Returns the number of bits that are set in a 32bit int |
def reverse_velocity_kalman_model():
om = np.array([[1,0,0,0], [0, 1, 0, 0]])
tm = np.array([[1,0,-1,0],
[0,1,0,-1],
[0,0,1,0],
[0,0,0,1]])
return KalmanState(om, tm) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reverse_velocity_kalman_model'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '24... | Return a KalmanState set up to model going backwards in time |
def is1d(a:Collection)->bool:
"Return `True` if `a` is one-dimensional"
return len(a.shape) == 1 if hasattr(a, 'shape') else True | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'is1d'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'... | Return `True` if `a` is one-dimensional |
def add_domain_user_role(request, user, role, domain):
manager = keystoneclient(request, admin=True).roles
return manager.grant(role, user=user, domain=domain) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_domain_user_role'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'childr... | Adds a role for a user on a domain. |
def packet2dict(packet):
dict_ = dict()
frame = packet.frame_info
for field in frame.field_names:
dict_[field] = getattr(frame, field)
tempdict = dict_
for layer in packet.layers:
tempdict[layer.layer_name.upper()] = dict()
tempdict = tempdict[layer.layer_name.upper()]
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'packet2dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'packe... | Convert PyShark packet into dict. |
def build_task(self, name):
try:
self._gettask(name).value = (
self._gettask(name).task.resolve_and_build())
except TaskExecutionException as e:
perror(e.header, indent="+0")
perror(e.message, indent="+4")
self._gettask(name).value = e.payl... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_task'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Builds a task by name, resolving any dependencies on the way |
def _resources(p):
if p.resources:
click.echo(",".join(p.resources))
else:
click.echo(f"Provider '{p.name}' does not have resource helpers") | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_resources'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'p'}; {... | Callback func to display provider resources |
def build_queryset(self):
paths = [(os.path.join(self.build_prefix, 'index.html'), {})]
self.request = None
queryset = self.get_queryset()
paginator = self.get_paginator(queryset, self.get_paginate_by(queryset))
for page in paginator.page_range:
paths.append(
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_queryset'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Override django-bakery's build logic to fake pagination. |
def auto_load_configs(self):
for app in apps.get_app_configs():
for model in app.get_models():
config = ModelConfig(model, getattr(app, model.__name__, None))
self.configs[self.get_model_name(model)] = config | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'auto_load_configs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Auto load all configs from app configs |
def file_exists(fname):
try:
return fname and os.path.exists(fname) and os.path.getsize(fname) > 0
except OSError:
return False | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'file_exists'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fname... | Check if a file exists and is non-empty. |
def md5sum(fname: str) -> str:
with open(fname, "rb") as inp:
md5 = hashlib.md5(inp.read()).hexdigest()
return md5 | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'md5sum'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; ... | Compute MD5 sum of file. |
def siblings_files(path):
file_basename, extension = splitext(path)
main_extension = extension.lower()
files = {}
if extension.lower() in list(extension_siblings.keys()):
for text_extension in list(extension_siblings[main_extension].keys()):
if isfile(file_basename + text_extension):... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'siblings_files'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pa... | Return a list of sibling files available. |
def calcontime(data, inds=None):
if not inds:
inds = range(len(data['time']))
logger.info('No indices provided. Assuming all are valid.')
scans = set([data['scan'][i] for i in inds])
total = 0.
for scan in scans:
time = [data['time'][i] for i in inds if data['scan'][i] == scan]
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calcontime'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'd... | Given indices of good times, calculate total time per scan with indices. |
def create_outbound_email(self, subject, description, email, email_config_id, **kwargs):
url = 'tickets/outbound_email'
priority = kwargs.get('priority', 1)
data = {
'subject': subject,
'description': description,
'priority': priority,
'email': ema... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_outbound_email'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifi... | Creates an outbound email |
def add_menu(self, menu):
from MAVProxy.modules.mavproxy_map import mp_slipmap
self.default_popup.add(menu)
self.map.add_object(mp_slipmap.SlipDefaultPopup(self.default_popup, combine=True)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_menu'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | add to the default popup menu |
def _expire_data(self):
expire_time_stamp = time.time() - self.expire_time
self.timed_data = {d: t for d, t in self.timed_data.items()
if t > expire_time_stamp} | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_expire_data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | Remove all expired entries. |
def run_migration(data, version_start, version_end):
items = []
if version_start == 1 and version_end == 2:
for item in data['accounts']:
items.append(v2.upgrade(item))
if version_start == 2 and version_end == 1:
for item in data:
items.append(v2.downgrade(item))
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_migration'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Runs migration against a data set. |
def plotMatches2(listofNValues, errors,
listOfScales, scaleErrors,
fileName = "images/scalar_matches.pdf"):
w, h = figaspect(0.4)
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(w,h))
plotMatches(listofNValues, errors, fileName=None, fig=fig, ax=ax1)
plotScaledMatches(listOfScale... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plotMatches2'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children... | Plot two figures side by side in an aspect ratio appropriate for the paper. |
def lines(self):
if self._cache.lines is None:
self._cache.lines = _ImmutableLineList(self.text.split('\n'))
return self._cache.lines | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lines'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Array of all the lines. |
def start(self):
while True:
self.thread_debug("Interval starting")
for thr in threading.enumerate():
self.thread_debug(" " + str(thr))
self.feed_monitors()
start = time.time()
self.workers_queue.join()
end = time.time()
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | The main loop, run forever. |
def _get_states(self, result):
if 'devices' not in result.keys():
return
for device_states in result['devices']:
device = self.__devices[device_states['deviceURL']]
try:
device.set_active_states(device_states['states'])
except KeyError:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_states'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Get states of devices. |
def precedence(item):
try:
mro = item.__class__.__mro__
except AttributeError:
return PRECEDENCE["Atom"]
for i in mro:
n = i.__name__
if n in PRECEDENCE_FUNCTIONS:
return PRECEDENCE_FUNCTIONS[n](item)
elif n in PRECEDENCE_VALUES:
return PRECEDE... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'precedence'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'item'}... | Returns the precedence of a given object. |
def output_snapshot_profile(gandi, profile, output_keys, justify=13):
schedules = 'schedules' in output_keys
if schedules:
output_keys.remove('schedules')
output_generic(gandi, profile, output_keys, justify)
if schedules:
schedule_keys = ['name', 'kept_version']
for schedule in p... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'output_snapshot_profile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'ch... | Helper to output a snapshot_profile. |
def extension_supported(request, extension_name):
for extension in list_extensions(request):
if extension.name == extension_name:
return True
return False | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extension_supported'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | This method will determine if Cinder supports a given extension name. |
def std_human_uid(kind=None):
kind_list = alphabet
if kind == 'animal':
kind_list = animals
elif kind == 'place':
kind_list = places
name = "{color} {adjective} {kind} of {attribute}".format(
color=choice(colors),
adjective=choice(adjectives),
kind=choice(kind_lis... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'std_human_uid'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']... | Return a random generated human-friendly phrase as low-probability unique id |
def clear(self):
with self._hlock:
self.handlers.clear()
with self._mlock:
self.memoize.clear() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Discards all registered handlers and cached results |
def df_names_to_idx(names:IntsOrStrs, df:DataFrame):
"Return the column indexes of `names` in `df`."
if not is_listy(names): names = [names]
if isinstance(names[0], int): return names
return [df.columns.get_loc(c) for c in names] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'df_names_to_idx'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5'... | Return the column indexes of `names` in `df`. |
def _get_filename_path(self, path):
feature_filename = os.path.join(path, self.feature_type.value)
if self.feature_name is not None:
feature_filename = os.path.join(feature_filename, self.feature_name)
return feature_filename | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_filename_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Helper function for creating filename without file extension |
def rgb2hex(r: int, g: int, b: int) -> str:
return '{:02x}{:02x}{:02x}'.format(r, g, b) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rgb2hex'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '12']}; {'id': '4', 'type': 'typed_parameter', 'children': ... | Convert rgb values to a hex code. |
def lognorm(x, mu, sigma=1.0):
return stats.lognorm(sigma, scale=mu).pdf(x) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lognorm'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Log-normal function from scipy |
def norm_vec(vector):
assert len(vector) == 3
v = np.array(vector)
return v/np.sqrt(np.sum(v**2)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'norm_vec'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'vector'}... | Normalize the length of a vector to one |
def plot_fracs(self, Q=None, ax=None, fignum=None):
from ..plotting import Tango
Tango.reset()
col = Tango.nextMedium()
if ax is None:
fig = pylab.figure(fignum)
ax = fig.add_subplot(111)
if Q is None:
Q = self.Q
ticks = numpy.arange(Q)... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plot_fracs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [],... | Plot fractions of Eigenvalues sorted in descending order. |
def drain(self, cycles=None):
if not self._check_service_requirements():
self.init_timer.stop()
return self.finish()
if self.anybar: self.anybar.change("orange")
self.init_timer.stop()
log.info("Trapping CTRL+C and starting to drain.")
signal.signal(signal... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'drain'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Execute _drain while trapping KeyboardInterrupt |
def trends_available(self):
url = 'https://api.twitter.com/1.1/trends/available.json'
try:
resp = self.get(url)
except requests.exceptions.HTTPError as e:
raise e
return resp.json() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'trends_available'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Returns a list of regions for which Twitter tracks trends. |
def do_email_notification(self, comment, entry, site):
if not self.mail_comment_notification_recipients:
return
template = loader.get_template(
'comments/zinnia/entry/email/notification.txt')
context = {
'comment': comment,
'entry': entry,
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_email_notification'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'child... | Send email notification of a new comment to site staff. |
def run(self, steps=10):
try:
super(GeneticMachine, self).run(steps)
self._error = False
except StopIteration:
self._error = False
except Exception:
self._error = True | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Executes up to `steps` instructions. |
def _norm_index(dim, index, start, stop):
length = stop - start
if -length <= index < 0:
normindex = index + length
elif start <= index < stop:
normindex = index - start
else:
fstr = "expected dim {} index in range [{}, {})"
raise IndexError(fstr.format(dim, start, stop))... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_norm_index'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Return an index normalized to an farray start index. |
def max_voltage_step(self):
steps = [self.voltage_pairs[i].voltage
- self.voltage_pairs[i + 1].voltage
for i in range(len(self.voltage_pairs) - 1)]
return max(steps) if len(steps) > 0 else 0 | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'max_voltage_step'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Maximum absolute difference in adjacent voltage steps |
def _get_listeners(instance, change):
if (
change['mode'] not in listeners_disabled._quarantine and
change['name'] in instance._listeners
):
return instance._listeners[change['name']][change['mode']]
return [] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_listeners'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Gets listeners of changed Property on a HasProperties instance |
def smudgeraw(target, offset, magicbytes):
magicbytes = magicbytes.replace('\\x', '').decode('hex')
_backup_bytes(target, offset, len(magicbytes))
_smudge_bytes(target, offset, magicbytes) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'smudgeraw'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Smudge magic bytes with raw bytes |
def getflags(fd):
flags_ptr = ffi.new('uint64_t*')
flags_buf = ffi.buffer(flags_ptr)
fcntl.ioctl(fd, lib.FS_IOC_GETFLAGS, flags_buf)
return flags_ptr[0] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getflags'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fd'}; {'... | Gets per-file filesystem flags. |
def _treat_devices_added(self):
try:
devices_details_list = self._plugin_rpc.get_devices_details_list(
self._context, self._added_ports, self._agent_id)
except Exception as exc:
LOG.debug("Unable to get ports details for "
"devices %(devices)... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_treat_devices_added'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Process the new devices. |
def getCheckedOption(self):
if self.__silentRButton.isChecked():
return GCPluginConfigDialog.SILENT
if self.__statusbarRButton.isChecked():
return GCPluginConfigDialog.STATUS_BAR
return GCPluginConfigDialog.LOG | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getCheckedOption'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Returns what destination is selected |
def mget(self, key, *keys, encoding=_NOTSET):
return self.execute(b'MGET', key, *keys, encoding=encoding) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mget'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Get the values of all the given keys. |
def reduce_sum_square(attrs, inputs, proto_obj):
square_op = symbol.square(inputs[0])
sum_op = symbol.sum(square_op, axis=attrs.get('axes'),
keepdims=attrs.get('keepdims'))
return sum_op, attrs, inputs | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reduce_sum_square'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | Reduce the array along a given axis by sum square value |
def prep_rg_names(item, config, fc_name, fc_date):
if fc_name and fc_date:
lane_name = "%s_%s_%s" % (item["lane"], fc_date, fc_name)
else:
lane_name = item["description"]
return {"rg": item["description"],
"sample": item["description"],
"lane": lane_name,
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prep_rg_names'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': []... | Generate read group names from item inputs. |
def _handle_multiple_svcallers(data, stage):
svs = get_svcallers(data)
if stage == "ensemble" and dd.get_svprioritize(data):
svs.append("prioritize")
out = []
for svcaller in svs:
if svcaller in _get_callers([data], stage):
base = copy.deepcopy(data)
final_svs = [... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_handle_multiple_svcallers'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':... | Retrieve configured structural variation caller, handling multiple. |
def remove_unused_resources(issues, app_dir, ignore_layouts):
for issue in issues:
filepath = os.path.join(app_dir, issue.filepath)
if issue.remove_file:
remove_resource_file(issue, filepath, ignore_layouts)
else:
remove_resource_value(issue, filepath) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_unused_resources'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children... | Remove the file or the value inside the file depending if the whole file is unused or not. |
def write(self, fptr):
self._validate(writing=True)
length = 16 + 4 * len(self.compatibility_list)
fptr.write(struct.pack('>I4s', length, b'ftyp'))
fptr.write(self.brand.encode())
fptr.write(struct.pack('>I', self.minor_version))
for item in self.compatibility_list:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Write a File Type box to file. |
def complete(self, text, state):
"Generic readline completion entry point."
results = [w for w in self.words if w.startswith(text)] + [None]
if results != [None]:
return results[state]
buffer = readline.get_line_buffer()
line = readline.get_line_buffer().split()
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'complete'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Generic readline completion entry point. |
def getfile(data_name, path):
data_source = get_data_object(data_name, use_data_config=False)
if not data_source:
if 'output' in data_name:
floyd_logger.info("Note: You cannot clone the output of a running job. You need to wait for it to finish.")
sys.exit()
url = "{}/api/v1/reso... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getfile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data... | Download a specific file from a dataset. |
def create_all_tables(self):
for klass in self.__get_classes():
if not klass.exists():
klass.create_table(read_capacity_units=1, write_capacity_units=1, wait=True) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_all_tables'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Create database tables for all known database data-models. |
def probe(self, axis: str, distance: float) -> Dict[str, float]:
return self._smoothie_driver.probe_axis(axis, distance) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'probe'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Run a probe and return the new position dict |
def _get_date(self, decrypted_content):
date_field = struct.unpack('<5B', decrypted_content[:5])
dw1 = date_field[0]
dw2 = date_field[1]
dw3 = date_field[2]
dw4 = date_field[3]
dw5 = date_field[4]
y = (dw1 << 6) | (dw2 >> 2)
mon = ((dw2 & 0x03) << 2) | (dw... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_date'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | This method is used to decode the packed dates of entries |
def blend_color(color, color2):
r1, g1, b1 = hex_to_rgb(color)
r2, g2, b2 = hex_to_rgb(color2)
r3 = int(0.5 * r1 + 0.5 * r2)
g3 = int(0.5 * g1 + 0.5 * g2)
b3 = int(0.5 * b1 + 0.5 * b2)
return rgb_to_hex((r3, g3, b3)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'blend_color'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Blend two colors together. |
def _handle_response(self, response):
if not response.ok:
raise ScrapydResponseError(
"Scrapyd returned a {0} error: {1}".format(
response.status_code,
response.text))
try:
json = response.json()
except ValueError:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_handle_response'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Handles the response received from Scrapyd. |
def _obtain_token(self):
if self.expiration and self.expiration > datetime.datetime.now():
return
resp = requests.post("{}/1.1/oauth/token".format(API_URL), data={
"client_id": self.client_id,
"client_secret": self.client_secret,
"grant_type": "client_cred... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_obtain_token'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Obtain an auth token from client id and client secret. |
def init(self):
if not self.export_enable:
return None
server_uri = '{}:{}'.format(self.host, self.port)
try:
s = KafkaProducer(bootstrap_servers=server_uri,
value_serializer=lambda v: json.dumps(v).encode('utf-8'),
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Init the connection to the Kafka server. |
def negociate_content(default='json-ld'):
mimetype = request.accept_mimetypes.best_match(ACCEPTED_MIME_TYPES.keys())
return ACCEPTED_MIME_TYPES.get(mimetype, default) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'negociate_content'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', ... | Perform a content negociation on the format given the Accept header |
def _keep_alive(self):
send_next_keep_alive_at = 0
while not self.is_closed:
if not self.is_ready:
self._reconnect()
continue
if time.monotonic() > send_next_keep_alive_at:
command = KEEP_ALIVE_COMMAND_PREAMBLE + [self.wb1, self.wb2... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_keep_alive'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Send keep alive messages continuously to bridge. |
async def initialize(self):
flavors = await self._list_flavors()
images = await self._list_images()
self.flavors_map = bidict()
self.images_map = bidict()
self.images_details = {}
for flavor in flavors:
self.flavors_map.put(flavor['id'], flavor['name'], on_dup... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'initialize'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Initialize static data like images and flavores and set it as object property |
def cat(dataset, query, bounds, indent, compact, dst_crs, pagesize, sortby):
dump_kwds = {"sort_keys": True}
if indent:
dump_kwds["indent"] = indent
if compact:
dump_kwds["separators"] = (",", ":")
table = bcdata.validate_name(dataset)
for feat in bcdata.get_features(
table, ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cat'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11']}; {'id': '4', 'type': 'identifier', '... | Write DataBC features to stdout as GeoJSON feature objects. |
def availability_rtf() -> bool:
unrtf = tools['unrtf']
if unrtf:
return True
elif pyth:
log.warning("RTF conversion: unrtf missing; "
"using pyth (less efficient)")
return True
else:
return False | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'availability_rtf'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'type', 'children': ['5']}; {'id': '5'... | Is an RTF processor available? |
def _shutdown(self, message=None, code=0):
if self._shutdown_complete:
sys.exit(code)
if self.shutdown_callback is not None:
self.shutdown_callback(message, code)
if self.pidfile is not None:
self._close_pidfile()
self._shutdown_complete = True
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_shutdown'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Shutdown and cleanup everything. |
def pop(self):
popped = False
result = None
current_node = self._first_node
while not popped:
next_node = current_node.next()
next_next_node = next_node.next()
if not next_next_node:
self._last_node = current_node
self._... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pop'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id'... | Removes the last node from the list |
def write_case_data(self, file):
file.write("function mpc = %s\n" % self._fcn_name)
file.write('\n%%%% MATPOWER Case Format : Version %d\n' % 2)
file.write("mpc.version = '%d';\n" % 2)
file.write("\n%%%%----- Power Flow Data -----%%%%\n")
file.write("%%%% system MVA base\n")
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_case_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Writes the case data in MATPOWER format. |
def bubble_to_js(bblfile:str, jsdir:str=None, oriented:bool=False, **style):
js_converter.bubble_to_dir(bblfile, jsdir, oriented=bool(oriented), **style)
return jsdir | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bubble_to_js'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '13', '18']}; {'id': '4', 'type': 'typed_parameter', 'childr... | Write in jsdir a graph equivalent to those depicted in bubble file |
def check_version(ctx, param, value):
if ctx.resilient_parsing:
return
if not value and ctx.invoked_subcommand != 'run':
ctx.call_on_close(_check_version) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_version'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Check for latest version of renku on PyPI. |
def _get_dynamic_acl_info(self, switch_ip):
cmds = ["enable",
"show ip access-lists dynamic",
"show ip access-lists summary dynamic"]
switch = self._switches.get(switch_ip)
_, acls, bindings = self._run_eos_cmds(cmds, switch)
parsed_acls = self._parse_acl_... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_dynamic_acl_info'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Retrieve ACLs, ACLs rules and interface bindings from switch |
def _get_user(self, username, attrs=ALL_ATTRS):
username = ldap.filter.escape_filter_chars(username)
user_filter = self.user_filter_tmpl % {
'username': self._uni(username)
}
r = self._search(self._byte_p2(user_filter), attrs, self.userdn)
if len(r) == 0:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_user'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Get a user from the ldap |
def _get_jar(self, command, alts=None, allow_missing=False):
dirs = []
for bdir in [self._gatk_dir, self._picard_ref]:
dirs.extend([bdir,
os.path.join(bdir, os.pardir, "gatk")])
if alts is None: alts = []
for check_cmd in [command] + alts:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_jar'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Retrieve the jar for running the specified command. |
def format_assistants_lines(cls, assistants):
lines = cls._format_files(assistants, 'assistants')
if assistants:
lines.append('')
assistant = strip_prefix(random.choice(assistants), 'assistants').replace(os.path.sep, ' ').strip()
if len(assistants) == 1:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_assistants_lines'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []... | Return formatted assistants from the given list in human readable form. |
def download(url, encoding='utf-8'):
import requests
response = requests.get(url)
response.encoding = encoding
return response.text | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'download'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'url... | Returns the text fetched via http GET from URL, read as `encoding` |
def list_all_requests_view(request, requestType):
request_type = get_object_or_404(RequestType, url_name=requestType)
requests = Request.objects.filter(request_type=request_type)
if not request_type.managers.filter(incumbent__user=request.user):
requests = requests.exclude(
~Q(owner__use... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_all_requests_view'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],... | Show all the requests for a given type in list form. |
def exit(self, status=0, message=None):
if status:
self.logger.error(message)
if self.__parser__:
self.__parser__.exit(status, message)
else:
sys.exit(status) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'exit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Delegates to `ArgumentParser.exit` |
def groups_set_topic(self, room_id, topic, **kwargs):
return self.__call_api_post('groups.setTopic', roomId=room_id, topic=topic, kwargs=kwargs) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'groups_set_topic'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children':... | Sets the topic for the private group. |
def __get_wbfmt_format_txt(self, data_nt):
format_txt_val = getattr(data_nt, "format_txt")
if format_txt_val == 1:
return self.fmtname2wbfmtobj.get("very light grey")
if format_txt_val == 2:
return self.fmtname2wbfmtobj.get("light grey")
return self.fmtname2wbfmto... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__get_wbfmt_format_txt'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],... | Return format for text cell from namedtuple field, 'format_txt'. |
def _following_siblings(
self, qname: Union[QualName, bool] = None) -> List[InstanceNode]:
if qname and self.qual_name != qname:
return []
res = []
en = self
for _ in self.after:
en = en.next()
res.append(en)
return res | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_following_siblings'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':... | XPath - return the list of receiver's following siblings. |
def print_tree(self, *, verbose=True):
print("{0} ({1})".format(self.natural_name, self.filepath))
self._print_branch("", depth=0, verbose=verbose) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_tree'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Print a ascii-formatted tree representation of the data contents. |
def unsubscribe(self):
self.subscription = None
self._user_assignment.clear()
self.assignment.clear()
self.subscribed_pattern = None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unsubscribe'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Clear all topic subscriptions and partition assignments |
def GetHashObject(self):
hash_object = rdf_crypto.Hash()
hash_object.num_bytes = self._bytes_read
for algorithm in self._hashers:
setattr(hash_object, algorithm, self._hashers[algorithm].digest())
return hash_object | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetHashObject'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Returns a `Hash` object with appropriate fields filled-in. |
def _invalid_frame(fobj):
fin = fobj.f_code.co_filename
invalid_module = any([fin.endswith(item) for item in _INVALID_MODULES_LIST])
return invalid_module or (not os.path.isfile(fin)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_invalid_frame'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fo... | Select valid stack frame to process. |
def api_download(service, fileId, authorisation):
data = tempfile.SpooledTemporaryFile(max_size=SPOOL_SIZE, mode='w+b')
headers = {'Authorization' : 'send-v1 ' + unpadded_urlsafe_b64encode(authorisation)}
url = service + 'api/download/' + fileId
r = requests.get(url, headers=headers, stream=True)
r.... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'api_download'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Given a Send url, download and return the encrypted data and metadata |
def _get_client_and_key(url, user, password, verbose=0):
session = {}
session['client'] = six.moves.xmlrpc_client.Server(url, verbose=verbose, use_datetime=True)
session['key'] = session['client'].auth.login(user, password)
return session | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_client_and_key'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'childr... | Return the client object and session key for the client |
def _fix_offset(self, state, size, arch=None):
if state is not None:
arch = state.arch
if arch is None:
raise ValueError('Either "state" or "arch" must be specified.')
offset = arch.registers[self.reg_name][0]
if size in self.alt_offsets:
return offset... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_fix_offset'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [],... | This is a hack to deal with small values being stored at offsets into large registers unpredictably |
def document_path_path(cls, project, database, document_path):
return google.api_core.path_template.expand(
"projects/{project}/databases/{database}/documents/{document_path=**}",
project=project,
database=database,
document_path=document_path,
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'document_path_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children... | Return a fully-qualified document_path string. |
def remove(self, name):
fut = self.execute(b'REMOVE', name)
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': 'remove'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Remove a master from Sentinel's monitoring. |
def removeXmlElement(name, directory, file_pattern, logger=None):
for path, dirs, files in os.walk(os.path.abspath(directory)):
for filename in fnmatch.filter(files, file_pattern):
filepath = os.path.join(path, filename)
remove_xml_element_file(name, filepath) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'removeXmlElement'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children'... | Recursively walk a directory and remove XML elements |
def structure_repr(self):
ret = '{%s}' % ', '.join([str(x) for x in self.elements])
return self._wrap_packed(ret) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'structure_repr'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Return the LLVM IR for the structure representation |
def show_multi_buffer(self):
from safe.gui.tools.multi_buffer_dialog import (
MultiBufferDialog)
dialog = MultiBufferDialog(
self.iface.mainWindow(), self.iface, self.dock_widget)
dialog.exec_() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show_multi_buffer'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Show the multi buffer tool. |
def _complete_trajectory(self, trajectory, index):
assert isinstance(trajectory, Trajectory)
assert trajectory.last_time_step.action is None
self._completed_trajectories.append(trajectory)
self._trajectories[index] = Trajectory() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_complete_trajectory'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': ... | Completes the given trajectory at the given index. |
def remove_all_callbacks(self):
for cb_id in list(self._next_tick_callback_removers.keys()):
self.remove_next_tick_callback(cb_id)
for cb_id in list(self._timeout_callback_removers.keys()):
self.remove_timeout_callback(cb_id)
for cb_id in list(self._periodic_callback_remo... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_all_callbacks'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Removes all registered callbacks. |
def sigterm(self, signum, frame):
self.logger.warning("Caught signal %s. Stopping daemon." % signum)
sys.exit(0) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sigterm'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | These actions will be done after SIGTERM. |
def lower_coerce_type_block_type_data(ir_blocks, type_equivalence_hints):
allowed_key_type_spec = (GraphQLInterfaceType, GraphQLObjectType)
allowed_value_type_spec = GraphQLUnionType
for key, value in six.iteritems(type_equivalence_hints):
if (not isinstance(key, allowed_key_type_spec) or
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lower_coerce_type_block_type_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'chi... | Rewrite CoerceType blocks to explicitly state which types are allowed in the coercion. |
def setConf(self, key, value):
self.sparkSession.conf.set(key, value) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setConf'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Sets the given Spark SQL configuration property. |
def magnitude(self):
return math.sqrt(
reduce(lambda x, y: x + y, [x ** 2 for x in self.to_list()])
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'magnitude'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Return magnitude of the vector. |
def format_percent_field(__, prec, number, locale):
prec = PERCENT_DECIMAL_DIGITS if prec is None else int(prec)
locale = Locale.parse(locale)
pattern = locale.percent_formats.get(None)
return pattern.apply(number, locale, force_frac=(prec, prec)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_percent_field'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'childr... | Formats a percent field. |
def _get_comments(group_tasks):
comments = {}
for status, human in _COMMENTS:
num_tasks = _get_number_of_tasks_for(status, group_tasks)
if num_tasks:
space = " " if status in _PENDING_SUB_STATUSES else ""
comments[status] = '{space}* {num_tasks} {human}:\n'.format(
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_comments'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'gro... | Get the human readable comments and quantities for the task types. |
def with_base_config(base_config, extra_config):
config = copy.deepcopy(base_config)
config.update(extra_config)
return config | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'with_base_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Returns the given config dict merged with a base agent conf. |
def _convert_to_array(array_like, dtype):
if isinstance(array_like, bytes):
return np.frombuffer(array_like, dtype=dtype)
return np.asarray(array_like, dtype=dtype) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_to_array'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Convert Matrix attributes which are array-like or buffer to array. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.