sequence
stringlengths
546
16.2k
code
stringlengths
108
19.3k
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, 8; 5, 9; 5, 10; 5, 14; 5, 15; 5, 16; 5, 17; 5, 38; 5, 39; 5, 40; 5, 41; 5, 42; 5, 43; 5, 44; 5, 67; 5, 68; 5, 69; 5, 70; 5, 71; 5, 81; 5, 82; 6, expression_statement; 6, 7; 7, com...
def now(self): """ Function to return just the current timestep from this forecast """ # From the comments in issue 19: forecast.days[0] is dated for the # previous day shortly after midnight now = None # Set the time now to be in the same time zone as the first...
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, 9; 6, 15; 6, 19; 6, 25; 6, 26; 6, 110; 6, 111; 6, 193; 6, 194; 6, 207; 6, 215; 6, 226; 6, 227; 6, 233; 6, 248; 6, 253; 6, 259; 6, 274; 6, 279; 6, 280; ...
def from_dict(cls, d): """Create cache hierarchy from dictionary.""" main_memory = MainMemory() caches = {} referred_caches = set() # First pass, create all named caches and collect references for name, conf in d.items(): caches[name] = Cache(name=name, ...
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, 10; 6, 14; 6, 15; 6, 42; 6, 43; 7, expression_statement; 7, 8; 8, string:'''Attribute getter for the objects to operate on. This fun...
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, wit...
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, 8; 5, 43; 6, expression_statement; 6, 7; 7, comment; 8, for_statement; 8, 9; 8, 10; 8, 15; 9, identifier:unique_together; 10, attribute; 10, 11; 10, 14; 11, attribut...
def get_unique_fields(self): """List field names that are unique_together with `sort_order`.""" for unique_together in self._meta.unique_together: if 'sort_order' in unique_together: unique_fields = list(unique_together) unique_fields.remove('sort_order') ...
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, 8; 5, 16; 5, 34; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:un...
def _is_sort_order_unique_together_with_something(self): """ Is the sort_order field unique_together with something """ unique_together = self._meta.unique_together for fields in unique_together: if 'sort_order' in fields and len(fields) > 1: return Tr...
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; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, try_statement; 8, 9; 8, 35; 9, block; 9, 10; 10, with_statement; 10, 11; 10, 18; 11, with_clause; 11, 12; 12, with_item; 12, 13;...
def _update(qs): """ Increment the sort_order in a queryset. Handle IntegrityErrors caused by unique constraints. """ try: with transaction.atomic(): qs.update(sort_order=models.F('sort_order') + 1) except IntegrityError: for obj i...
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, 9; 6, 20; 6, 44; 6, 45; 6, 46; 6, 61; 6, 62; 6, 63; 6, 64; 6, 65; 6, 113; 6, 166; 6, 167; 7, expression_statement; 7, 8; 8, comment; 9, expr...
def set_orders(self, object_pks): """ Perform a mass update of sort_orders across the full queryset. Accepts a list, object_pks, of the intended order for the objects. Works as follows: - Compile a list of all sort orders in the queryset. Leave out anything that isn't ...
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): """Merge several records into the target one. NOTE: This should be executed in end migration scripts for assuring that all the possible rel...
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, 10; 7, 148; 8, expression_statement; 8, 9; 9, comment; 10, function_definition; 10, 11; 10, 12; 10, 17; 11...
def _get_existing_records(cr, fp, module_name): """yield file like objects per 'leaf' node in the xml file that exists. This is for not trying to create a record with partial data in case the record was removed in the database.""" def yield_element(node, path=None): if node.tag not in ['openerp'...
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, 10; 6, 28; 6, 29; 6, 30; 6, 70; 6, 99; 6, 100; 6, 111; 6, 112; 6, 120; 6, 121; 6, 129; 6, 130; 6, 131; 6, 167; 6, 168; 6, 200; 7, expression_sta...
def check_ab(ab, verb): r"""Check source-receiver configuration. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- ab : int Source-receiver con...
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, 13; 9, 17; 9, 41; 9, 42; 9, 46; 9, 62; 9, 93; 9, 94; 9, 137; 10...
def check_opt(opt, loop, ht, htarg, verb): r"""Check optimization parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- opt : {None, 'parallel...
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"""Get required ab's for given angles. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- ...
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, 11; 7, 19; 7, 20; 7, 130; 8, expression_statement; 8, 9; 9, comment; 10, comment; 11, expression_state...
def spline_backwards_hankel(ht, htarg, opt): r"""Check opt if deprecated 'spline' is used. Returns corrected htarg, opt. r""" # Ensure ht is all lowercase ht = ht.lower() # Only relevant for 'fht' and 'hqwe', not for 'quad' if ht in ['fht', 'qwe', 'hqwe']: # Get corresponding htar...
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"""Return the electromagnetic wavenumber-domain field. Calculate the electromagnetic wavenumber-domain field due to infinitesimal small electric or magnetic dip...
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, 13; 9, 23; 9, 32; 9, 33; 9, 44; 9, 55; 9, 56; 9, 67; 9, 79; 9, 91...
def plot_result(filt, full, prntres=True): r"""QC the inversion result. Parameters ---------- - filt, full as returned from fdesign.design with full_output=True - If prntres is True, it calls fdesign.print_result as well. r""" # Check matplotlib (soft dependency) if not plt: pr...
0, module; 0, 1; 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, identifier:tit; 9, block; 9, 10; 9, 12; 9, 13; 9, 22; 9, 33; 9, 123; 9, 135; 9, 144; 9, 145; 9, 154;...
def _plot_transform_pairs(fCI, r, k, axes, tit): r"""Plot the input transform pairs.""" # Plot lhs 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...
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"""Numerical transform pair with empymod. All parameters except ``ftype``, ``verblhs``, and ``verbrhs`` correspond to...
0, module; 0, 1; 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; 7, 8; 7, 10; 7, 11; 7, 17; 7, 32; 7, 33; 7, 46; 7, 47; 7, 59; 7, 60; 7, 394; 7, 395; 7, 407; 7, 408; 8, expression_s...
def _get_min_val(spaceshift, *params): r"""Calculate minimum resolved amplitude or maximum r.""" # Get parameters from tuples spacing, shift = spaceshift n, fI, fC, r, r_def, error, reim, cvar, verb, plot, log = params # Get filter for these parameters dlf = _calculate_filter(n, spacing, shift...
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"""Calculate wavenumber domain solution. Return the wavenumber domain solutions ``PJ0``, ``PJ1``, and ``PJ0b``, which have to be transformed with a Hankel transform to the f...
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, 14; 10, 421; 10, 422;...
def reflections(depth, e_zH, Gam, lrec, lsrc, use_ne_eval): r"""Calculate Rp, Rm. .. math:: R^\pm_n, \bar{R}^\pm_n This function corresponds to equations 64/65 and A-11/A-12 in [HuTS15]_, and loosely to the corresponding files ``Rmin.F90`` and ``Rplus.F90``. This function is called from the f...
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"""Hankel Transform using the ``QUADPACK`` library. This routine uses the ``scipy.integrate.quad`` module, which in turn makes use of the Fortran library ``QUADPACK``...
0, module; 0, 1; 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, identifier:sPJ0i; 6, identifier:sPJ1r; 7, identifier:sPJ1i; 8, identifier:sPJ0br; 9, identifier:sPJ0bi; 10, identifier:ab; 11, identif...
def quad(sPJ0r, sPJ0i, sPJ1r, sPJ1i, sPJ0br, sPJ0bi, ab, off, factAng, iinp): r"""Quadrature for Hankel transform. This is the kernel of the QUAD method, used for the Hankel transforms ``hquad`` and ``hqwe`` (where the integral is not suited for QWE). """ # Define the quadrature kernels def q...
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, 8; 5, 9; 5, 10; 5, 23; 5, 58; 5, 59; 5, 60; 5, 122; 5, 147; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, comment; 10, if_statement; 10, ...
def is_participle_clause_fragment(sentence): """Supply a sentence or fragment and recieve a confidence interval""" # short circuit if sentence or fragment doesn't start with a participle # past participles can sometimes look like adjectives -- ie, Tired if not _begins_with_one_of(sentence, ['VBG', 'VBN'...
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, 8; 5, 9; 5, 10; 5, 11; 5, 12; 5, 13; 5, 14; 5, 15; 5, 16; 5, 17; 5, 18; 5, 24; 5, 31; 5, 38; 5, 45; 5, 52; 5, 59; 5, 60; 5, 96; 5, 133; 5, 179; 5, 214; 5, 250; 5, 325; 5, 32...
def check(sentence): """Supply a sentence or fragment and recieve feedback""" # How we decide what to put as the human readable feedback # # Our order of prefence is, # # 1. Spelling errors. # - A spelling error can change the sentence meaning # 2. Subject-verb agreement errors # ...
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, 8; 5, 14; 5, 20; 5, 26; 5, 36; 5, 37; 5, 74; 5, 82; 5, 83; 5, 144; 5, 145; 5, 196; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, ...
def execute(self): """Run all child tasks concurrently in separate threads. Return 0 after all child tasks have completed execution. """ self.count = 0 self.taskset = [] self.results = {} self.totaltime = time.time() # Register termination callbacks for a...
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, 13; 10, 22; 11, expression_statemen...
def startall(self, wait=False, **kwdargs): """Start all of the threads in the thread pool. If _wait_ is True then don't return until all threads are up and running. Any extra keyword arguments are passed to the worker thread constructor. """ self.logger.debug("startall called")...
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, 8; 5, 18; 5, 19; 5, 25; 5, 33; 5, 41; 5, 42; 5, 51; 5, 62; 5, 69; 5, 75; 5, 507; 5, 508; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment...
def handle(self): """ This is where the action starts. """ self.logger = self.server.logger # create a packet structure packet = iis() packet.datain = self.rfile packet.dataout = self.wfile # decode the header size = struct.calcsize('8h')...
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): """Load a file and display it. Parameters ---------- filepath : str The path of the file to load (must reference a local fil...
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): """Open a set of URIs. Parameters ---------- uris : list of str The URIs of the files to load chname: str, optional (defaults to channel with focus) The name of the channel in which to load the item...
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): """Create a new Ginga channel. Parameters ---------- chname : str The n...
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, 10; 7, 11; 7, 54; 7, 60; 7, 75; 7, 94; 7, 109; 7, 199; 8, expression_statement; 8, 9; 9, comment; 10, comment; 1...
def mode_key_down(self, viewer, keyname): """This method is called when a key is pressed and was not handled by some other handler with precedence, such as a subcanvas. """ # Is this a mode key? if keyname not in self.mode_map: if (keyname not in self.mode_tbl) or (se...
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, 10; 7, 18; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 1...
def set_sort_cb(self, w, index): """This callback is invoked when the user selects a new sort order from the preferences pane.""" 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, 8; 5, 18; 5, 25; 5, 35; 5, 50; 5, 51; 5, 52; 5, 53; 5, 63; 5, 205; 5, 220; 5, 230; 5, 231; 5, 241; 5, 253; 5, 259; 5, 263; 5, 317; 5, 318; 5, 319; 5, 320; 6, expression_statement...
def redo(self): """Called when an image is set in the channel.""" 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 m...
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, 12; 9, 13; 9, 38; 9, 49; 9, 66; 9, 78; 9, 79; 9, 80...
def _download_rtd_zip(rtd_version=None, **kwargs): """ Download and extract HTML ZIP from RTD to installed doc data path. Download is skipped if content already exists. Parameters ---------- rtd_version : str or `None` RTD version to download; e.g., "latest", "stable", or "v2.6.0". ...
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): """ Return URL to documentation. Attempt download if does not exist. Parameters ---------- logger : obj or `None` Ginga logger. plugin : obj or `None` Plugin object. If given, URL points to plugin doc directly. If ...
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, 10; 7, 17; 7, 29; 7, 37; 7, 45; 7, 56; 7, 69; 7, 75; 7, 76; 7, 103; 7, 104; 7, 331; 7, 340; 7, 341; 7, 348; 8, expression_s...
def redo(self, *args): """Generate listing of images that user can save.""" 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_...
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, 10; 7, 18; 7, 29; 7, 37; 7, 48; 7, 61; 7, 65; 7, 183; 7, 338; 7, 376; 7, 389; 7, 397; 7, 412; 8, expression_statement; ...
def _imload(self, filepath, kwds): """Load an image file, guessing the format, and return a numpy array containing an RGB image. If EXIF keywords can be read they are returned in the dict _kwds_. """ start_time = time.time() typ, enc = mimetypes.guess_type(filepath) ...
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, 8; 5, 81; 5, 91; 5, 96; 5, 106; 5, 111; 5, 121; 5, 205; 5, 215; 5, 220; 5, 230; 5, 235; 5, 245; 5, 250; 5, 260; 5, 265; 5, 266; 6, expression_statement; 6, 7; ...
def get_coord_system_name(header): """Return an appropriate key code for the axes coordinate system by examining the FITS header. """ try: ctype = header['CTYPE1'].strip().upper() except KeyError: try: # see if we have an "RA" header ra = header['RA'] # noqa ...
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, 9; 6, 10; 6, 11; 6, 47; 6, 62; 6, 68; 6, 80; 6, 90; 6, 101; 6, 123; 6, 140; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, comment; 11, fun...
def _do_info(bz, opt): """ Handle the 'info' subcommand """ # All these commands call getproducts internally, so do it up front # with minimal include_fields for speed def _filter_components(compdetails): ret = {} for k, v in compdetails.items(): if v.get("is_active",...
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): """ Attempt to log in using the given username and password. Subsequent method calls will use this username and password. Returns False if login fails, otherwise returns some kind of login info - typically either a n...
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, 11; 8, 58; 8, 62; 8, 115; 8, 132; 9, expression_state...
def _process_include_fields(self, include_fields, exclude_fields, extra_fields): """ Internal helper to process include_fields lists """ def _convert_fields(_in): if not _in: return _in for newname, oldname in self....
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): """ Return a list of dicts of full bug info for each given bug id. bug ids that couldn't be found will return None instead of a dict. """ oldidlist = idlist id...
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, 13; 10, 46;...
def attachfile(self, idlist, attachfile, description, **kwargs): """ Attach a file to the given bug IDs. Returns the ID of the attachment or raises XMLRPC Fault if something goes wrong. attachfile may be a filename (which will be opened) or a file-like object, which must provide...
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, 9; 6, 17; 6, 59; 6, 87; 6, 97; 6, 125; 6, 126; 6, 127; 6, 143; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10...
def pre_translation(self, query): """ Translates the query for possible aliases """ old = query.copy() if 'bug_id' in query: if not isinstance(query['bug_id'], list): query['id'] = query['bug_id'].split(',') else: query['id...
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, 8; 5, 15; 5, 31; 5, 47; 5, 65; 5, 66; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12;...
def check_differences(self): """ In-depth check of mail differences. Compare all mails of the duplicate set with each other, both in size and content. Raise an error if we're not within the limits imposed by the threshold setting. """ logger.info("Check that mail differe...
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, 237; 10, 261; 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, 12; 9, 19; 9, 257; 10, expression_statement; 10, 11; 11,...
async def connect(self, *args, **kwargs): """Connect to a juju model. This supports two calling conventions: The model and (optionally) authentication information can be taken from the data files created by the Juju CLI. This convention will be used if a ``model_name`` is spec...
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, 8; 5, 295; 5, 302; 5, 310; 5, 318; 5, 326; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 11; 9, function_name:_all_watcher; 10, parameters;...
def _watch(self): """Start an asynchronous watch against this model. See :meth:`add_observer` to register an onchange callback. """ async def _all_watcher(): try: allwatcher = client.AllWatcherFacade.from_connection( self.connection()) ...
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): """Start a new, empty machine and optionally a container, or add a container to a machine. :param str spec: Machine specification Examples:: (None) - starts a new machine...
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, 12; 9, 27; 9, 40; 9, 41; 9, 42; 9, 43; 9, 44; 9, 85; 9, 98; 9,...
async def get_action_output(self, action_uuid, wait=None): """Get the results of an action by ID. :param str action_uuid: Id of the action :param int wait: Time in seconds to wait for action to complete. :return dict: Output from action :raises: :class:`JujuError` if invalid act...
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, 12; 9, 19; 10, expression_statement; 10, 11; 11, comment...
async def connect(self, *args, **kwargs): """Connect to a Juju controller. This supports two calling conventions: The controller and (optionally) authentication information can be taken from the data files created by the Juju CLI. This convention will be used if a ``controller...
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): """Add or update a credential to the controller. :param str name: Name of new credential. If None, the default local credential is used. Name must be provided if a ...
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, 10; 7, 71; 8, expression_statement; 8, 9; 9, comment; 10, for_statement; 10, 11; 10, 12; 10, 13; 11, identifier:spec; 1...
def matches(self, *specs): """ Check if this relation matches relationship specs. Relation specs are strings that would be given to Juju to establish a relation, and should be in the form ``<application>[:<endpoint_name>]`` where the ``:<endpoint_name>`` suffix is optional. If ...
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=''): """Create a Wag...
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, 333; 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: # Live trading until the end of the day bt_dates = ...
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, 10; 7, 17; 7, 24; 7, 31; 7, 43; 7, 60; 7, 79; 7, 93; 7, 105; 7, 111; 7, 112; 7, 116; 7, 117; 8, expression_statement; 8, 9;...
def gcal2jd(year, month, day): """Gregorian calendar date to Julian date. The input and output are for the proleptic Gregorian calendar, i.e., no consideration of historical usage of the calendar is made. Parameters ---------- year : int Year as an integer. month : int ...
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""" Check restarting parameters This method checks that the restarting parameters are set and satisfy the correct assumptions. It also checks that the current mode is regula...
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, 13; 10, 252; 11, expression_stateme...
def method_cache(by='value',method='run'): """A decorator used on any model method which calls the model's 'method' method if that latter method has not been called using the current arguments or simply sets model attributes to match the run results if it has.""" def decorate_(func): def de...
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, 12; 9, 13; 9, 24; 9, 25; 9, 35; 9, 45; 9, 46; 9, 56; 9, 57; 9...
def _format_command(ctx, show_nested, commands=None): """Format the output of `click.Command`.""" # the hidden attribute is part of click 7.x only hence use of getattr if getattr(ctx.command, 'hidden', False): return # description for line in _format_description(ctx): yield line ...
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): """ Default formatter function, if no `formatter` kwarg is specified. Takes information about the pick event as a series of kwargs and returns the string to be displayed. """ def is_date(axis): ...
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): """ Create an interactive data cursor for the specified artists or specified axes. The data cursor displays information about a selected artist in a "popup" annotation box. If a specific sequence of artists is given, only the specified artists will...
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): """Listen for characteristics changes from a BLE address. @param: mac - MAC address in format XX:XX:XX:XX:XX:XX @param: handle - BLE characteristics handle in format 0xXX a value of 0x0...
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, 14; 11, 15; ...
def simplify_tree(tree, unpack_lists=True, in_list=False): """Recursively unpack single-item lists and objects where fields and labels only reference a single child :param tree: the tree to simplify (mutating!) :param unpack_lists: whether single-item lists should be replaced by that item :param in_lis...
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, 10; 7, 21; 7, 32; 7, 80; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assignment; 11, 12...
def run(self, *args): """Get and set configuration parameters. This command gets or sets parameter values from the user configuration file. On Linux systems, configuration will be stored in the file '~/.sortinghat'. """ params = self.parser.parse_args(args) conf...
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, 11; 8, 15; 8, 29; 8, 99; 8, 116; 8, 144; 9, expression_statement; 9, 10; 10, comment; 11, expression_stat...
def export(self, source=None): """Export a set of unique identities. Method to export unique identities from the registry. Identities schema will follow Sorting Hat JSON format. When source parameter is given, only those unique identities which have one or more identities from ...
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, 8; 5, 12; 5, 23; 5, 69; 5, 94; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:organizations; 11, dictiona...
def export(self): """Export a set of organizations. Method to export organizations from the registry. Organizations schema will follow Sorting Hat JSON format. :returns: a JSON formatted str """ organizations = {} orgs = api.registry(self.db) for org i...
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, 10; 7, 23; 7, 36; 7, 55; 7, 64; 7, 73; 7, 92; 8, expression_statement; 8, 9; 9, comment; 10, if_statement; 10, 11; 10, 17; 11, not_...
def match(self, a, b): """Determine if two unique identities are the same. This method compares the email addresses or the names of each identity to check if the given unique identities are the same. When the given unique identities are the same object or share the same UUID, th...
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; 7, 10; 7, 11; 8, expression_statement; 8, 9; 9, comment; 10, comment; 11, with_statement; 11, 12; 11, 22; 12, ...
def merge_enrollments(db, uuid, organization): """Merge overlapping enrollments. This function merges those enrollments, related to the given 'uuid' and 'organization', that have overlapping dates. Default start and end dates (1900-01-01 and 2100-01-01) are considered range limits and will be remov...
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, 11; 8, 15; 8, 109; 9, expression_statement; 9, 10; 10, comment; 11, expression_statement; 11, 12; 12, assig...
def registry(db, term=None): """List the organizations available in the registry. The function will return the list of organizations. If term parameter is set, it will only return the information about the organizations which match that term. When the given term does not match with any organization...
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, 14; 11, 18; 11, 199; 12, expre...
def domains(db, domain=None, top=False): """List the domains available in the registry. The function will return the list of domains. Settting the top flag, it will look for those domains that are top domains. If domain parameter is set, it will only return the information about that domain. When ...
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, 14; 11, 41; 11, 62; 11, 66; 11...
def countries(db, code=None, term=None): """List the countries available in the registry. The function will return the list of countries. When either 'code' or 'term' parameters are set, it will only return the information about those countries that match them. Take into account that 'code' is a c...
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): """List the enrollment information available in the registry. This function will return a list of enrollments. If 'uuid' parameter is set, it will return the enrollments related to that unique identity; if 'organization' p...
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, 11; 8, 15; 8, 109; 9, expression_statement; 9, 10; 10, comment; 11, expression_statement; 11, 12; 12, assi...
def blacklist(db, term=None): """List the blacklisted entities available in the registry. The function will return the list of blacklisted entities. If term parameter is set, it will only return the information about the entities which match that term. When the given term does not match with any en...
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, 9; 6, 102; 6, 111; 6, 115; 7, expression_statement; 7, 8; 8, comment; 9, function_definition; 9, 10; 9, 11; 9, 15; 10, function_name:__c...
def __parse_identities(self, stream): """Parse identities using GrimoireLab format. The GrimoireLab identities format is a YAML document following a schema similar to the example below. More information available at https://github.com/bitergia/identities - profile: ...
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, 9; 6, 14; 6, 23; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 12; 10, not_operator; 10, 11; 11, identifier:s...
def __parse_organizations(self, stream): """Parse GrimoireLab organizations. The GrimoireLab organizations format is a YAML element stored under the "organizations" key. The next example shows the structure of the document: - organizations: Bitergia: ...
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, 9; 6, 20; 6, 29; 6, 36; 6, 43; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 12; 10, not_operator; 10, 11; 11, identifier:s...
def __parse(self, stream): """Parse Sorting Hat 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(j...
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; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, try_statement; 9, 10; 9, 74; 10, block; 10, 11; 11, for_statement; 11, 12; 11, 13; 11, 16;...
def __parse_blacklist(self, json): """Parse blacklist entries using Sorting Hat format. The Sorting Hat blacklist format is a JSON stream that stores a list of blacklisted entries. Next, there is an example of a valid stream: { "blacklist": [ "John ...
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; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, try_statement; 9, 10; 9, 117; 10, block; 10, 11; 11, for_statement; 11, 12; 11, 13; 11...
def __parse_organizations(self, json): """Parse organizations using Sorting Hat format. The Sorting Hat organizations format is a JSON stream which its keys are the name of the organizations. Each organization object has a list of domains. For instance: { "organizat...
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, 9; 6, 15; 6, 22; 6, 26; 6, 96; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; ...
def import_blacklist(self, parser): """Import blacklist. New entries parsed by 'parser' will be added to the blacklist. :param parser: sorting hat parser """ blacklist = parser.blacklist self.log("Loading blacklist...") n = 0 for entry in blacklist: ...
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, 12; 9, 18; 10, expression_statement; 10, 11; 11, comment; ...
def import_organizations(self, parser, overwrite=False): """Import organizations. New domains and organizations parsed by 'parser' will be added to the registry. Remember that a domain can only be assigned to one organization. If one of the given domains is already on the registry, ...
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): """Import identities information on the registry. New unique identities, organizations and enrollment data parsed by 'pa...
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, 11; 8, 14; 8, 18; 8, 22; 8, 26; 8, 30; 8, 34; 8, 117; 8, 118; 8...
def __create_profile_from_identities(self, identities, uuid, verbose): """Create a profile using the data from the identities""" import re EMAIL_ADDRESS_REGEX = r"^(?P<email>[^\s@]+@[^\s@.]+\.[^\s@]+)$" NAME_REGEX = r"^\w+\s\w+" name = None email = None usernam...
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, 10; 7, 11; 7, 18; 7, 25; 7, 26; 7, 185; 7, 186; 8, expression_statement; 8, 9; 9, comment; 10, c...
def __parse_identities(self, aliases, email_to_employer): """Parse Gitdm identities""" # Parse streams self.__parse_aliases_stream(aliases) self.__parse_email_to_employer_stream(email_to_employer) # Create unique identities from aliases list for alias, email in self.__r...
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, 12; 9, 20; 9, 28; 9, 36; 9, 44; 9, 60; 9, 162; 10, expression_statement; 1...
def initialize(self, name, reuse=False): """Create an empty Sorting Hat registry. This method creates a new database including the schema of Sorting Hat. Any attempt to create a new registry over an existing instance will produce an error, except if reuse=True. In that case, the ...
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, 8; 5, 13; 5, 27; 5, 36; 5, 155; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 11; 9, not_operator; 9, 10; 10, identifier:dates; 11, block; 11...
def merge_date_ranges(dates): """Merge date ranges. Generator that merges ovelaped data ranges. Default init and end dates (1900-01-01 and 2100-01-01) are considered range limits and will be removed when a set of ranges overlap. For example: * [(1900-01-01, 2010-01-01), (2008-01-01, 2100-01-01)]...
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): """Get the UUID related to the identity data. Based on the input data, the function will return the UUID associated to an identity. On this version, the UUID will be the SHA1 of "source:email:name:username" string. This string is case insensitive,...
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): """ Send JSON RPC request to a backend socket and receive reply Note that this uses the default event loop to run in a blocking manner. If you would rather run in an async fashion or provide your own event loop...
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, 11; 8, 314; 8, 323; 9, expression_statement; 9, 10; 10, comment; 11, if_statemen...
def init_process_dut(contextlist, conf, index, args): """ Initialize process type Dut as DutProcess or DutConsole. """ if "subtype" in conf and conf["subtype"]: if conf["subtype"] != "console": msg = "Unrecognized process subtype: {}" contextlist.logger.error(msg.format(c...
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, 12; 9, 20; 9, 21; 9, 22; 9, 35; 9, 85; 9, 86; 9, 123; 9, 129...
def allocate(self, dut_configuration_list, args=None): """ Allocates resources from available local devices. :param dut_configuration_list: List of ResourceRequirements objects :param args: Not used :return: AllocationContextList with allocated resources """ dut_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 7; 2, function_name:_allocate; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:dut_configuration; 6, comment; 7, block; 7, 8; 7, 10; 7, 25; 7, 276; 7, 277; 8, expression_statement; 8, 9; 9, comment; 10, if_statement; 10, 11; 10, 16; 11, comparis...
def _allocate(self, dut_configuration): # pylint: disable=too-many-branches """ Internal allocation function. Allocates a single resource based on dut_configuration. :param dut_configuration: ResourceRequirements object which describes a required resource :return: True :raises:...
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, 8; 5, 21; 5, 22; 5, 26; 5, 30; 5, 34; 5, 38; 5, 102; 5, 318; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 14; 10, p...
def __generate(results): """ Static method which generates the Junit xml string from results :param results: Results as ResultList object. :return: Junit xml format string. """ doc, tag, text = Doc().tagtext() # Counters for testsuite tag info count = 0 ...
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): """ Initialize the Icetea logging by creating a directory to store logs for this run and initialize the console logger for Icetea itself. :param dire...
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): """ Assert that jsonStr contains key. :param jsonStr: Json as string :param key: Key to look for :param message: Failure message :raises: TestStepFail if key is not in jsonStr or if loading jsonStr to a dictionary fails or if jso...
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, 8; 5, 60; 5, 179; 6, expression_statement; 6, 7; 7, comment; 8, try_statement; 8, 9; 8, 22; 9, block; 9, 10; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 1...
def _read_fd(file_descr): """ Read incoming data from file handle. Then find the matching StreamDescriptor by file_descr value. :param file_descr: file object :return: Return number of bytes read """ try: line = os.read(file_descr, 1024 * 1024) ...
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, 11; 8, 12; 8, 13; 8, 19; 8, 30; 8, 40; 8, 64; 8, 65; 8, 71; 8, 104; 8, 121; 8, 122; 8, 135; 8, 136; 8, 186; 8,...
def run(self, args=None): """ Runs the set of tests within the given path. """ # Disable "Too many branches" and "Too many return statemets" warnings # pylint: disable=R0912,R0911 retcodesummary = ExitCodes.EXIT_SUCCESS self.args = args if args else self.args ...
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, 8; 5, 20; 5, 24; 5, 37; 6, expression_statement; 6, 7; 7, comment; 8, try_statement; 8, 9; 8, 16; 9, block; 9, 10; 9, 13; 10, import_statement; 10...
def generate_object_graphs_by_class(classlist): """ Generate reference and backreference graphs for objects of type class for each class given in classlist. Useful for debugging reference leaks in framework etc. Usage example to generate graphs for class "someclass": >>> import someclass >>...
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, 8; 5, 115; 5, 169; 5, 170; 5, 194; 5, 200; 6, expression_statement; 6, 7; 7, comment; 8, while_statement; 8, 9; 8, 24; 9, boolean_operator:and; 9, 10; 9, 19; 10, ...
def _wait_for_exec_ready(self): """ Wait for response. :return: CliResponse object coming in :raises: TestStepTimeout, TestStepError """ while not self.response_received.wait(1) and self.query_timeout != 0: if self.query_timeout != 0 and self.query_timeout < ...
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, 11; 8, 93; 8, 94; 8, 155; 8, 156; 8, 164; 8, 183; 8, 189; 8, 200; 8, 225; 8, 24...
def execute_command(self, req, **kwargs): """ Execute command and return CliResponse :param req: String, command to be executed in DUT, or CliRequest, command class which contains all configurations like timeout. :param kwargs: Configurations (wait, timeout) which will be used w...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 1, 5; 2, function_name:run; 3, parameters; 4, comment; 5, block; 5, 6; 5, 8; 5, 23; 5, 345; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identi...
def run(): # pylint: disable=too-many-branches """ Main thread runner for all Duts. :return: Nothing """ Dut._logger.debug("Start DUT communication", extra={'type': '<->'}) while Dut._run: Dut._sem.acquire() try: dut = Dut._signal...