sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:now; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 31; 5, 54; 5, 64; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:now; 9, None; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12... | def now(self):
now = None
d = datetime.datetime.now(tz=self.days[0].date.tzinfo)
for_total_seconds = d - \
d.replace(hour=0, minute=0, second=0, microsecond=0)
msm = for_total_seconds.total_seconds() / 60
if self.days[0].date.strftime("%Y-%m-%dZ") == d.strftime("%Y-%m... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:from_dict; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:d; 6, block; 6, 7; 6, 13; 6, 17; 6, 23; 6, 107; 6, 189; 6, 202; 6, 210; 6, 221; 6, 227; 6, 242; 6, 247; 6, 253; 6, 268; 6, 273; 6, 280; 6, 287; 7, expression_statement; 7, 8... | def from_dict(cls, d):
main_memory = MainMemory()
caches = {}
referred_caches = set()
for name, conf in d.items():
caches[name] = Cache(name=name,
**{k: v for k, v in conf.items()
if k not in ['store_to', 'l... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_object_getattr; 3, parameters; 3, 4; 3, 5; 4, identifier:obj; 5, identifier:field; 6, block; 6, 7; 6, 9; 6, 13; 6, 39; 7, expression_statement; 7, 8; 8, string:'''Attribute getter for the objects to operate on.
This function can be overridde... | def _object_getattr(obj, field):
'''Attribute getter for the objects to operate on.
This function can be overridden in classes or instances of Query, Filter, and
Order. Thus, a custom function to extract values to attributes can be
specified, and the system can remain agnostic to the client's data model,
with... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:sorted; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:items; 6, identifier:orders; 7, block; 7, 8; 7, 10; 8, expression_statement; 8, 9; 9, string:'''Returns the elements in `items` sorted according to `orders`'''; 10, retur... | def sorted(cls, items, orders):
'''Returns the elements in `items` sorted according to `orders`'''
return sorted(items, cmp=cls.multipleOrderComparison(orders)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_unique_fields; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 41; 6, for_statement; 6, 7; 6, 8; 6, 13; 7, identifier:unique_together; 8, attribute; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:_m... | def get_unique_fields(self):
for unique_together in self._meta.unique_together:
if 'sort_order' in unique_together:
unique_fields = list(unique_together)
unique_fields.remove('sort_order')
return ['%s_id' % f for f in unique_fields]
return [] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_is_sort_order_unique_together_with_something; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 32; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:unique_together; 9, attribute; 9, 10; 9, 13; 10, attri... | def _is_sort_order_unique_together_with_something(self):
unique_together = self._meta.unique_together
for fields in unique_together:
if 'sort_order' in fields and len(fields) > 1:
return True
return False |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_update; 3, parameters; 3, 4; 4, identifier:qs; 5, block; 5, 6; 6, try_statement; 6, 7; 6, 33; 7, block; 7, 8; 8, with_statement; 8, 9; 8, 16; 9, with_clause; 9, 10; 10, with_item; 10, 11; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14... | def _update(qs):
try:
with transaction.atomic():
qs.update(sort_order=models.F('sort_order') + 1)
except IntegrityError:
for obj in qs.order_by('-sort_order'):
qs.filter(pk=obj.pk).update(sort_order=models.F('sort_order') + 1) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_orders; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:object_pks; 6, block; 6, 7; 6, 18; 6, 42; 6, 57; 6, 105; 6, 156; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:objects_to_sort; 10, call; 10, 11... | def set_orders(self, object_pks):
objects_to_sort = self.filter(pk__in=object_pks)
max_value = self.model.objects.all().aggregate(
models.Max('sort_order')
)['sort_order__max']
orders = list(objects_to_sort.values_list('sort_order', flat=True))
if len(orders) != len(o... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:merge_records; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:env; 5, identifier:model_name; 6, identifier:record_ids; 7, identifier:target_record_id; 8, default_parameter; 8, 9; 8, 10; 9, identifier:field_spec... | def merge_records(env, model_name, record_ids, target_record_id,
field_spec=None, method='orm', delete=True,
exclude_columns=None):
if exclude_columns is None:
exclude_columns = []
if field_spec is None:
field_spec = {}
if isinstance(record_ids, list):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_get_existing_records; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cr; 5, identifier:fp; 6, identifier:module_name; 7, block; 7, 8; 7, 146; 8, function_definition; 8, 9; 8, 10; 8, 15; 9, function_name:yield_element; 10, parameters; 10, 11; 1... | def _get_existing_records(cr, fp, module_name):
def yield_element(node, path=None):
if node.tag not in ['openerp', 'odoo', 'data']:
if node.tag == 'record':
xmlid = node.attrib['id']
if '.' not in xmlid:
module = module_name
els... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:check_ab; 3, parameters; 3, 4; 3, 5; 4, identifier:ab; 5, identifier:verb; 6, block; 6, 7; 6, 9; 6, 27; 6, 67; 6, 96; 6, 107; 6, 115; 6, 123; 6, 155; 6, 187; 7, expression_statement; 7, 8; 8, identifier:r; 9, try_statement; 9, 10; 9, 18; 10, bl... | def check_ab(ab, verb):
r
try:
ab = int(ab)
except VariableCatch:
print('* ERROR :: <ab> must be an integer')
raise
pab = [11, 12, 13, 14, 15, 16, 21, 22, 23, 24, 25, 26,
31, 32, 33, 34, 35, 36, 41, 42, 43, 44, 45, 46,
51, 52, 53, 54, 55, 56, 61, 62, 63, 6... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:check_opt; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:opt; 5, identifier:loop; 6, identifier:ht; 7, identifier:htarg; 8, identifier:verb; 9, block; 9, 10; 9, 12; 9, 16; 9, 40; 9, 44; 9, 60; 9, 91; 9, 134; 10, expression_statemen... | def check_opt(opt, loop, ht, htarg, verb):
r
use_ne_eval = False
if opt == 'parallel':
if numexpr:
use_ne_eval = numexpr.evaluate
elif verb > 0:
print(numexpr_msg)
lagged_splined_fht = False
if ht == 'fht':
if htarg[1] != 0:
lagged_splined_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_abs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:msrc; 5, identifier:mrec; 6, identifier:srcazm; 7, identifier:srcdip; 8, identifier:recazm; 9, identifier:recdip; 10, identifier:verb; 11, block; 11, 12; 11, 14; ... | def get_abs(msrc, mrec, srcazm, srcdip, recazm, recdip, verb):
r
ab_calc = np.array([[11, 12, 13], [21, 22, 23], [31, 32, 33]])
if msrc:
ab_calc += 3
if mrec:
ab_calc += 30
if msrc:
ab_calc -= 33
else:
ab_calc = ab_calc % 10*10 + ab_calc // 10
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:spline_backwards_hankel; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:ht; 5, identifier:htarg; 6, identifier:opt; 7, block; 7, 8; 7, 10; 7, 18; 7, 121; 8, expression_statement; 8, 9; 9, identifier:r; 10, expression_statement; 10, 11; 11, assi... | def spline_backwards_hankel(ht, htarg, opt):
r
ht = ht.lower()
if ht in ['fht', 'qwe', 'hqwe']:
if ht == 'fht':
htarg = _check_targ(htarg, ['fhtfilt', 'pts_per_dec'])
elif ht in ['qwe', 'hqwe']:
htarg = _check_targ(htarg, ['rtol', 'atol', 'nquad', 'maxint',
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 31; 2, function_name:dipole_k; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 4, identifier:src; 5, identifier:rec; 6, identifier:depth; 7, identifier:res; 8, identifier:freq; 9, identifier:wavenumber; 10, defau... | def dipole_k(src, rec, depth, res, freq, wavenumber, ab=11, aniso=None,
epermH=None, epermV=None, mpermH=None, mpermV=None, verb=2):
r
t0 = printstartfinish(verb)
modl = check_model(depth, res, aniso, epermH, epermV, mpermH, mpermV,
False, verb)
depth, res, aniso, epe... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:plot_result; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:filt; 5, identifier:full; 6, default_parameter; 6, 7; 6, 8; 7, identifier:prntres; 8, True; 9, block; 9, 10; 9, 12; 9, 22; 9, 31; 9, 42; 9, 53; 9, 64; 9, 76; 9, 88; 9, 279; 9, 299; 9, ... | def plot_result(filt, full, prntres=True):
r
if not plt:
print(plt_msg)
return
if prntres:
print_result(filt, full)
spacing = full[2][0, :, 0]
shift = full[2][1, 0, :]
minfield = np.squeeze(full[3])
plt.figure("Brute force result", figsize=(9.5, 4.5))
plt.subplots... |
0, module; 0, 1; 0, 10; 0, 12; 0, 21; 0, 32; 0, 122; 0, 134; 0, 143; 0, 152; 0, 163; 0, 223; 0, 372; 0, 384; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_plot_transform_pairs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:fCI; 5, identifier:r; 6, identifier:k; 7, identifier:axes; 8, identifi... | def _plot_transform_pairs(fCI, r, k, axes, tit):
r
plt.sca(axes[0])
plt.title('|' + tit + ' lhs|')
for f in fCI:
if f.name == 'j2':
lhs = f.lhs(k)
plt.loglog(k, np.abs(lhs[0]), lw=2, label='j0')
plt.loglog(k, np.abs(lhs[1]), lw=2, label='j1')
else:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 36; 2, function_name:empy_hankel; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 3, 33; 4, identifier:ftype; 5, identifier:zsrc; 6, identifier:zrec; 7, identifier:res; 8, identifier:freqtime; 9, default_paramete... | def empy_hankel(ftype, zsrc, zrec, res, freqtime, depth=None, aniso=None,
epermH=None, epermV=None, mpermH=None, mpermV=None,
htarg=None, verblhs=0, verbrhs=0):
r
if isinstance(ftype, list):
out = []
for f in ftype:
out.append(empy_hankel(f, zsrc, zrec... |
0, module; 0, 1; 0, 8; 0, 10; 0, 16; 0, 31; 0, 44; 0, 56; 0, 370; 0, 382; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_get_min_val; 3, parameters; 3, 4; 3, 5; 4, identifier:spaceshift; 5, list_splat_pattern; 5, 6; 6, identifier:params; 7, block:; 8, expression_statement; 8, 9; 9, identifier:r; 10, expres... | def _get_min_val(spaceshift, *params):
r
spacing, shift = spaceshift
n, fI, fC, r, r_def, error, reim, cvar, verb, plot, log = params
dlf = _calculate_filter(n, spacing, shift, fI, r_def, reim, 'filt')
k = dlf.base/r[:, None]
for i, f in enumerate(fC):
lhs = f.lhs(k)
if f.name == 'j2... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:wavenumber; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 3, 15; 3, 16; 3, 17; 3, 18; 4, identifier:zsrc; 5, identifier:zrec; 6, identifier:lsrc; 7, identifier:lrec; 8, identifier:depth; 9, identifier:et... | def wavenumber(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH, zetaV, lambd,
ab, xdirect, msrc, mrec, use_ne_eval):
r
PTM, PTE = greenfct(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH,
zetaV, lambd, ab, xdirect, msrc, mrec, use_ne_eval)
PJ0 = None
PJ1 = None
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:reflections; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:depth; 5, identifier:e_zH; 6, identifier:Gam; 7, identifier:lrec; 8, identifier:lsrc; 9, identifier:use_ne_eval; 10, block; 10, 11; 10, 13; 10, 407; 11, expression_s... | def reflections(depth, e_zH, Gam, lrec, lsrc, use_ne_eval):
r
for plus in [True, False]:
if plus:
pm = 1
layer_count = np.arange(depth.size-2, min(lrec, lsrc)-1, -1)
izout = abs(lsrc-lrec)
minmax = max(lrec, lsrc)
else:
pm = -1
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:hquad; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 3, 15; 3, 16; 3, 17; 3, 18; 3, 19; 3, 20; 4, identifier:zsrc; 5, identifier:zrec; 6, identifier:lsrc; 7, identifier:lrec; 8, identifier:off; 9, identi... | def hquad(zsrc, zrec, lsrc, lrec, off, factAng, depth, ab, etaH, etaV, zetaH,
zetaV, xdirect, quadargs, use_ne_eval, msrc, mrec):
r
rtol, atol, limit, a, b, pts_per_dec = quadargs
la = np.log10(a)
lb = np.log10(b)
ilambd = np.logspace(la, lb, (lb-la)*pts_per_dec + 1)
PJ0, PJ1, PJ0b = k... |
0, module; 0, 1; 0, 24; 0, 26; 0, 45; 0, 54; 0, 56; 0, 70; 0, 87; 0, 98; 0, 106; 0, 108; 0, 129; 0, 133; 0, 144; 0, 150; 0, 217; 0, 288; 0, 357; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:quad; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 4, identifier:sPJ0r; 5, identi... | def quad(sPJ0r, sPJ0i, sPJ1r, sPJ1i, sPJ0br, sPJ0bi, ab, off, factAng, iinp):
r
def quad_PJ0(klambd, sPJ0, koff):
r
return sPJ0(np.log(klambd))*special.j0(koff*klambd)
def quad_PJ1(klambd, sPJ1, ab, koff, kang):
r
tP1 = kang*sPJ1(np.log(klambd))
if ab in [11, 12, 21, 22, 14, 24, 15, ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:is_participle_clause_fragment; 3, parameters; 3, 4; 4, identifier:sentence; 5, block; 5, 6; 5, 19; 5, 53; 5, 113; 5, 138; 6, if_statement; 6, 7; 6, 16; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:_begins_with_one_of; 10, argument... | def is_participle_clause_fragment(sentence):
if not _begins_with_one_of(sentence, ['VBG', 'VBN', 'JJ']):
return 0.0
if _begins_with_one_of(sentence, ['JJ']):
doc = nlp(sentence)
fw = [w for w in doc][0]
if fw.dep_ == 'amod':
return 0.0
if _begins_with_one_of(sente... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:check; 3, parameters; 3, 4; 4, identifier:sentence; 5, block; 5, 6; 5, 12; 5, 19; 5, 26; 5, 33; 5, 40; 5, 47; 5, 82; 5, 119; 5, 165; 5, 200; 5, 236; 5, 310; 5, 328; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:result;... | def check(sentence):
result = Feedback()
is_missing_verb = detect_missing_verb(sentence)
is_infinitive = detect_infinitive_phrase(sentence)
is_participle = is_participle_clause_fragment(sentence)
lang_tool_feedback = get_language_tool_feedback(sentence)
subject_and_verb_agree = get_subject_verb_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:execute; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 18; 5, 24; 5, 34; 5, 71; 5, 79; 5, 137; 5, 188; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier... | def execute(self):
self.count = 0
self.taskset = []
self.results = {}
self.totaltime = time.time()
for task in list(self.taskseq):
self.taskset.append(task)
task.add_callback('resolved', self.child_done, self.count)
self.count += 1
self... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:startall; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:wait; 7, False; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwdargs; 10, block; 10, 11; 10, 20; 11, expression_statement; 11, 1... | def startall(self, wait=False, **kwdargs):
self.logger.debug("startall called")
with self.regcond:
while self.status != 'down':
if self.status in ('start', 'up') or self.ev_quit.is_set():
self.logger.error("ignoring duplicate request to start thread pool")... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:handle; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 22; 5, 30; 5, 38; 5, 47; 5, 58; 5, 65; 5, 71; 5, 491; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, ident... | def handle(self):
self.logger = self.server.logger
packet = iis()
packet.datain = self.rfile
packet.dataout = self.wfile
size = struct.calcsize('8h')
line = packet.datain.read(size)
n = len(line)
if n < size:
return
while n > 0:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:load_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:filepath; 6, default_parameter; 6, 7; 6, 8; 7, identifier:chname; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:wait; 11, Tr... | def load_file(self, filepath, chname=None, wait=True,
create_channel=True, display_image=True,
image_loader=None):
if not chname:
channel = self.get_current_channel()
else:
if not self.has_channel(chname) and create_channel:
sel... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:open_uris; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:uris; 6, default_parameter; 6, 7; 6, 8; 7, identifier:chname; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:bulk_add; 11, False; 12, block; 12, 1... | def open_uris(self, uris, chname=None, bulk_add=False):
if len(uris) == 0:
return
if chname is None:
channel = self.get_channel_info()
if channel is None:
return
chname = channel.name
channel = self.get_channel_on_demand(chname)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:add_channel; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 4, identifier:self; 5, identifier:chname; 6, default_parameter; 6, 7; 6, 8; 7, identifier:workspace; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:nu... | def add_channel(self, chname, workspace=None,
num_images=None, settings=None,
settings_template=None,
settings_share=None, share_keylist=None):
with self.lock:
if self.has_channel(chname):
return self.get_channel(chname)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:mode_key_down; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:viewer; 6, identifier:keyname; 7, block; 7, 8; 7, 50; 7, 56; 7, 71; 7, 87; 7, 100; 7, 189; 8, if_statement; 8, 9; 8, 14; 8, 40; 9, comparison_operator:not; 9, 10;... | def mode_key_down(self, viewer, keyname):
if keyname not in self.mode_map:
if (keyname not in self.mode_tbl) or (self._kbdmode != 'meta'):
return False
bnch = self.mode_tbl[keyname]
else:
bnch = self.mode_map[keyname]
mode_name = bnch.name
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:set_sort_cb; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:w; 6, identifier:index; 7, block; 7, 8; 7, 16; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:name; 11, subscript; 11, 12; 11, 15; 12, a... | def set_sort_cb(self, w, index):
name = self.sort_options[index]
self.t_.set(sort_order=name) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:redo; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 23; 5, 33; 5, 48; 5, 58; 5, 197; 5, 212; 5, 222; 5, 232; 5, 244; 5, 250; 5, 254; 5, 307; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:image; 9, ... | def redo(self):
image = self.channel.get_current_image()
if image is None:
return True
path = image.get('path', None)
if path is None:
self.fv.show_error(
"Cannot open image: no value for metadata key 'path'")
return
if path.end... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_download_rtd_zip; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:rtd_version; 6, None; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 35; 9, 46; 9, 63; 9, 75; 9, 87; 9, 99; 9, 114; 9, 1... | def _download_rtd_zip(rtd_version=None, **kwargs):
if not toolkit.family.startswith('qt'):
raise ValueError('Downloaded documentation not compatible with {} '
'UI toolkit browser'.format(toolkit.family))
if rtd_version is None:
rtd_version = _find_rtd_version()
data_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:get_doc; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:logger; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:plugin; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:reporthook; 12, ... | def get_doc(logger=None, plugin=None, reporthook=None):
from ginga.GingaPlugin import GlobalPlugin, LocalPlugin
if isinstance(plugin, GlobalPlugin):
plugin_page = 'plugins_global'
plugin_name = str(plugin)
elif isinstance(plugin, LocalPlugin):
plugin_page = 'plugins_local'
pl... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:redo; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, block; 7, 8; 7, 15; 7, 27; 7, 35; 7, 43; 7, 54; 7, 67; 7, 73; 7, 99; 7, 321; 7, 330; 7, 337; 8, if_statement; 8, 9; 8, 13; 9, not_operator;... | def redo(self, *args):
if not self.gui_up:
return
mod_only = self.w.modified_only.get_state()
treedict = Bunch.caselessDict()
self.treeview.clear()
self.w.status.set_text('')
channel = self.fv.get_channel(self.chname)
if channel is None:
re... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_imload; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:filepath; 6, identifier:kwds; 7, block; 7, 8; 7, 16; 7, 27; 7, 35; 7, 46; 7, 59; 7, 63; 7, 170; 7, 323; 7, 360; 7, 373; 7, 381; 7, 396; 8, expression_statement; 8, 9; 9... | def _imload(self, filepath, kwds):
start_time = time.time()
typ, enc = mimetypes.guess_type(filepath)
if not typ:
typ = 'image/jpeg'
typ, subtyp = typ.split('/')
self.logger.debug("MIME type is %s/%s" % (typ, subtyp))
data_loaded = False
if have_opencv... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_coord_system_name; 3, parameters; 3, 4; 4, identifier:header; 5, block; 5, 6; 5, 77; 5, 87; 5, 92; 5, 102; 5, 107; 5, 117; 5, 197; 5, 207; 5, 212; 5, 222; 5, 227; 5, 237; 5, 242; 5, 252; 5, 257; 6, try_statement; 6, 7; 6, 22; 7, block; 7, 8... | def get_coord_system_name(header):
try:
ctype = header['CTYPE1'].strip().upper()
except KeyError:
try:
ra = header['RA']
try:
equinox = float(header['EQUINOX'])
if equinox < 1984.0:
radecsys = 'FK4'
else:... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_do_info; 3, parameters; 3, 4; 3, 5; 4, identifier:bz; 5, identifier:opt; 6, block; 6, 7; 6, 43; 6, 58; 6, 64; 6, 76; 6, 86; 6, 97; 6, 119; 6, 136; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:_filter_components; 9, parameters; 9... | def _do_info(bz, opt):
def _filter_components(compdetails):
ret = {}
for k, v in compdetails.items():
if v.get("is_active", True):
ret[k] = v
return ret
productname = (opt.components or opt.component_owners or opt.versions)
include_fields = ["name", "id"]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:login; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:user; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:password; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, i... | def login(self, user=None, password=None, restrict_login=None):
if self.api_key:
raise ValueError("cannot login when using an API key")
if user:
self.user = user
if password:
self.password = password
if not self.user:
raise ValueError("miss... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_process_include_fields; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:include_fields; 6, identifier:exclude_fields; 7, identifier:extra_fields; 8, block; 8, 9; 8, 56; 8, 60; 8, 113; 8, 130; 9, function_definition; 9,... | def _process_include_fields(self, include_fields, exclude_fields,
extra_fields):
def _convert_fields(_in):
if not _in:
return _in
for newname, oldname in self._get_api_aliases():
if oldname in _in:
_in.re... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:_getbugs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:self; 5, identifier:idlist; 6, identifier:permissive; 7, default_parameter; 7, 8; 7, 9; 8, identifier:include_fields; 9, None; 10, default_parameter; 10, 11; 10, 12; ... | def _getbugs(self, idlist, permissive,
include_fields=None, exclude_fields=None, extra_fields=None):
oldidlist = idlist
idlist = []
for i in oldidlist:
try:
idlist.append(int(i))
except ValueError:
idlist.append(i)
extra... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:attachfile; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:idlist; 6, identifier:attachfile; 7, identifier:description; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 44; 10, 60;... | def attachfile(self, idlist, attachfile, description, **kwargs):
if isinstance(attachfile, str):
f = open(attachfile, "rb")
elif hasattr(attachfile, 'read'):
f = attachfile
else:
raise TypeError("attachfile must be filename or file-like object")
if "co... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:pre_translation; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:query; 6, block; 6, 7; 6, 15; 6, 57; 6, 85; 6, 95; 6, 123; 6, 139; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:old; 10, call; 10, 11; 10,... | def pre_translation(self, query):
old = query.copy()
if 'bug_id' in query:
if not isinstance(query['bug_id'], list):
query['id'] = query['bug_id'].split(',')
else:
query['id'] = query['bug_id']
del query['bug_id']
if 'component'... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:check_differences; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 29; 5, 45; 5, 63; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:logger; 10, identifier:info; 11, argument_list... | def check_differences(self):
logger.info("Check that mail differences are within the limits.")
if self.conf.size_threshold < 0:
logger.info("Skip checking for size differences.")
if self.conf.content_threshold < 0:
logger.info("Skip checking for content differences.")
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:filecache; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:seconds_of_validity; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:fail_silently; 9, False; 10, block; 10, 11; 10, 13; 10, 231; 10, 254; 11, expre... | def filecache(seconds_of_validity=None, fail_silently=False):
'''
filecache is called and the decorator should be returned.
'''
def filecache_decorator(function):
@_functools.wraps(function)
def function_with_cache(*args, **kwargs):
try:
key = _args_key(functi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:connect; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 17; 9, 255; 10, expression_statement; 10, 11; 11, await;... | async def connect(self, *args, **kwargs):
await self.disconnect()
if 'endpoint' not in kwargs and len(args) < 2:
if args and 'model_name' in kwargs:
raise TypeError('connect() got multiple values for model_name')
elif args:
model_name = args[0]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_watch; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 283; 5, 290; 5, 298; 5, 306; 5, 314; 6, function_definition; 6, 7; 6, 8; 6, 9; 7, function_name:_all_watcher; 8, parameters; 9, block; 9, 10; 10, try_statement; 10, 11; 10, 258... | def _watch(self):
async def _all_watcher():
try:
allwatcher = client.AllWatcherFacade.from_connection(
self.connection())
while not self._watch_stopping.is_set():
try:
results = await utils.run_with_inter... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:add_machine; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:spec; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:constraints; 10, None; 11, default_parameter; 11, 1... | async def add_machine(
self, spec=None, constraints=None, disks=None, series=None):
params = client.AddMachineParams()
if spec:
if spec.startswith("ssh:"):
placement, target, private_key_path = spec.split(":")
user, host = target.split("@")
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_action_output; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:action_uuid; 6, default_parameter; 6, 7; 6, 8; 7, identifier:wait; 8, None; 9, block; 9, 10; 9, 25; 9, 38; 9, 79; 9, 92; 9, 102; 9, 129; 10, expression_statem... | async def get_action_output(self, action_uuid, wait=None):
action_facade = client.ActionFacade.from_connection(
self.connection()
)
entity = [{'tag': tag.action(action_uuid)}]
async def _wait_for_action_status():
while True:
action_output = await a... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:connect; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 17; 10, expression_statement; 10, 11; 11, await; 11, 12;... | async def connect(self, *args, **kwargs):
await self.disconnect()
if 'endpoint' not in kwargs and len(args) < 2:
if args and 'model_name' in kwargs:
raise TypeError('connect() got multiple values for '
'controller_name')
elif args:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:add_credential; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:name; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:credential; 10, None; 11, default_paramet... | async def add_credential(self, name=None, credential=None, cloud=None,
owner=None, force=False):
if not cloud:
cloud = await self.get_cloud()
if not owner:
owner = self.connection().info['user-info']['identity']
if credential and not name:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:matches; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:specs; 7, block; 7, 8; 7, 67; 8, for_statement; 8, 9; 8, 10; 8, 11; 9, identifier:spec; 10, identifier:specs; 11, block; 11, 12; 11, 38; 12, if_s... | def matches(self, *specs):
for spec in specs:
if ':' in spec:
app_name, endpoint_name = spec.split(':')
else:
app_name, endpoint_name = spec, None
for endpoint in self.endpoints:
if app_name == endpoint.application.name and \
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:create; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:source; 5, default_parameter; 5, 6; 5, 7; 6, identifier:requirement_files; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:force;... | def create(source,
requirement_files=None,
force=False,
keep_wheels=False,
archive_destination_dir='.',
python_versions=None,
validate_archive=False,
wheel_args='',
archive_format='zip',
build_tag=''):
if validate_arc... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:build_trading_timeline; 3, parameters; 3, 4; 3, 5; 4, identifier:start; 5, identifier:end; 6, block; 6, 7; 6, 9; 6, 26; 6, 41; 6, 324; 7, expression_statement; 7, 8; 8, string:''' Build the daily-based index we will trade on '''; 9, expression_... | def build_trading_timeline(start, end):
''' Build the daily-based index we will trade on '''
EMPTY_DATES = pd.date_range('2000/01/01', periods=0, tz=pytz.utc)
now = dt.datetime.now(tz=pytz.utc)
if not start:
if not end:
bt_dates = EMPTY_DATES
live_dates = pd.date_range(
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:gcal2jd; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:year; 5, identifier:month; 6, identifier:day; 7, block; 7, 8; 7, 15; 7, 22; 7, 29; 7, 41; 7, 58; 7, 77; 7, 91; 7, 103; 7, 109; 7, 113; 8, expression_statement; 8, 9; 9, assignment; 9, 10; ... | def gcal2jd(year, month, day):
year = int(year)
month = int(month)
day = int(day)
a = ipart((month - 14) / 12.0)
jd = ipart((1461 * (year + 4800 + a)) / 4.0)
jd += ipart((367 * (month - 2 - 12 * a)) / 12.0)
x = ipart((year + 4900 + a) / 100.0)
jd -= ipart((3 * x) / 4.0)
jd += day - 2... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_check_restart_params; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:restart_strategy; 6, identifier:min_beta; 7, identifier:s_greedy; 8, identifier:xi_restart; 9, block; 9, 10; 9, 12; 9, 19; 9, 33; 9, 48; 9, 62... | def _check_restart_params(self, restart_strategy, min_beta, s_greedy,
xi_restart):
r
if restart_strategy is None:
return True
if self.mode != 'regular':
raise ValueError('Restarting strategies can only be used with '
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:method_cache; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:by; 6, string:'value'; 7, default_parameter; 7, 8; 7, 9; 8, identifier:method; 9, string:'run'; 10, block; 10, 11; 10, 243; 11, function_definition; 11, 1... | def method_cache(by='value',method='run'):
def decorate_(func):
def decorate(*args, **kwargs):
model = args[0]
assert hasattr(model,method), "Model must have a '%s' method."%method
if func.__name__ == method:
method_args = kwargs
else:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_format_command; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:ctx; 5, identifier:show_nested; 6, default_parameter; 6, 7; 6, 8; 7, identifier:commands; 8, None; 9, block; 9, 10; 9, 21; 9, 31; 9, 41; 9, 51; 9, 61; 9, 70; 9, 77; 9, 87; 9, 96; 9... | def _format_command(ctx, show_nested, commands=None):
if getattr(ctx.command, 'hidden', False):
return
for line in _format_description(ctx):
yield line
yield '.. program:: {}'.format(ctx.command_path)
for line in _format_usage(ctx):
yield line
lines = list(_format_options(ctx... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:_formatter; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:x; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:y; 10, None; 11, default_parameter; 11, 1... | def _formatter(self, x=None, y=None, z=None, s=None, label=None, **kwargs):
def is_date(axis):
fmt = axis.get_major_formatter()
return (isinstance(fmt, mdates.DateFormatter)
or isinstance(fmt, mdates.AutoDateFormatter))
def format_date(num):
if num is... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:datacursor; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:artists; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:axes; 9, None; 10, dictionary_splat_pattern; 10, 11; 11, identifier:kwargs; 12, blo... | def datacursor(artists=None, axes=None, **kwargs):
def plotted_artists(ax):
artists = (ax.lines + ax.patches + ax.collections
+ ax.images + ax.containers)
return artists
if axes is None:
managers = pylab_helpers.Gcf.get_all_fig_managers()
figs = [manager.canvas... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:wait_for_notification; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 10; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:handle; 7, type; 7, 8; 8, identifier:int; 9, identifier:delegate; 10, typed_parameter; 10, 11; 10, 12; 11, identif... | def wait_for_notification(self, handle: int, delegate, notification_timeout: float):
if not self.is_connected():
raise BluetoothBackendException('Not connected to any device.')
attempt = 0
delay = 10
_LOGGER.debug("Enter write_ble (%s)", current_thread())
while attemp... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:simplify_tree; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:tree; 5, default_parameter; 5, 6; 5, 7; 6, identifier:unpack_lists; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:in_list; 10, False; 11, block; 11, 12; 11, 188; 12, if_... | def simplify_tree(tree, unpack_lists=True, in_list=False):
if isinstance(tree, BaseNode) and not isinstance(tree, Terminal):
used_fields = [field for field in tree._fields if getattr(tree, field, False)]
if len(used_fields) == 1:
result = getattr(tree, used_fields[0])
else:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:run; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, block; 7, 8; 7, 19; 7, 30; 7, 78; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:params; 11, call; 11, 12; 11, 1... | def run(self, *args):
params = self.parser.parse_args(args)
config_file = os.path.expanduser('~/.sortinghat')
if params.action == 'get':
code = self.get(params.parameter, config_file)
elif params.action == 'set':
code = self.set(params.parameter, params.value, con... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:export; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:source; 7, None; 8, block; 8, 9; 8, 13; 8, 27; 8, 97; 8, 114; 8, 142; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, ide... | def export(self, source=None):
uidentities = {}
uids = api.unique_identities(self.db, source=source)
for uid in uids:
enrollments = [rol.to_dict()
for rol in api.enrollments(self.db, uuid=uid.uuid)]
u = uid.to_dict()
u['identities'].... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:export; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 21; 5, 67; 5, 92; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:organizations; 9, dictionary; 10, expression_statement; 10, 11; 11, assignment;... | def export(self):
organizations = {}
orgs = api.registry(self.db)
for org in orgs:
domains = [{'domain': dom.domain,
'is_top': dom.is_top_domain}
for dom in org.domains]
domains.sort(key=lambda x: x['domain'])
org... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:match; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:a; 6, identifier:b; 7, block; 7, 8; 7, 21; 7, 34; 7, 53; 7, 62; 7, 71; 7, 90; 8, if_statement; 8, 9; 8, 15; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; 11, identifi... | def match(self, a, b):
if not isinstance(a, UniqueIdentity):
raise ValueError("<a> is not an instance of UniqueIdentity")
if not isinstance(b, UniqueIdentity):
raise ValueError("<b> is not an instance of UniqueIdentity")
if a.uuid and b.uuid and a.uuid == b.uuid:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:merge_enrollments; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:db; 5, identifier:uuid; 6, identifier:organization; 7, block; 7, 8; 8, with_statement; 8, 9; 8, 19; 9, with_clause; 9, 10; 10, with_item; 10, 11; 11, as_pattern; 11, 12; 11, 17; ... | def merge_enrollments(db, uuid, organization):
with db.connect() as session:
uidentity = find_unique_identity(session, uuid)
if not uidentity:
raise NotFoundError(entity=uuid)
org = find_organization(session, organization)
if not org:
raise NotFoundError(entit... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:registry; 3, parameters; 3, 4; 3, 5; 4, identifier:db; 5, default_parameter; 5, 6; 5, 7; 6, identifier:term; 7, None; 8, block; 8, 9; 8, 13; 8, 106; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:orgs; 12, list:[... | def registry(db, term=None):
orgs = []
with db.connect() as session:
if term:
orgs = session.query(Organization).\
filter(Organization.name.like('%' + term + '%')).\
order_by(Organization.name).all()
if not orgs:
raise NotFoundError... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:domains; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:db; 5, default_parameter; 5, 6; 5, 7; 6, identifier:domain; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:top; 10, False; 11, block; 11, 12; 11, 16; 11, 193; 12, expression_st... | def domains(db, domain=None, top=False):
doms = []
with db.connect() as session:
if domain:
dom = find_domain(session, domain)
if not dom:
if not top:
raise NotFoundError(entity=domain)
else:
add_dot = lambda... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:countries; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:db; 5, default_parameter; 5, 6; 5, 7; 6, identifier:code; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:term; 10, None; 11, block; 11, 12; 11, 39; 11, 60; 11, 64; 11, 195; 1... | def countries(db, code=None, term=None):
def _is_code_valid(code):
return type(code) == str \
and len(code) == 2 \
and code.isalpha()
if code is not None and not _is_code_valid(code):
raise InvalidValueError('country code must be a 2 length alpha string - %s given'
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:enrollments; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:db; 5, default_parameter; 5, 6; 5, 7; 6, identifier:uuid; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:organization; 10, None; 11, default_parameter; 11, 12... | def enrollments(db, uuid=None, organization=None, from_date=None, to_date=None):
if not from_date:
from_date = MIN_PERIOD_DATE
if not to_date:
to_date = MAX_PERIOD_DATE
if from_date < MIN_PERIOD_DATE or from_date > MAX_PERIOD_DATE:
raise InvalidValueError("'from_date' %s is out of bo... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:blacklist; 3, parameters; 3, 4; 3, 5; 4, identifier:db; 5, default_parameter; 5, 6; 5, 7; 6, identifier:term; 7, None; 8, block; 8, 9; 8, 13; 8, 106; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:mbs; 12, list:[... | def blacklist(db, term=None):
mbs = []
with db.connect() as session:
if term:
mbs = session.query(MatchingBlacklist).\
filter(MatchingBlacklist.excluded.like('%' + term + '%')).\
order_by(MatchingBlacklist.excluded).all()
if not mbs:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__parse_identities; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:stream; 6, block; 6, 7; 6, 96; 6, 105; 6, 109; 7, function_definition; 7, 8; 7, 9; 7, 13; 8, function_name:__create_sh_identities; 9, parameters; 9, 10; 9, 11; 9, ... | def __parse_identities(self, stream):
def __create_sh_identities(name, emails, yaml_entry):
ids = []
ids.append(Identity(name=name, source=self.source))
if emails:
for m in emails:
ids.append(Identity(email=m, source=self.source))
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__parse_organizations; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:stream; 6, block; 6, 7; 6, 12; 6, 21; 7, if_statement; 7, 8; 7, 10; 8, not_operator; 8, 9; 9, identifier:stream; 10, block; 10, 11; 11, return_statement; 12, ex... | def __parse_organizations(self, stream):
if not stream:
return
yaml_file = self.__load_yml(stream)
try:
for element in yaml_file:
name = self.__encode(element['organization'])
if not name:
error = "Empty organization nam... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__parse; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:stream; 6, block; 6, 7; 6, 18; 6, 27; 6, 34; 6, 41; 7, if_statement; 7, 8; 7, 10; 8, not_operator; 8, 9; 9, identifier:stream; 10, block; 10, 11; 11, raise_statement; 11, 12;... | def __parse(self, stream):
if not stream:
raise InvalidFormatError(cause="stream cannot be empty or None")
json = self.__load_json(stream)
self.__parse_organizations(json)
self.__parse_identities(json)
self.__parse_blacklist(json) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__parse_blacklist; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:json; 6, block; 6, 7; 7, try_statement; 7, 8; 7, 72; 8, block; 8, 9; 9, for_statement; 9, 10; 9, 11; 9, 14; 10, identifier:entry; 11, subscript; 11, 12; 11, 13; 12,... | def __parse_blacklist(self, json):
try:
for entry in json['blacklist']:
if not entry:
msg = "invalid json format. Blacklist entries cannot be null or empty"
raise InvalidFormatError(cause=msg)
excluded = self.__encode(entry)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__parse_organizations; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:json; 6, block; 6, 7; 7, try_statement; 7, 8; 7, 115; 8, block; 8, 9; 9, for_statement; 9, 10; 9, 11; 9, 14; 10, identifier:organization; 11, subscript; 11, 12;... | def __parse_organizations(self, json):
try:
for organization in json['organizations']:
name = self.__encode(organization)
org = self._organizations.get(name, None)
if not org:
org = Organization(name=name)
self._... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:import_blacklist; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:parser; 6, block; 6, 7; 6, 13; 6, 20; 6, 24; 6, 94; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:blacklist; 10, attribute; 10, 11; 10, 12... | def import_blacklist(self, parser):
blacklist = parser.blacklist
self.log("Loading blacklist...")
n = 0
for entry in blacklist:
try:
api.add_to_matching_blacklist(self.db, entry.excluded)
self.display('load_blacklist.tmpl', entry=entry.excluded... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:import_organizations; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:parser; 6, default_parameter; 6, 7; 6, 8; 7, identifier:overwrite; 8, False; 9, block; 9, 10; 9, 16; 10, expression_statement; 10, 11; 11, assignment; 11, ... | def import_organizations(self, parser, overwrite=False):
orgs = parser.organizations
for org in orgs:
try:
api.add_organization(self.db, org.name)
except ValueError as e:
raise RuntimeError(str(e))
except AlreadyExistsError as e:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:import_identities; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:parser; 6, default_parameter; 6, 7; 6, 8; 7, identifier:matching; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:matc... | def import_identities(self, parser, matching=None, match_new=False,
no_strict_matching=False,
reset=False, verbose=False):
matcher = None
if matching:
strict = not no_strict_matching
try:
blacklist = api.blacklis... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:__create_profile_from_identities; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:identities; 6, identifier:uuid; 7, identifier:verbose; 8, block; 8, 9; 8, 12; 8, 16; 8, 20; 8, 24; 8, 28; 8, 32; 8, 115; 8, 153; 8, 163; ... | def __create_profile_from_identities(self, identities, uuid, verbose):
import re
EMAIL_ADDRESS_REGEX = r"^(?P<email>[^\s@]+@[^\s@.]+\.[^\s@]+)$"
NAME_REGEX = r"^\w+\s\w+"
name = None
email = None
username = None
for identity in identities:
if not name ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:__parse_identities; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:aliases; 6, identifier:email_to_employer; 7, block; 7, 8; 7, 15; 7, 22; 7, 181; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; ... | def __parse_identities(self, aliases, email_to_employer):
self.__parse_aliases_stream(aliases)
self.__parse_email_to_employer_stream(email_to_employer)
for alias, email in self.__raw_aliases.items():
uid = self._identities.get(email, None)
if not uid:
uid ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:initialize; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:reuse; 8, False; 9, block; 9, 10; 9, 18; 9, 26; 9, 34; 9, 42; 9, 58; 9, 158; 10, expression_statement; 10, 11; ... | def initialize(self, name, reuse=False):
user = self._kwargs['user']
password = self._kwargs['password']
host = self._kwargs['host']
port = self._kwargs['port']
if '-' in name:
self.error("dabase name '%s' cannot contain '-' characters" % name)
return CODE... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:merge_date_ranges; 3, parameters; 3, 4; 4, identifier:dates; 5, block; 5, 6; 5, 11; 5, 25; 5, 34; 5, 153; 6, if_statement; 6, 7; 6, 9; 7, not_operator; 7, 8; 8, identifier:dates; 9, block; 9, 10; 10, return_statement; 11, expression_statement; ... | def merge_date_ranges(dates):
if not dates:
return
sorted_dates = sorted([sorted(t) for t in dates])
saved = list(sorted_dates[0])
for st, en in sorted_dates:
if st < MIN_PERIOD_DATE or st > MAX_PERIOD_DATE:
raise ValueError("start date %s is out of bounds" % str(st))
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:uuid; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:source; 5, default_parameter; 5, 6; 5, 7; 6, identifier:email; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:name; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, ide... | def uuid(source, email=None, name=None, username=None):
if source is None:
raise ValueError("source cannot be None")
if source == '':
raise ValueError("source cannot be an empty string")
if not (email or name or username):
raise ValueError("identity data cannot be None or empty")
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:call; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 11; 3, 16; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:method_name; 7, type; 7, 8; 8, identifier:str; 9, list_splat_pattern; 9, 10; 10, identifier:args; 11, typed_default_paramete... | def call(self, method_name: str, *args, rpc_timeout: float = None, **kwargs):
request = utils.rpc_request(method_name, *args, **kwargs)
_log.debug("Sending request: %s", request)
self._socket.send_multipart([to_msgpack(request)])
if rpc_timeout is None:
rpc_timeout = self.rpc... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:init_process_dut; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:contextlist; 5, identifier:conf; 6, identifier:index; 7, identifier:args; 8, block; 8, 9; 8, 311; 8, 320; 9, if_statement; 9, 10; 9, 17; 9, 97; 10, boolean_operator:and; 10,... | def init_process_dut(contextlist, conf, index, args):
if "subtype" in conf and conf["subtype"]:
if conf["subtype"] != "console":
msg = "Unrecognized process subtype: {}"
contextlist.logger.error(msg.format(conf["subtype"]))
raise ResourceInitError("Unrecognized process su... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:allocate; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:dut_configuration_list; 6, default_parameter; 6, 7; 6, 8; 7, identifier:args; 8, None; 9, block; 9, 10; 9, 18; 9, 31; 9, 81; 9, 116; 9, 122; 9, 126; 9, 173; 9, 181; 9,... | def allocate(self, dut_configuration_list, args=None):
dut_config_list = dut_configuration_list.get_dut_configuration()
if not isinstance(dut_config_list, list):
raise AllocationError("Invalid dut configuration format!")
if next((item for item in dut_config_list if item.get("type") =... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_allocate; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:dut_configuration; 6, block; 6, 7; 6, 22; 6, 271; 7, if_statement; 7, 8; 7, 13; 8, comparison_operator:==; 8, 9; 8, 12; 9, subscript; 9, 10; 9, 11; 10, identifier:dut_confi... | def _allocate(self, dut_configuration):
if dut_configuration["type"] == "hardware":
dut_configuration.set("type", "mbed")
if dut_configuration["type"] == "mbed":
if not self._available_devices:
raise AllocationError("No available devices to allocate from")
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:__generate; 3, parameters; 3, 4; 4, identifier:results; 5, block; 5, 6; 5, 19; 5, 23; 5, 27; 5, 31; 5, 35; 5, 96; 5, 312; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 12; 8, pattern_list; 8, 9; 8, 10; 8, 11; 9, identifier:doc; 10, ide... | def __generate(results):
doc, tag, text = Doc().tagtext()
count = 0
fails = 0
errors = 0
skips = 0
for result in results:
if result.passed() is False:
if result.retries_left > 0:
continue
count += 1
i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:init_base_logging; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 4, default_parameter; 4, 5; 4, 6; 5, identifier:directory; 6, string:"./log"; 7, default_parameter; 7, 8; 7, 9; 8, identifier:verbose; 9, integer:0; 10, default_p... | def init_base_logging(directory="./log", verbose=0, silent=False, color=False, no_file=False,
truncate=True, config_location=None):
global LOGPATHDIR
global STANDALONE_LOGGING
global TRUNCATE_LOG
global COLOR_ON
global SILENT_ON
global VERBOSE_LEVEL
if config_location:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:assertJsonContains; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:jsonStr; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:key; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:message... | def assertJsonContains(jsonStr=None, key=None, message=None):
if jsonStr is not None:
try:
data = json.loads(jsonStr)
if key not in data:
raise TestStepFail(
format_message(message) if message is not None else "Assert: "
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_read_fd; 3, parameters; 3, 4; 4, identifier:file_descr; 5, block; 5, 6; 5, 58; 5, 172; 6, try_statement; 6, 7; 6, 20; 7, block; 7, 8; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:line; 11, call; 11, 12; 11, 15; 12... | def _read_fd(file_descr):
try:
line = os.read(file_descr, 1024 * 1024)
except OSError:
stream_desc = NonBlockingStreamReader._get_sd(file_descr)
if stream_desc is not None:
stream_desc.has_error = True
if stream_desc.callback is not Non... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:run; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:args; 7, None; 8, block; 8, 9; 8, 15; 8, 26; 8, 36; 8, 60; 8, 66; 8, 99; 8, 116; 8, 129; 8, 179; 8, 228; 8, 263; 8, 274; 8, 326; 9, expression_s... | def run(self, args=None):
retcodesummary = ExitCodes.EXIT_SUCCESS
self.args = args if args else self.args
if not self.check_args():
return retcodesummary
if self.args.clean:
if not self.args.tc and not self.args.suite:
return retcodesummary
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:generate_object_graphs_by_class; 3, parameters; 3, 4; 4, identifier:classlist; 5, block; 5, 6; 5, 18; 5, 22; 5, 35; 6, try_statement; 6, 7; 6, 14; 7, block; 7, 8; 7, 11; 8, import_statement; 8, 9; 9, dotted_name; 9, 10; 10, identifier:objgraph;... | def generate_object_graphs_by_class(classlist):
try:
import objgraph
import gc
except ImportError:
return
graphcount = 0
if not isinstance(classlist, list):
classlist = [classlist]
for class_item in classlist:
for obj in gc.get_objects():
if isinst... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_wait_for_exec_ready; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 113; 5, 165; 5, 189; 5, 195; 6, while_statement; 6, 7; 6, 22; 7, boolean_operator:and; 7, 8; 7, 17; 8, not_operator; 8, 9; 9, call; 9, 10; 9, 15; 10, attribute; 1... | def _wait_for_exec_ready(self):
while not self.response_received.wait(1) and self.query_timeout != 0:
if self.query_timeout != 0 and self.query_timeout < self.get_time():
if self.prev:
cmd = self.prev.cmd
else:
cmd = "???"
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:execute_command; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:req; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 88; 8, 149; 8, 157; 8, 176; 8, 182; 8, 193; 8, 218; 8, 233; 8, 240; 8, 270; 8, ... | def execute_command(self, req, **kwargs):
if isinstance(req, string_types):
timeout = 50
wait = True
asynchronous = False
for key in kwargs:
if key == 'wait':
wait = kwargs[key]
elif key == 'timeout':
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:run; 3, parameters; 4, block; 4, 5; 4, 20; 4, 336; 5, expression_statement; 5, 6; 6, call; 6, 7; 6, 12; 7, attribute; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:Dut; 10, identifier:_logger; 11, identifier:debug; 12, argument_list; 12... | def run():
Dut._logger.debug("Start DUT communication", extra={'type': '<->'})
while Dut._run:
Dut._sem.acquire()
try:
dut = Dut._signalled_duts.pop()
if dut.waiting_for_response is not None:
item = dut.waiting_for_response
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.