sequence
stringlengths
546
16.2k
code
stringlengths
108
19.3k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:contigs_to_positions; 3, parameters; 3, 4; 3, 5; 4, identifier:contigs; 5, default_parameter; 5, 6; 5, 7; 6, identifier:binning; 7, integer:10000; 8, block; 8, 9; 8, 11; 8, 20; 8, 24; 8, 67; 9, expression_statement; 9, 10; 10, comment; 11, expr...
def contigs_to_positions(contigs, binning=10000): """Build positions from contig labels From a list of contig labels and a binning parameter, build a list of positions that's essentially a concatenation of linspaces with step equal to the binning. Parameters ---------- contigs : list o...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find_nearest; 3, parameters; 3, 4; 3, 5; 4, identifier:sorted_list; 5, identifier:x; 6, block; 6, 7; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 15; 9, 20; 9, 33; 10, comparison_operator:<=; 10, 11; 10, 12; 11, i...
def find_nearest(sorted_list, x): """ Find the nearest item of x from sorted array. :type array: list :param array: an iterable object that support inex :param x: a comparable value note: for finding the nearest item from a descending array, I recommend find_nearest(sorted_list[::-1], x)....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:execute; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:input_params; 5, identifier:engine; 6, default_parameter; 6, 7; 6, 8; 7, identifier:cwd; 8, None; 9, block; 9, 10; 9, 12; 9, 33; 9, 51; 9, 52; 9, 56; 9, 71; 9, 72; 9, 76; 9, 84; 9, 104; 9,...
def execute(input_params, engine, cwd=None): """ Execute a task with the provided input parameters :param input_params: Python dictionary containg all input parameters. This will be converted to JSON before being passed to the task engine. :param engine...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:merge_fasta; 3, parameters; 3, 4; 3, 5; 4, identifier:fasta_file; 5, identifier:output_dir; 6, block; 6, 7; 6, 9; 6, 10; 6, 11; 6, 50; 6, 101; 6, 129; 6, 130; 6, 150; 6, 160; 6, 161; 6, 167; 6, 280; 6, 281; 6, 307; 6, 316; 6, 328; 7, expression...
def merge_fasta(fasta_file, output_dir): """Merge chunks into complete FASTA bins Merge bin chunks by appending consecutive chunks to one another. Parameters ---------- fasta_file : file, str or pathlib.Path The FASTA file containing the chunks to merge. output_dir : str or pathlib.Pa...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:print_block; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 11; 4, identifier:self; 5, identifier:section_key; 6, default_parameter; 6, 7; 6, 8; 7, identifier:f; 8, attribute; 8, 9; 8, 10; 9, identifier:sys; 10, identifier:stdout; 11, default_parameter; ...
def print_block(self, section_key, f=sys.stdout, file_format="mwtab"): """Print `mwtab` section into a file or stdout. :param str section_key: Section name. :param io.StringIO f: writable file-like stream. :param str file_format: Format to use: `mwtab` or `json`. :return: None ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:retry; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:ExceptionToCheck; 5, default_parameter; 5, 6; 5, 7; 6, identifier:tries; 7, integer:4; 8, default_parameter; 8, 9; 8, 10; 9, identifier:delay; 10, integer:3; 11, defaul...
def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, status_codes=[], logger=None): """ Decorator function for retrying the decorated function, using an exponential or fixed backoff. Original: https://wiki.python.org/moin/PythonDecoratorLibrary#Retry ExceptionToCheck: the exception t...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:lcopt_bw2_autosetup; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 4, default_parameter; 4, 5; 4, 6; 5, identifier:ei_username; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:ei_password; 9, None; 10, default_parameter; 10, ...
def lcopt_bw2_autosetup(ei_username=None, ei_password=None, write_config=None, ecoinvent_version='3.3', ecoinvent_system_model = "cutoff", overwrite=False): """ Utility function to automatically set up brightway2 to work correctly with lcopt. It requires a valid username and password to login to the eco...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:lcopt_bw2_forwast_setup; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:use_autodownload; 6, True; 7, default_parameter; 7, 8; 7, 9; 8, identifier:forwast_path; 9, None; 10, default_parameter; 10, 11; ...
def lcopt_bw2_forwast_setup(use_autodownload=True, forwast_path=None, db_name=FORWAST_PROJECT_NAME, overwrite=False): """ Utility function to set up brightway2 to work correctly with lcopt using the FORWAST database instead of ecoinvent By default it'll try and download the forwast database as a ....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_validate_samples_factors; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:mwtabfile; 5, default_parameter; 5, 6; 5, 7; 6, identifier:validate_samples; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:validate_factors; 10, True; 11, bl...
def _validate_samples_factors(mwtabfile, validate_samples=True, validate_factors=True): """Validate ``Samples`` and ``Factors`` identifiers across the file. :param mwtabfile: Instance of :class:`~mwtab.mwtab.MWTabFile`. :type mwtabfile: :class:`~mwtab.mwtab.MWTabFile` :return: None :rtype: :py:obj:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:convert; 3, parameters; 3, 4; 4, identifier:schema; 5, block; 5, 6; 5, 8; 5, 9; 5, 24; 5, 155; 5, 186; 5, 235; 5, 280; 5, 299; 5, 350; 5, 381; 5, 396; 5, 408; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, if_statement; 9, 10; 9, 17;...
def convert(schema): """Convert a voluptuous schema to a dictionary.""" # pylint: disable=too-many-return-statements,too-many-branches if isinstance(schema, vol.Schema): schema = schema.schema if isinstance(schema, Mapping): val = [] for key, value in schema.items(): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_jsmin; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 14; 5, 21; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, ...
def _jsmin(self): """Copy the input to the output, deleting the characters which are insignificant to JavaScript. Comments will be removed. Tabs will be replaced with spaces. Carriage returns will be replaced with linefeeds. Most spaces and linefeeds will be removed. """...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:tokenizer; 3, parameters; 3, 4; 4, identifier:text; 5, block; 5, 6; 5, 8; 5, 20; 5, 441; 5, 448; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:stream; 11, call; 11, 12; 11,...
def tokenizer(text): """A lexical analyzer for the `mwtab` formatted files. :param str text: `mwtab` formatted text. :return: Tuples of data. :rtype: py:class:`~collections.namedtuple` """ stream = deque(text.split("\n")) while len(stream) > 0: line = stream.popleft() if ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_proxy; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:url; 6, default_parameter; 6, 7; 6, 8; 7, identifier:urlparams; 8, None; 9, block; 9, 10; 9, 12; 9, 30; 9, 37; 9, 41; 9, 61; 9, 62; 9, 73; 9, 117; 9, 126; 9, 127; 9, 135...
def _proxy(self, url, urlparams=None): """Do the actual action of proxying the call. """ for k,v in request.params.iteritems(): urlparams[k]=v query = urlencode(urlparams) full_url = url if query: if not full_url.endswith("?"): full...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:attempt_open_query_permutations; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:url; 5, identifier:orig_file_path; 6, identifier:is_header_file; 7, block; 7, 8; 7, 10; 7, 22; 7, 23; 7, 51; 7, 52; 7, 113; 7, 122; 7, 138; 7, 144; 7, 150; 7, 159; ...
def attempt_open_query_permutations(url, orig_file_path, is_header_file): """ Attempt to open a given mock data file with different permutations of the query parameters """ directory = dirname(convert_to_platform_safe(orig_file_path)) + "/" # get all filenames in directory try: file...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:search_databases; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:search_term; 6, default_parameter; 6, 7; 6, 8; 7, identifier:location; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:markets...
def search_databases(self, search_term, location=None, markets_only=False, databases_to_search=None, allow_internal=False): """ Search external databases linked to your lcopt model. To restrict the search to particular databases (e.g. technosphere or biosphere only) use a list of database name...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:create_parameter_map; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 26; 5, 30; 5, 52; 5, 178; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:names...
def create_parameter_map(self): """ Creates a parameter map which takes a tuple of the exchange 'from' and exchange 'to' codes and returns the parameter name for that exchange """ names = self.modelInstance.names db = self.modelInstance.database['items'] paramete...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:apply; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:config_override; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:tag_override; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identif...
def apply(config_override=None, tag_override=None, rollback=None, skip_missing=None): """ Look thru migrations and apply them """ # Load config config = get_config(config_override) databases = config['databases'] # If we are rolling back, ensure that we have a database tag if rollback and not ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:_configure_common; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:self; 5, identifier:prefix; 6, identifier:fallback_level; 7, identifier:fallback_format; 8, identifier:handler_name; 9, identifier:handler; 10, default_...
def _configure_common( self, prefix, fallback_level, fallback_format, handler_name, handler, custom_args='' ): """commom configuration code Args: prefix (str): A prefix for the `log_level` and `log_forma...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:get_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:self; 5, identifier:name; 6, identifier:save_to; 7, default_parameter; 7, 8; 7, 9; 8, identifier:add_to_cache; 9, True; 10, default_parameter; 10, 11; 10, 12; 11, ide...
def get_file(self, name, save_to, add_to_cache=True, force_refresh=False, _lock_exclusive=False): """Retrieves file identified by ``name``. The file is saved as ``save_to``. If ``add_to_cache`` is ``True``, the file is added to the local store. If ``force_refresh`` is ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:get_stream; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:force_refresh; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:serve_from_cache; 11, False;...
def get_stream(self, name, force_refresh=False, serve_from_cache=False): """Retrieves file identified by ``name`` in streaming mode. Works like :meth:`get_file`, except that returns a tuple (file-like object, versioned name). When both remote_store and local_store are present,...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:put_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:self; 5, identifier:name; 6, identifier:filename; 7, default_parameter; 7, 8; 7, 9; 8, identifier:to_local_store; 9, True; 10, default_parameter; 10, 11; 10, 12; 11, ...
def put_file(self, name, filename, to_local_store=True, to_remote_store=True, compress_hint=True): """Adds file ``filename`` to the filetracker under the name ``name``. If the file already exists, a new version is c...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:check; 3, parameters; 3, 4; 3, 5; 4, identifier:operations; 5, default_parameter; 5, 6; 5, 7; 6, identifier:loud; 7, False; 8, block; 8, 9; 8, 11; 8, 19; 8, 23; 8, 27; 8, 56; 8, 167; 9, expression_statement; 9, 10; 10, comment; 11, if_statement...
def check(operations, loud=False): """Check all the things :param operations: The operations to check :param loud: `True` if checkers should prettyprint their status to stderr. `False` otherwise. :returns: A tuple of overall success, and a detailed execution log for all the operations """ if n...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:deci2sexa; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:deci; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pre; 7, integer:3; 8, default_parameter; 8, 9; 8, 10; 9, identifier:trunc; 10, False; 11, default_param...
def deci2sexa(deci, pre=3, trunc=False, lower=None, upper=None, b=False, upper_trim=False): """Returns the sexagesimal representation of a decimal number. Parameters ---------- deci : float Decimal number to be converted into sexagesimal. If `lower` and `upper` are given t...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:phmsdms; 3, parameters; 3, 4; 4, identifier:hmsdms; 5, block; 5, 6; 5, 8; 5, 12; 5, 16; 5, 17; 5, 18; 5, 19; 5, 20; 5, 21; 5, 22; 5, 23; 5, 32; 5, 33; 5, 42; 5, 50; 5, 59; 5, 66; 5, 147; 5, 448; 5, 449; 5, 477; 5, 487; 5, 503; 6, expression_sta...
def phmsdms(hmsdms): """Parse a string containing a sexagesimal number. This can handle several types of delimiters and will process reasonably valid strings. See examples. Parameters ---------- hmsdms : str String containing a sexagesimal number. Returns ------- d : dict ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:pposition; 3, parameters; 3, 4; 3, 5; 4, identifier:hd; 5, default_parameter; 5, 6; 5, 7; 6, identifier:details; 7, False; 8, block; 8, 9; 8, 11; 8, 12; 8, 13; 8, 23; 8, 38; 8, 39; 8, 166; 8, 198; 9, expression_statement; 9, 10; 10, comment; 11...
def pposition(hd, details=False): """Parse string into angular position. A string containing 2 or 6 numbers is parsed, and the numbers are converted into decimal numbers. In the former case the numbers are assumed to be floats. In the latter case, the numbers are assumed to be sexagesimal. Par...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 68; 2, function_name:Create; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 3, 44; 3, 47; 3, 50; 3, 53; 3, 56; 3, 59; 3, 62; 3, 65; 4, identifier:name; 5, identifier:template; 6, identifier...
def Create(name,template,group_id,network_id,cpu=None,memory=None,alias=None,password=None,ip_address=None, storage_type="standard",type="standard",primary_dns=None,secondary_dns=None, additional_disks=[],custom_fields=[],ttl=None,managed_os=False,description=None, source_server_password=None,cp...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 66; 2, function_name:Clone; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 3, 33; 3, 36; 3, 39; 3, 42; 3, 45; 3, 48; 3, 51; 3, 54; 3, 57; 3, 60; 3, 63; 4, identifier:self; 5, identifier:network_id; 6, default_parameter; 6, ...
def Clone(self,network_id,name=None,cpu=None,memory=None,group_id=None,alias=None,password=None,ip_address=None, storage_type=None,type=None,primary_dns=None,secondary_dns=None, custom_fields=None,ttl=None,managed_os=False,description=None, source_server_password=None,cpu_autoscale_policy_id=None,a...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:Call; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:method; 5, identifier:url; 6, default_parameter; 6, 7; 6, 8; 7, identifier:payload; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:session; 11, None; 12, default_pa...
def Call(method,url,payload=None,session=None,debug=False): """Execute v2 API call. :param url: URL paths associated with the API call :param payload: dict containing all parameters to submit with POST call :returns: decoded API json result """ if session is not None: token = session['token'] http_s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:processFiles; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 8; 5, 12; 5, 348; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:to_process; 11, list:[]; 12, for_s...
def processFiles(args): """ Generates and error checks each file's information before the compilation actually starts """ to_process = [] for filename in args['filenames']: file = dict() if args['include']: file['include'] = INCLUDE_STRING + ''.join( ['-...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:main; 3, parameters; 4, block; 4, 5; 4, 7; 4, 21; 4, 34; 4, 48; 4, 70; 4, 97; 4, 125; 4, 147; 4, 170; 4, 178; 4, 219; 4, 235; 4, 259; 4, 272; 4, 273; 4, 274; 4, 275; 4, 276; 4, 277; 4, 278; 4, 279; 4, 280; 4, 281; 4, 282; 4, 283; 4, 284; 4, 285...
def main(): """Main function that is called when DistanceClassifier is run on the command line""" parser = argparse.ArgumentParser(description='DistanceClassifier for classification based on distance measure in feature space.', add_help=False) parser.add_argument('INPUT...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:delete; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:name; 6, identifier:version; 7, default_parameter; 7, 8; 7, 9; 8, identifier:_lock; 9, True; 10, block; 10, 11; 10, 13; 10, 22; 10, 46; 10, 314; 10, 322; 11, expr...
def delete(self, name, version, _lock=True): """Removes a file from the storage. Args: name: name of the file being deleted. May contain slashes that are treated as path separators. version: file "version" that is meant to be deleted If the fi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:wait_socks; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:sock_events; 5, default_parameter; 5, 6; 5, 7; 6, identifier:inmask; 7, integer:1; 8, default_parameter; 8, 9; 8, 10; 9, identifier:outmask; 10, integer:2; 11, default_parameter...
def wait_socks(sock_events, inmask=1, outmask=2, timeout=None): """wait on a combination of zeromq sockets, normal sockets, and fds .. note:: this method can block it will return once there is relevant activity on any of the descriptors or sockets, or the timeout expires :param sock_event...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:sync_ldap_user_membership; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:user; 6, identifier:ldap_groups; 7, block; 7, 8; 7, 10; 7, 14; 7, 28; 7, 35; 7, 39; 7, 43; 7, 47; 7, 53; 7, 57; 7, 250; 7, 251; 7, 252; 7, 288; 7, 320...
def sync_ldap_user_membership(self, user, ldap_groups): """Synchronize LDAP membership to Django membership""" groupname_field = 'name' actualGroups = user.groups.values_list('name', flat=True) user_Membership_total = len(ldap_groups) user_Membership_added = 0 user_Member...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:block; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:timeout; 10, None; 11, block; 11, 12; 11, 14; 11, 115; 11, 141; 12, expr...
def get(self, block=True, timeout=None): """get an item out of the queue .. note:: if `block` is ``True`` (the default) and the queue is :meth`empty`, this method will block the current coroutine until something has been :meth:`put`. :param block: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:put; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:item; 6, default_parameter; 6, 7; 6, 8; 7, identifier:block; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:timeout; 11, None; 12, block; 12, 13; 12, 15...
def put(self, item, block=True, timeout=None): """put an item into the queue .. note:: if the queue was created with a `maxsize` and it is currently :meth:`full`, this method will block the calling coroutine until another coroutine :meth:`get`\ s an item. :...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_compress_tokens; 3, parameters; 3, 4; 4, identifier:tokens; 5, block; 5, 6; 5, 8; 5, 12; 5, 58; 5, 65; 5, 69; 5, 165; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:recorde...
def _compress_tokens(tokens): """Paste multi-line strings, comments, RST etc together. This function works by iterating over each over the _RECORDERS to determine if we should start recording a token sequence for pasting together. If it finds one, then we keep recording until that recorder is done and ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_parse_dependencies; 3, parameters; 3, 4; 4, identifier:string; 5, block; 5, 6; 5, 8; 5, 17; 5, 26; 5, 33; 5, 37; 5, 41; 5, 72; 5, 87; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, id...
def _parse_dependencies(string): """ This function actually parses the dependencies are sorts them into the buildable and given dependencies """ contents = _get_contents_between(string, '(', ')') unsorted_dependencies = contents.split(',') _check_parameters(unsorted_dependencies, ('?',)) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:wait_fds; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:fd_events; 5, default_parameter; 5, 6; 5, 7; 6, identifier:inmask; 7, integer:1; 8, default_parameter; 8, 9; 8, 10; 9, identifier:outmask; 10, integer:2; 11, default_parameter; 11...
def wait_fds(fd_events, inmask=1, outmask=2, timeout=None): """wait for the first of a number of file descriptors to have activity .. note:: this method can block it will return once there is relevant activity on the file descriptors, or the timeout expires :param fd_events: two-t...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:processAndSetDefaults; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 20; 5, 43; 5, 51; 5, 59; 5, 77; 5, 78; 5, 79; 5, 80; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, if_statement; 9, 10; 9, 14; 10, not_op...
def processAndSetDefaults(self): """ The heart of the 'Instruction' object. This method will make sure that all fields not entered will be defaulted to a correct value. Also checks for incongruities in the data entered, if it was by the user. """ # INPUT, OUTPUT, GIVEN + ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:schedule; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:target; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:args; 9, tuple; 10, default_parameter; 10, 11; 10, 12; 11, identifier:kwargs; 12, None...
def schedule(target=None, args=(), kwargs=None): """insert a greenlet into the scheduler If provided a function, it is wrapped in a new greenlet :param target: what to schedule :type target: function or greenlet :param args: arguments for the function (only used if ``target`` is a function...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:schedule_at; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:unixtime; 5, default_parameter; 5, 6; 5, 7; 6, identifier:target; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:args; 10, tuple; 11, default_parameter; 11, 12; 11, ...
def schedule_at(unixtime, target=None, args=(), kwargs=None): """insert a greenlet into the scheduler to be run at a set time If provided a function, it is wrapped in a new greenlet :param unixtime: the unix timestamp at which the new greenlet should be started :type unixtime: int or float ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:schedule_recurring; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:interval; 5, default_parameter; 5, 6; 5, 7; 6, identifier:target; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:maxtimes; 10, integer:0; 11, de...
def schedule_recurring(interval, target=None, maxtimes=0, starting_at=0, args=(), kwargs=None): """insert a greenlet into the scheduler to run regularly at an interval If provided a function, it is wrapped in a new greenlet :param interval: the number of seconds between invocations ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:assert_output; 3, parameters; 3, 4; 3, 5; 4, identifier:output; 5, identifier:assert_equal; 6, block; 6, 7; 6, 9; 6, 16; 6, 23; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, ident...
def assert_output(output, assert_equal): """ Check that two outputs have the same contents as one another, even if they aren't sorted yet """ sorted_output = sorted(output) sorted_assert = sorted(assert_equal) if sorted_output != sorted_assert: raise ValueError(ASSERT_ERROR.format(so...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:get_input; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:prompt; 5, identifier:check; 6, keyword_separator; 7, default_parameter; 7, 8; 7, 9; 8, identifier:redo_prompt; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifi...
def get_input(prompt, check, *, redo_prompt=None, repeat_prompt=False): """ Ask the user to input something on the terminal level, check their response and ask again if they didn't answer correctly """ if isinstance(check, str): check = (check,) to_join = [] for item in check: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:install_build_requires; 3, parameters; 3, 4; 4, identifier:pkg_targets; 5, block; 5, 6; 5, 8; 5, 47; 5, 107; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 15; 9, function_name:pip_install; 10, parameters; 10...
def install_build_requires(pkg_targets): """Iterate through build_requires list and pip install if package is not present accounting for version""" def pip_install(pkg_name, pkg_vers=None): pkg_name_version = '%s==%s' % (pkg_name, pkg_vers) if pkg_vers else pkg_name print '[WARNING] %s not ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:PackagePublishUI; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:package; 5, identifier:type; 6, identifier:visibility; 7, block; 7, 8; 7, 10; 7, 11; 7, 24; 7, 37; 7, 99; 7, 100; 7, 121; 7, 252; 7, 277; 7, 278; 7, 282; 7, 324; 7, 345; 8, expres...
def PackagePublishUI(package,type,visibility): """Publishes a Blueprint Package for use within the Blueprint Designer after interactive OS selection. Interactive selection of one or more operating systems by name. :param package: path to zip file containing package.manifest and supporting scripts :param class...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_construct_select_query; 3, parameters; 3, 4; 4, dictionary_splat_pattern; 4, 5; 5, identifier:filter_definition; 6, block; 6, 7; 6, 9; 6, 18; 6, 28; 6, 38; 6, 48; 6, 60; 6, 111; 6, 230; 6, 239; 6, 254; 6, 269; 7, expression_statement; 7, 8; 8,...
def _construct_select_query(**filter_definition): """Return SELECT statement that will be used as a filter. :param filter_definition: definition of a filter that should be used for SELECT construction :return: """ table_name = filter_definition.pop('table') distinct = filter_definition.pop('dis...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:encode; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:df; 5, default_parameter; 5, 6; 5, 7; 6, identifier:encoding; 7, string:'utf8'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:verbosity; 10, integer:1; 11, block; 11, 12; 11, 14; 11, 41...
def encode(df, encoding='utf8', verbosity=1): """If you try to encode each element individually with python, this would take days!""" if verbosity > 0: # pbar_i = 0 pbar = progressbar.ProgressBar(maxval=df.shape[1]) pbar.start() # encode strings as UTF-8 so they'll work in python2 an...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:data_worker; 3, parameters; 3, 4; 4, dictionary_splat_pattern; 4, 5; 5, identifier:kwargs; 6, block; 6, 7; 6, 9; 6, 183; 6, 187; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 13; 9, 176; 10, comparison_operator:is; 10, 1...
def data_worker(**kwargs): """ Function to be spawned concurrently, consume data keys from input queue, and push the resulting dataframes to output map """ if kwargs is not None: if "function" in kwargs: function = kwargs["function"] else: Exception("Invalid a...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:makeproperty; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:ns; 5, default_parameter; 5, 6; 5, 7; 6, identifier:cls; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:name; 10, None; 11, default_parameter; 11, 12; 11, 13...
def makeproperty(ns, cls=None, name=None, docstring='', descendant=True): """ Make a property on an instance of an SLDNode. If cls is omitted, the property is assumed to be a text node, with no corresponding class object. If name is omitted, the property is assumed to be a complex ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_parse_from_string; 3, parameters; 3, 4; 4, identifier:string_input; 5, block; 5, 6; 5, 8; 5, 9; 5, 25; 5, 50; 5, 153; 5, 170; 5, 229; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11...
def _parse_from_string(string_input): """Parses a Sudoku instance from string input. :param string_input: A string containing the Sudoku to parse. :type string_input: str :return: The parsed Sudoku. :rtype: :py:class:`dlxsudoku.sudoku.Sudoku` """ # Check if comm...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:solve; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:verbose; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:allow_brute_force; 10, True; 11, block; 11, 12; 11, 14; 11, 162; 12...
def solve(self, verbose=False, allow_brute_force=True): """Solve the Sudoku. :param verbose: If the steps used for solving the Sudoku should be printed. Default is `False` :type verbose: bool :param allow_brute_force: If Dancing Links Brute Force method ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_fill_hidden_singles; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 355; 6, expression_statement; 6, 7; 7, comment; 8, for_statement; 8, 9; 8, 10; 8, 18; 9, identifier:i; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, ...
def _fill_hidden_singles(self): """Look for hidden singles, i.e. cells with only one unique possible value in row, column or box. :return: If any Hidden Single has been found. :rtype: bool """ for i in utils.range_(self.side): box_i = (i // self.order) * self.order ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:request; 6, default_parameter; 6, 7; 6, 8; 7, identifier:reverse; 8, False; 9, block; 9, 10; 9, 12; 9, 29; 9, 37; 9, 48; 10, expression_statement; 10, 11; 11, comment; 12,...
def sort(self, request, reverse=False): """Sort current collection.""" field = self.model._meta.fields.get(self.columns_sort) if not field: return self.collection if reverse: field = field.desc() return self.collection.order_by(field)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:process_docstring; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:app; 5, identifier:what; 6, identifier:name; 7, identifier:obj; 8, identifier:options; 9, identifier:lines; 10, block; 10, 11; 10, 13; 10, 22; 10, 54; 10, 62; ...
def process_docstring(app, what, name, obj, options, lines): """Modify the docstring before generating documentation. This will insert type declarations for parameters and return type into the docstring, and remove the signature field so that it will be excluded from the generated document. """ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:main; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:argv; 6, None; 7, block; 7, 8; 7, 10; 7, 19; 7, 34; 7, 47; 7, 70; 7, 87; 7, 103; 7, 116; 7, 127; 7, 140; 7, 141; 7, 164; 7, 177; 7, 205; 7, 209; 7, 317; 7, 334; 8, expre...
def main(argv=None): """Start the command line interface.""" parser = ArgumentParser(prog="pygenstub") parser.add_argument("--version", action="version", version="%(prog)s " + __version__) parser.add_argument("files", nargs="*", help="generate stubs for given files") parser.add_argument( "-m...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_code; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 40; 5, 44; 5, 83; 5, 113; 5, 119; 5, 210; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:s...
def get_code(self): """Get the stub code for this function. :sig: () -> List[str] :return: Lines of stub code for this function. """ stub = [] for deco in self.decorators: if (deco in DECORATORS) or deco.endswith(".setter"): stub.append("@" +...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:query_metric_stats; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:metric_type; 6, default_parameter; 6, 7; 6, 8; 7, identifier:metric_id; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifi...
def query_metric_stats(self, metric_type, metric_id=None, start=None, end=None, bucketDuration=None, **query_options): """ Query for metric aggregates from the server. This is called buckets in the Hawkular-Metrics documentation. :param metric_type: MetricType to be matched (required) :...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:find_files; 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:path; 6, string:''; 7, default_parameter; 7, 8; 7, 9; 8, identifier:ext; 9, string:''; 10, default_parameter; 10, 11; 10,...
def find_files(path='', ext='', level=None, typ=list, dirs=False, files=True, verbosity=0): """ Recursively find all files in the indicated directory Filter by the indicated file name extension (ext) Args: path (str): Root/base path to search. ext (str): File name extension. Only file paths...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:limitted_dump; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 4, default_parameter; 4, 5; 4, 6; 5, identifier:cursor; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:twitter; 9, None; 10, default_parameter; 10, 11; 10, 12; 11,...
def limitted_dump(cursor=None, twitter=None, path='tweets.json', limit=450, rate=TWITTER_SEARCH_RATE_LIMIT, indent=-1): """Dump a limitted number of json.dump-able objects to the indicated file rate (int): Number of queries per 15 minute twitter window """ if not twitter: twitter = get_twitter(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:request; 6, default_parameter; 6, 7; 6, 8; 7, identifier:reverse; 8, False; 9, block; 9, 10; 9, 12; 10, expression_statement; 10, 11; 11, comment; 12, return_statement; 12...
async def sort(self, request, reverse=False): """Sort collection.""" return sorted( self.collection, key=lambda o: getattr(o, self.columns_sort, 0), reverse=reverse)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:_request; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:self; 5, identifier:path; 6, identifier:key; 7, identifier:data; 8, identifier:method; 9, identifier:key_is_cik; 10, default_parameter; 10, 11; 10, 12; 11, ident...
def _request(self, path, key, data, method, key_is_cik, extra_headers={}): """Generically shared HTTP request method. Args: path: The API endpoint to interact with. key: A string for the key used by the device for the API. Either a CIK or token. data: A string for t...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:parse_intervals; 3, parameters; 3, 4; 3, 5; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:as_context; 7, False; 8, block; 8, 9; 8, 11; 8, 59; 8, 81; 8, 90; 8, 96; 8, 105; 9, expression_statement; 9, 10; 10, comment; 11, fu...
def parse_intervals(path, as_context=False): """ Parse path strings into a collection of Intervals. `path` is a string describing a region in a file. It's format is dotted.module.name:[line | start-stop | context] `dotted.module.name` is a python module `line` is a single line number in t...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:graphiter; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:graph; 6, identifier:target; 7, default_parameter; 7, 8; 7, 9; 8, identifier:ascendants; 9, integer:0; 10, default_parameter; 10, 11; 10, 12; 11, identi...
def graphiter(self, graph, target, ascendants=0, descendants=1): """ Iter on a graph to finds object connected :param graph: Graph to serialize :type graph: Graph :param target: Node to iterate over :type target: Node :param ascendants: Number of level to iter over upwar...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:map_aliases_to_device_objects; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 47; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:all_devices; 11, c...
def map_aliases_to_device_objects(self): """ A device object knows its rid, but not its alias. A portal object knows its device rids and aliases. This function adds an 'portals_aliases' key to all of the device objects so they can be sorted by alias. """...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:print_sorted_device_list; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:device_list; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort_key; 10, string:'sn'; 11, block; 11, 12;...
def print_sorted_device_list(self, device_list=None, sort_key='sn'): """ Takes in a sort key and prints the device list according to that sort. Default sorts on serial number. Current supported sort options are: - name - sn - ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:enrich; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:columns; 6, block; 6, 7; 6, 9; 6, 26; 6, 27; 6, 28; 6, 41; 6, 45; 6, 53; 6, 156; 6, 172; 7, expression_statement; 7, 8; 8, comment; 9, for_statement; 9, 10; 9, 11; 9, 12; 10, ...
def enrich(self, columns): """ This method appends at the end of the dataframe as many rows as items are found in the list of elemnents in the provided columns. This assumes that the length of the lists for the several specified columns is the same. As an example, for the row A ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:parse_metadata; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:obj; 6, identifier:xml; 7, block; 7, 8; 7, 10; 7, 47; 7, 84; 7, 101; 7, 102; 7, 134; 7, 140; 8, expression_statement; 8, 9; 9, comment; 10, for_statement; 10, 11;...
def parse_metadata(cls, obj, xml): """ Parse a resource to feed the object :param obj: Obj to set metadata of :type obj: XmlCtsTextMetadata :param xml: An xml representation object :type xml: lxml.etree._Element """ for child in xml.xpath("ti:description", names...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:setup; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:app; 6, block; 6, 7; 6, 9; 6, 18; 6, 26; 6, 27; 6, 48; 6, 71; 6, 97; 6, 162; 6, 187; 6, 188; 6, 238; 6, 256; 6, 311; 6, 340; 6, 341; 6, 362; 7, expression_statement; 7, 8; 8, c...
def setup(self, app): """ Initialize the application. """ super().setup(app) self.handlers = OrderedDict() # Connect admin templates app.ps.jinja2.cfg.template_folders.append(op.join(PLUGIN_ROOT, 'templates')) @app.ps.jinja2.filter def admtest(value, a, b=None)...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:passageLoop; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:parent; 5, identifier:new_tree; 6, identifier:xpath1; 7, default_parameter; 7, 8; 7, 9; 8, identifier:xpath2; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, i...
def passageLoop(parent, new_tree, xpath1, xpath2=None, preceding_siblings=False, following_siblings=False): """ Loop over passages to construct and increment new tree given a parent and XPaths :param parent: Parent on which to perform xpath :param new_tree: Parent on which to add nodes :param xpath1: L...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 1, 21; 2, function_name:cancellable_wait; 3, parameters; 3, 4; 3, 5; 3, 14; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 8; 6, list_splat_pattern; 6, 7; 7, identifier:awaitables; 8, type; 8, 9; 9, generic_type; 9, 10; 9, 11; 10, identifier:Awaitable; 11, t...
async def cancellable_wait(self, *awaitables: Awaitable[_R], timeout: float = None) -> _R: """ Wait for the first awaitable to complete, unless we timeout or the token is triggered. Returns the result of the first awaitable to complete. Raises TimeoutError if we timeout or ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_tweets_count_times; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:twitter; 5, identifier:count; 6, default_parameter; 6, 7; 6, 8; 7, identifier:query; 8, None; 9, block; 9, 10; 9, 12; 9, 13; 9, 24; 9, 30; 9, 34; 9, 38; 9, 215; 9, 223; 9, 2...
def get_tweets_count_times(twitter, count, query=None): r""" hits the twitter api `count` times and grabs tweets for the indicated query""" # get id to start from oldest_id, newest_id = _get_oldest_id(query=query) newest_id = newest_id or oldest_id all_tweets = [] i = 0 while i < count: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:register; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:cls; 5, identifier:code; 6, identifier:name; 7, default_parameter; 7, 8; 7, 9; 8, identifier:hash_name; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:hash_n...
def register(cls, code, name, hash_name=None, hash_new=None): """Add an application-specific function to the registry. Registers a function with the given `code` (an integer) and `name` (a string, which is added both with only hyphens and only underscores), as well as an optional `hash_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:compile_vocab; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:docs; 5, default_parameter; 5, 6; 5, 7; 6, identifier:limit; 7, float:1e6; 8, default_parameter; 8, 9; 8, 10; 9, identifier:verbose; 10, integer:0; 11, default_parameter; 11,...
def compile_vocab(docs, limit=1e6, verbose=0, tokenizer=Tokenizer(stem=None, lower=None, strip=None)): """Get the set of words used anywhere in a sequence of documents and assign an integer id This vectorizer is much faster than the scikit-learn version (and only requires low/constant RAM ?). >>> gen = ('...
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:resource; 6, block; 6, 7; 6, 9; 6, 13; 6, 17; 6, 21; 6, 63; 6, 120; 6, 144; 6, 145; 6, 159; 6, 160; 6, 167; 6, 177; 7, expression_statement; 7, 8; 8, comment; 9, expression_sta...
def parse(self, resource): """ Parse a list of directories and reads it into a collection :param resource: List of folders :return: An inventory resource and a list of CtsTextMetadata metadata-objects """ textgroups = [] texts = [] invalids = [] for fold...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:generate_address_label; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 24; 5, 40; 5, 58; 5, 83; 5, 97; 5, 98; 5, 131; 5, 132; 5, 142; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 12; 9, attribute; 9, 1...
def generate_address_label(self): """Construct a list for address label. Non-empty premises elements are appended to the address label in the order of organisation_name, department_name, po_box_number (which must be prepended with 'PO Box', sub_building_name, building_name, buil...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:verify_token; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:token; 5, identifier:public_key_or_address; 6, default_parameter; 6, 7; 6, 8; 7, identifier:signing_algorithm; 8, string:"ES256K"; 9, block; 9, 10; 9, 12; 9, 19; 9, 25; 9, 35; 9, 47; ...
def verify_token(token, public_key_or_address, signing_algorithm="ES256K"): """ A function for validating an individual token. """ decoded_token = decode_token(token) decoded_token_payload = decoded_token["payload"] if "subject" not in decoded_token_payload: raise ValueError("Token doesn't ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_translations; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:locale; 6, block; 6, 7; 6, 9; 6, 18; 6, 31; 6, 35; 6, 133; 6, 146; 6, 150; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment;...
def get_translations(self, locale): """ Get translation dictionary Returns a dictionary for locale or raises an exception if such can't be located. If a dictionary for locale was previously loaded returns that, otherwise goes through registered locations and merges any fo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:process_request; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:session; 6, block; 6, 7; 6, 9; 6, 17; 6, 30; 6, 238; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, id...
def process_request(self, session): """ Process single request from the given session :param session: session for reading requests and writing responses :return: None """ debugger = self.debugger() debugger_session_id = debugger.session_id() if debugger is not None else None try: request = session.r...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find_point_in_section_list; 3, parameters; 3, 4; 3, 5; 4, identifier:point; 5, identifier:section_list; 6, block; 6, 7; 6, 9; 6, 25; 6, 67; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 22; 10, boolean_operator:or; 10, 1...
def find_point_in_section_list(point, section_list): """Returns the start of the section the given point belongs to. The given list is assumed to contain start points of consecutive sections, except for the final point, assumed to be the end point of the last section. For example, the list [5, 8, 30, 3...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:find_range_ix_in_section_list; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:start; 5, identifier:end; 6, identifier:section_list; 7, block; 7, 8; 7, 10; 7, 28; 7, 51; 7, 76; 8, expression_statement; 8, 9; 9, comment; 10, if_statement; 10, 11;...
def find_range_ix_in_section_list(start, end, section_list): """Returns the index range all sections belonging to the given range. The given list is assumed to contain start points of consecutive sections, except for the final point, assumed to be the end point of the last section. For example, the lis...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:find_range_in_section_list; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:start; 5, identifier:end; 6, identifier:section_list; 7, block; 7, 8; 7, 10; 7, 19; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assi...
def find_range_in_section_list(start, end, section_list): """Returns all sections belonging to the given range. The given list is assumed to contain start points of consecutive sections, except for the final point, assumed to be the end point of the last section. For example, the list [5, 8, 30, 31] is...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:find_range_ix_in_point_list; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:start; 5, identifier:end; 6, identifier:point_list; 7, block; 7, 8; 7, 10; 8, expression_statement; 8, 9; 9, comment; 10, return_statement; 10, 11; 11, list:[point_list...
def find_range_ix_in_point_list(start, end, point_list): """Returns the index range all points inside the given range. Parameters --------- start : float The start of the desired range. end : float The end of the desired range. point_list : sortedcontainers.SortedList A ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:check; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:type_spec; 6, identifier:arg_name; 7, identifier:decorated_function; 8, block; 8, 9; 8, 11; 8, 42; 9, expression_statement; 9, 10; 10, comment; 11, function_definit...
def check(self, type_spec, arg_name, decorated_function): """ Return callable that checks function parameter for type validity. Checks parameter if it is instance of specified class or classes :param type_spec: type or list/tuple/set of types :param arg_name: function parameter name :param decorated_function...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:check; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:type_spec; 6, identifier:arg_name; 7, identifier:decorated_function; 8, block; 8, 9; 8, 11; 8, 40; 9, expression_statement; 9, 10; 10, comment; 11, function_definit...
def check(self, type_spec, arg_name, decorated_function): """ Return callable that checks function parameter for class validity. Checks parameter if it is class or subclass of specified class or classes :param type_spec: type or list/tuple/set of types :param arg_name: function parameter name :param decorate...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:check; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:value_spec; 6, identifier:arg_name; 7, identifier:decorated_function; 8, block; 8, 9; 8, 11; 8, 40; 9, expression_statement; 9, 10; 10, comment; 11, function_defini...
def check(self, value_spec, arg_name, decorated_function): """ Return callable that checks function parameter for value validity. Checks parameter if its value passes specified restrictions. :param value_spec: function or list/tuple/set of functions. Each function must accept one parameter and \ must return Tr...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:cache_control; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:validator; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:storage; 9, None; 10, block; 10, 11; 10, 13; 10, 23; 10, 32; 10, 43; 10, 130; 11, exp...
def cache_control(validator=None, storage=None): """ Decorator that is used for caching result. :param validator: function, that has following signature (decorated_function, \*args, \*\*kwargs), where \ decorated_function - original function, args - function arguments, kwargs - function keyword arguments. \ This f...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 14; 2, function_name:parse_int_string; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:int_string; 6, type; 6, 7; 7, identifier:str; 8, type; 8, 9; 9, generic_type; 9, 10; 9, 11; 10, identifier:List; 11, type_parameter; 11, 12; 12, type; 1...
def parse_int_string(int_string: str) -> List[int]: """ Given a string like "1 23 4-8 32 1", return a unique list of those integers in the string and the integers in the ranges in the string. Non-numbers ignored. Not necessarily sorted """ cleaned = " ".join(int_string.strip().split()) clean...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:locations_within; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:a; 5, identifier:b; 6, identifier:tolerance; 7, block; 7, 8; 7, 10; 7, 14; 7, 15; 7, 22; 7, 85; 7, 104; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11...
def locations_within(a, b, tolerance): """ Verifies whether two positions are the same. A tolerance value determines how close the two positions must be to be considered "same". The two locations must be dictionaries that have the same keys. If a key is pesent in one but not in the other, this ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:persistence2stats; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:rev_docs; 5, default_parameter; 5, 6; 5, 7; 6, identifier:min_persisted; 7, integer:5; 8, default_parameter; 8, 9; 8, 10; 9, identifier:min_visible; 10, int...
def persistence2stats(rev_docs, min_persisted=5, min_visible=1209600, include=None, exclude=None, verbose=False): """ Processes a sorted and page-partitioned sequence of revision documents into and adds statistics to the 'persistence' field each token "added" in the revision persis...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:update_index; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 13; 5, 109; 5, 115; 5, 116; 5, 120; 5, 189; 5, 211; 5, 217; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, assignm...
def update_index(self): """ Regenerates the permission index for this set Called everytime a rule is added / removed / modified in the set """ # update index idx = {} for _, p in sorted(self.permissions.items(), key=lambda x: str(x[0])): bra...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:type_check; 3, parameters; 3, 4; 4, identifier:func_handle; 5, block; 5, 6; 5, 8; 5, 119; 5, 346; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 14; 8, 15; 8, 16; 8, 17; 8, 18; 8, 19; 9, function_name:checkTy...
def type_check(func_handle): """ Ensure arguments have the type specified in the annotation signature. Example:: def foo(a, b:str, c:int =0, d:(int, list)=None): pass This function accepts an arbitrary parameter for ``a``, a string for ``b``, an integer for ``c`` which default...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:qteProcessKey; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:event; 6, identifier:targetObj; 7, block; 7, 8; 7, 10; 7, 11; 7, 21; 7, 28; 7, 39; 7, 40; 7, 41; 7, 77; 7, 78; 7, 87; 7, 88; 7, 96; 7, 127; 7, 128; 7, 129; 7, 130...
def qteProcessKey(self, event, targetObj): """ If the key completes a valid key sequence then queue the associated macro. |Args| * ``targetObj`` (**QObject**): the source of the event (see Qt documentation). * ``event_qt`` (**QKeyEvent**): information about th...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:timerEvent; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:event; 6, block; 6, 7; 6, 9; 6, 20; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12,...
def timerEvent(self, event): """ Trigger the focus manager and work off all queued macros. The main purpose of using this timer event is to postpone updating the visual layout of Qtmacs until all macro code has been fully executed. Furthermore, this GUI update needs to h...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 37; 2, function_name:qteNextApplet; 3, parameters; 3, 4; 3, 5; 3, 10; 3, 17; 3, 22; 3, 27; 3, 32; 4, identifier:self; 5, typed_default_parameter; 5, 6; 5, 7; 5, 9; 6, identifier:numSkip; 7, type; 7, 8; 8, identifier:int; 9, integer:1; 10, typed_default_parameter; ...
def qteNextApplet(self, numSkip: int=1, ofsApp: (QtmacsApplet, str)=None, skipInvisible: bool=True, skipVisible: bool=False, skipMiniApplet: bool=True, windowObj: QtmacsWindow=None): """ Return the next applet in cyclic order. If...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:_qteRunQueuedMacro; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 16; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:macroName; 7, type; 7, 8; 8, identifier:str; 9, typed_default_parameter; 9, 10; 9, 11; 9, 15; 10, identifier:widgetOb...
def _qteRunQueuedMacro(self, macroName: str, widgetObj: QtGui.QWidget=None, keysequence: QtmacsKeysequence=None): """ Execute the next macro in the macro queue. This method is triggered by the ``timerEvent`` in conjunction with the f...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:qteNewApplet; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 14; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:appletName; 7, type; 7, 8; 8, identifier:str; 9, typed_default_parameter; 9, 10; 9, 11; 9, 13; 10, identifier:appletID; 11,...
def qteNewApplet(self, appletName: str, appletID: str=None, windowObj: QtmacsWindow=None): """ Create a new instance of ``appletName`` and assign it the ``appletID``. This method creates a new instance of ``appletName``, as registered by the ``qteRegisterApp...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:qteAddMiniApplet; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:appletObj; 7, type; 7, 8; 8, identifier:QtmacsApplet; 9, block; 9, 10; 9, 12; 9, 13; 9, 14; 9, 36; 9, 37; 9, 38; 9, 39; 9, 78; 9, 79;...
def qteAddMiniApplet(self, appletObj: QtmacsApplet): """ Install ``appletObj`` as the mini applet in the window layout. At any given point there can ever only be one mini applet in the entire Qtmacs application, irrespective of how many windows are open. Note that this ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:qteKillMiniApplet; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 17; 5, 18; 5, 45; 5, 196; 5, 197; 5, 205; 5, 213; 5, 214; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, if_statement; 9, 10; 9, 15; 10, compa...
def qteKillMiniApplet(self): """ Remove the mini applet. If a different applet is to be restored/focused then call ``qteMakeAppletActive`` for that applet *after* calling this method. |Args| * **None** |Returns| * **None** |Raises| ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:qteSplitApplet; 3, parameters; 3, 4; 3, 5; 3, 12; 3, 17; 4, identifier:self; 5, typed_default_parameter; 5, 6; 5, 7; 5, 11; 6, identifier:applet; 7, type; 7, 8; 8, tuple; 8, 9; 8, 10; 9, identifier:QtmacsApplet; 10, identifier:str; 11, None; 1...
def qteSplitApplet(self, applet: (QtmacsApplet, str)=None, splitHoriz: bool=True, windowObj: QtmacsWindow=None): """ Reveal ``applet`` by splitting the space occupied by the current applet. If ``applet`` is already visible then the method do...