sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
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, 18; 8, 22; 8, 65; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, ...
def contigs_to_positions(contigs, binning=10000): positions = np.zeros_like(contigs) index = 0 for _, chunk in itertools.groubpy(contigs): l = len(chunk) positions[index : index + l] = np.arange(list(chunk)) * binning index += l return positions
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; 7, if_statement; 7, 8; 7, 13; 7, 18; 7, 31; 8, comparison_operator:<=; 8, 9; 8, 10; 9, identifier:x; 10, subscript; 10, 11; 10, 12; 11, identif...
def find_nearest(sorted_list, x): if x <= sorted_list[0]: return sorted_list[0] elif x >= sorted_list[-1]: return sorted_list[-1] else: lower = find_le(sorted_list, x) upper = find_ge(sorted_list, x) if (x - lower) > (upper - x): return upper else:...
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, 31; 9, 49; 9, 53; 9, 68; 9, 72; 9, 80; 9, 100; 9, 106; 9, 116; 9, 120;...
def execute(input_params, engine, cwd=None): try: taskengine_exe = config.get('engine') except NoConfigOptionError: raise TaskEngineNotFoundError( "Task Engine config option not set." + "\nPlease verify the 'engine' configuration setting.") if not os.path.exists(taske...
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, 44; 6, 95; 6, 121; 6, 141; 6, 151; 6, 157; 6, 270; 6, 296; 6, 305; 6, 317; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_nam...
def merge_fasta(fasta_file, output_dir): def chunk_lexicographic_order(chunk): chunk_fields = chunk.split("_") chunk_name = chunk_fields[:-1] chunk_id = chunk_fields[-1] return (chunk_name, int(chunk_id)) def are_consecutive(chunk1, chunk2): if None in {chunk1, chunk2}: ...
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"): if file_format == "mwtab": for key, value in self[section_key].items(): if section_key == "METABOLOMICS WORKBENCH" and key not in ("VERSION", "CREATED_ON"): continue if key in (...
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): if backoff is None or backoff <= 0: raise ValueError("backoff must be a number greater than 0") tries = math.floor(tries) if tries < 0: raise ValueError("tries must be a number 0 or greater") ...
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): ei_name = "Ecoinvent{}_{}_{}".format(*ecoinvent_version.split('.'), ecoinvent_system_model) config = check_for_config() if config is None: co...
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): if use_autodownload: forwast_filepath = forwast_autodownload(FORWAST_URL) elif forwast_path is not None: forwast_filepath = forwast_path else: raise ValueErro...
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): from_subject_samples = {i["local_sample_id"] for i in mwtabfile["SUBJECT_SAMPLE_FACTORS"]["SUBJECT_SAMPLE_FACTORS"]} from_subject_factors = {i["factors"] for i in mwtabfile["SUBJECT_SAMPLE_FACTORS"]["SUBJECT_SAMPLE_FACTORS"]...
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, 21; 5, 152; 5, 183; 5, 232; 5, 277; 5, 296; 5, 347; 5, 378; 5, 393; 5, 405; 6, if_statement; 6, 7; 6, 14; 7, call; 7, 8; 7, 9; 8, identifier:isinstance; 9, argument_list; 9,...
def convert(schema): if isinstance(schema, vol.Schema): schema = schema.schema if isinstance(schema, Mapping): val = [] for key, value in schema.items(): description = None if isinstance(key, vol.Marker): pkey = key.schema descripti...
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, 12; 5, 19; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:theA; 11, string:'\n'; 12, expression_statem...
def _jsmin(self): self.theA = '\n' self._action(3) while self.theA != '\000': if self.theA == ' ': if isAlphanum(self.theB): self._action(1) else: self._action(2) elif self.theA == '\n': ...
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, 18; 5, 393; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:stream; 9, call; 9, 10; 9, 11; 10, identifier:deque; 11, argument_list; 11, 12; 12, call;...
def tokenizer(text): stream = deque(text.split("\n")) while len(stream) > 0: line = stream.popleft() if line.startswith(" yield KeyValue(" yield KeyValue("HEADER", line) for identifier in line.split(" "): if ":" in identifier: ...
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, 28; 9, 35; 9, 39; 9, 59; 9, 70; 9, 114; 9, 123; 9, 131; 9, 139; 9, 143; 9, 1...
def _proxy(self, url, urlparams=None): for k,v in request.params.iteritems(): urlparams[k]=v query = urlencode(urlparams) full_url = url if query: if not full_url.endswith("?"): full_url += "?" full_url += query req = urllib2.Re...
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, 20; 7, 48; 7, 109; 7, 118; 7, 134; 7, 140; 7, 146; 7, 155; 7, 170; 7, 184; 7, 20...
def attempt_open_query_permutations(url, orig_file_path, is_header_file): directory = dirname(convert_to_platform_safe(orig_file_path)) + "/" try: filenames = [f for f in os.listdir(directory) if isfile(join(directory, f))] except OSError: return if is_header_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): dict_list = [] if allow_internal: internal_dict = {} for k, v in self.database['items'].items(): if v.get('lcopt_type') == 'intermediate': ...
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, 14; 5, 24; 5, 28; 5, 50; 5, 173; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:names; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11;...
def create_parameter_map(self): names = self.modelInstance.names db = self.modelInstance.database['items'] parameter_map = {} def get_names_index(my_thing): return[i for i, x in enumerate(names) if x == my_thing][0] for k, this_item in db.items(): if this_...
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): config = get_config(config_override) databases = config['databases'] if rollback and not tag_override: raise RuntimeError( 'To rollback a migration you need to specify the database tag with `--tag`') ...
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='' ): log_level = self.config.get_option( 'LOGGING', prefix + 'log_level', None, fallback_level...
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): uname, version = split_name(name) lock = None if self.local_store: lock = self.lock_manager.lock_for(uname) if _lock_exclusive: lock.lock_exc...
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): uname, version = split_name(name) lock = None if self.local_store: lock = self.lock_manager.lock_for(uname) lock.lock_shared() try: if not self.remote_store or (version is not Non...
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): if not to_local_store and not to_remote_store: raise ValueError("Neither to_local_store nor to_remote_store set " ...
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, 17; 8, 21; 8, 25; 8, 54; 8, 165; 9, if_statement; 9, 10; 9, 12; 10, not_operator; 10, 11; 11, identif...
def check(operations, loud=False): if not CHECKERS: load_checkers() roll_call = [] everything_ok = True if loud and operations: title = "Preflyt Checklist" sys.stderr.write("{}\n{}\n".format(title, "=" * len(title))) for operation in operations: if operation.get('chec...
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): if lower is not None and upper is not None: deci = normalize(deci, lower=lower, upper=upper, b=b) sign = 1 if deci < 0: deci = abs(deci) sign = -1 hd, f1 = divmod(deci, 1) ...
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, 10; 5, 14; 5, 23; 5, 32; 5, 40; 5, 49; 5, 56; 5, 129; 5, 423; 5, 451; 5, 460; 5, 476; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:units; 9, None;...
def phmsdms(hmsdms): units = None sign = None pattern1 = re.compile(r"([-+]?[0-9]*\.?[0-9]+[^0-9\-+]*)") pattern2 = re.compile(r"([-+]?[0-9]*\.?[0-9]+)") hmsdms = hmsdms.lower() hdlist = pattern1.findall(hmsdms) parts = [None, None, None] def _fill_right_not_none(): rp = reversed...
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, 19; 8, 34; 8, 160; 8, 192; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identif...
def pposition(hd, details=False): p = re.split(r"[^\d\-+.]*", hd) if len(p) not in [2, 6]: raise ValueError("Input must contain either 2 or 6 numbers.") if len(p) == 2: x, y = float(p[0]), float(p[1]) if details: numvals = 2 raw_x = p[0] raw_y = p[...
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): if session is not None: token = session['token'] http_session = session['http_session'] else: if not clc._LOGIN_TOKEN_V2: API._Login() token = clc._LOGIN_TOKEN_V2 http_session = clc._REQUESTS_SESSION if payload is None: payload =...
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, 10; 5, 346; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:to_process; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 15; 11, identifier:file...
def processFiles(args): to_process = [] for filename in args['filenames']: file = dict() if args['include']: file['include'] = INCLUDE_STRING + ''.join( ['-I' + item for item in args['include']]) else: file['include'] = INCLUDE_STRING file[...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:main; 3, parameters; 4, block; 4, 5; 4, 19; 4, 32; 4, 46; 4, 68; 4, 95; 4, 123; 4, 145; 4, 168; 4, 176; 4, 217; 4, 233; 4, 257; 4, 270; 4, 281; 4, 303; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:parser; 8, call; 8, ...
def main(): parser = argparse.ArgumentParser(description='DistanceClassifier for classification based on distance measure in feature space.', add_help=False) parser.add_argument('INPUT_FILE', type=str, help='Data file to perform DistanceClassifier on; ensure that the class l...
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, 20; 10, 44; 10, 312; 10, 320; 11, expression_s...
def delete(self, name, version, _lock=True): link_path = self._link_path(name) if _lock: file_lock = _exclusive_lock(self._lock_path('links', name)) else: file_lock = _no_lock() with file_lock: logger.debug('Acquired or inherited lock for link %s.', na...
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): results = [] for sock, mask in sock_events: if isinstance(sock, zmq.backend.Socket): mask = _check_events(sock, mask, inmask, outmask) if mask: results.append((sock, mask)) if results: ret...
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, 12; 7, 26; 7, 33; 7, 37; 7, 41; 7, 45; 7, 51; 7, 55; 7, 244; 7, 280; 7, 312; 7, 318; 7, 324; 7, 33...
def sync_ldap_user_membership(self, user, ldap_groups): groupname_field = 'name' actualGroups = user.groups.values_list('name', flat=True) user_Membership_total = len(ldap_groups) user_Membership_added = 0 user_Membership_deleted = 0 user_Membership_errors = 0 lda...
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, 113; 11, 139; 12, if_statement...
def get(self, block=True, timeout=None): if not self._data: if not block: raise Empty() current = compat.getcurrent() waketime = None if timeout is None else time.time() + timeout if timeout is not None: scheduler.schedule_at(waketi...
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, 11...
def put(self, item, block=True, timeout=None): if self.full(): if not block: raise Full() current = compat.getcurrent() waketime = None if timeout is None else time.time() + timeout if timeout is not None: scheduler.schedule_at(wake...
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, 10; 5, 50; 5, 57; 5, 61; 5, 155; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:recorder; 9, None; 10, function_definition; 10, 11; 10, 12;...
def _compress_tokens(tokens): recorder = None def _edge_case_stray_end_quoted(tokens, index): tokens[index] = Token(type=TokenType.UnquotedLiteral, content=tokens[index].content, line=tokens[index].line, col=tokens...
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, 15; 5, 24; 5, 31; 5, 35; 5, 39; 5, 70; 5, 85; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:contents; 9, call; 9, 10; 9, 11; 10, identi...
def _parse_dependencies(string): contents = _get_contents_between(string, '(', ')') unsorted_dependencies = contents.split(',') _check_parameters(unsorted_dependencies, ('?',)) buildable_dependencies = [] given_dependencies = [] for dependency in unsorted_dependencies: if dependency[0] =...
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): current = compat.getcurrent() activated = {} poll_regs = {} callback_refs = {} def activate(fd, event): if not activated and timeout != 0: scheduler.schedule(current) if timeout: scheduler._re...
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, 17; 5, 37; 5, 44; 5, 51; 5, 69; 6, if_statement; 6, 7; 6, 11; 7, not_operator; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:input; 11, blo...
def processAndSetDefaults(self): if not self.input: raise ValueError(NO_INPUT_FILE) if not self.output: if not self.build_directory: File() pass else: pass if not self.build_directory: pass for dependency...
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): if target is None: def decorator(target): return schedule(target, args=args, kwargs=kwargs) return decorator if isinstance(target, compat.greenlet) or target is compat.main_greenlet: glet = target else: glet = green...
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): if target is None: def decorator(target): return schedule_at(unixtime, target, args=args, kwargs=kwargs) return decorator if isinstance(target, compat.greenlet) or target is compat.main_greenlet: glet = target ...
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): starting_at = starting_at or time.time() if target is None: def decorator(target): return schedule_recurring( interval, target, maxtimes, starting_at, args, ...
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, 14; 6, 21; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:sorted_output; 10, call; 10, 11; 10, 12; 11, iden...
def assert_output(output, assert_equal): sorted_output = sorted(output) sorted_assert = sorted(assert_equal) if sorted_output != sorted_assert: raise ValueError(ASSERT_ERROR.format(sorted_output, sorted_assert))
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): if isinstance(check, str): check = (check,) to_join = [] for item in check: if item: to_join.append(str(item)) else: to_join.append("''") prompt += " [{}]: ".format('/'.join(to_join)) ...
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, 45; 5, 103; 6, function_definition; 6, 7; 6, 8; 6, 13; 7, function_name:pip_install; 8, parameters; 8, 9; 8, 10; 9, identifier:pkg_name; 10, default_para...
def install_build_requires(pkg_targets): 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 found, attempting to install using a raw "pip install" call!' % pkg_name_version subprocess.Popen('pip insta...
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, 21; 7, 34; 7, 96; 7, 117; 7, 248; 7, 273; 7, 277; 7, 319; 7, 340; 8, expression_statement; 8, 9; 9, assig...
def PackagePublishUI(package,type,visibility): linux_lst = {'L': {'selected': False, 'Description': 'All Linux'}} windows_lst = {'W': {'selected': False, 'Description': 'All Windows'}} for r in clc.v1.Server.GetTemplates(): r['selected'] = False if re.search("Windows",r['Description']): windows_lst[str(r['...
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, 16; 6, 26; 6, 36; 6, 46; 6, 58; 6, 109; 6, 226; 6, 235; 6, 249; 6, 263; 7, expression_statement; 7, 8; 8, assig...
def _construct_select_query(**filter_definition): table_name = filter_definition.pop('table') distinct = filter_definition.pop('distinct', False) select_count = filter_definition.pop('count', False) if distinct and select_count: raise UnsupportedDefinitionError('SELECT (DISTINCT ...) is not supp...
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, 38; 11, 30...
def encode(df, encoding='utf8', verbosity=1): if verbosity > 0: pbar = progressbar.ProgressBar(maxval=df.shape[1]) pbar.start() for colnum, col in enumerate(df.columns): if isinstance(df[col], pd.Series): if verbosity: pbar.update(colnum) if df[col...
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, 181; 6, 185; 7, if_statement; 7, 8; 7, 11; 7, 174; 8, comparison_operator:is; 8, 9; 8, 10; 9, identifier:kwargs; 10, None; 11, block; ...
def data_worker(**kwargs): if kwargs is not None: if "function" in kwargs: function = kwargs["function"] else: Exception("Invalid arguments, no function specified") if "input" in kwargs: input_queue = kwargs["input"] else: Exception("In...
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): def get_property(self): if cls is None: xpath = '%s:%s' % (ns, name) else: xpath = '%s:%s' % (ns, cls.__name__) xpath = self._node.xpath(xpath, namespaces=SLDNode._nsmap)...
0, module; 0, 1; 1, ERROR; 1, 2; 1, 43; 1, 144; 1, 161; 1, 220; 2, function_definition; 2, 3; 2, 4; 2, 6; 2, 38; 3, function_name:_parse_from_string; 4, parameters; 4, 5; 5, identifier:string_input; 6, ERROR; 6, 7; 6, 23; 6, 28; 6, 29; 6, 37; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:read...
def _parse_from_string(string_input): read_lines = list(filter(None, string_input.split('\n'))) if read_lines[0].startswith(' comment = read_lines.pop(0) else: comment = '' if len(read_lines) > 1: order = int(math.sqrt(len(read_lines))) else: ...
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, 153; 12, while_...
def solve(self, verbose=False, allow_brute_force=True): while not self.is_solved: self._update() singles_found = False or self._fill_naked_singles() or self._fill_hidden_singles() if not singles_found: if allow_brute_force: solution = None ...
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, 346; 6, for_statement; 6, 7; 6, 8; 6, 16; 7, identifier:i; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:utils; 11, identifier:range_; 12, argu...
def _fill_hidden_singles(self): for i in utils.range_(self.side): box_i = (i // self.order) * self.order for j in utils.range_(self.side): box_j = (j // self.order) * self.order if self[i][j] > 0: continue p = self._poss...
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, 27; 9, 35; 9, 46; 10, expression_statement; 10, 11; 11, assignment; 11, 12;...
def sort(self, request, reverse=False): 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, 20; 10, 52; 10, 60; 10, 68; ...
def process_docstring(app, what, name, obj, options, lines): aliases = getattr(app, "_sigaliases", None) if aliases is None: if what == "module": aliases = get_aliases(inspect.getsource(obj).splitlines()) app._sigaliases = aliases sig_marker = ":" + SIG_FIELD + ":" is_cla...
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, 17; 7, 32; 7, 45; 7, 68; 7, 85; 7, 101; 7, 114; 7, 125; 7, 138; 7, 161; 7, 174; 7, 202; 7, 206; 7, 314; 7, 331; 8, expression_statement...
def main(argv=None): 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", "--module", action="appen...
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, 10; 5, 38; 5, 42; 5, 81; 5, 111; 5, 117; 5, 208; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:stub; 9, list:[]; 10, for_statement; 10, 11; 10, 12; ...
def get_code(self): stub = [] for deco in self.decorators: if (deco in DECORATORS) or deco.endswith(".setter"): stub.append("@" + deco) parameters = [] for name, type_, has_default in self.parameters: decl = "%(n)s%(t)s%(d)s" % { "n...
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): if start is not None: if type(start) is datetime: query_options['start'] = datetime_to_time_millis(start) else: query_options['start'] = ...
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): gen = generate_files(path, ext=ext, level=level, dirs=dirs, files=files, verbosity=verbosity) if isinstance(typ(), collections.Mapping): return typ((ff['path'], ff) for ff in gen) elif typ is not None: ...
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): if not twitter: twitter = get_twitter() cursor = cursor or 'python' if isinstance(cursor, basestring): cursor = get_cursor(twitter, search=cursor) newline = '\n' if ind...
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; 10, return_statement; 10, 11; 11, call; 11, 12; 11, 13; 12, identifier:sorted;...
async def sort(self, request, reverse=False): 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={}): if method == 'GET': if len(data) > 0: url = path + '?' + data else: url = path body = None else: url = path body = data headers =...
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, 57; 8, 79; 8, 88; 8, 94; 8, 103; 9, function_definition; 9, 10; 9, 11; 9, 12; 10, function_...
def parse_intervals(path, as_context=False): def _regions_from_range(): if as_context: ctxs = list(set(pf.lines[start - 1: stop - 1])) return [ ContextInterval(filename, ctx) for ctx in ctxs ] else: return [LineInterval(...
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): asc = 0 + ascendants if asc != 0: asc -= 1 desc = 0 + descendants if desc != 0: desc -= 1 t = str(target) if descendants != 0 and self.downwards[t] is True: self.downwards...
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, 14; 5, 45; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:all_devices; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11,...
def map_aliases_to_device_objects(self): all_devices = self.get_all_devices_in_portal() for dev_o in all_devices: dev_o['portals_aliases'] = self.get_portal_by_name( self.portal_name() )[2...
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'): dev_list = device_list if device_list is not None else self.get_all_devices_in_portal() sorted_dev_list = [] if sort_key == 'sn': sort_keys = [ k[sort_key] for k in dev_list if k[sort_key] is not None ] ...
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, 24; 6, 37; 6, 41; 6, 49; 6, 148; 6, 164; 7, for_statement; 7, 8; 7, 9; 7, 10; 8, identifier:column; 9, identifier:columns; 10, block; 10, 11; 11, i...
def enrich(self, columns): for column in columns: if column not in self.data.columns: return self.data first_column = list(self.data[columns[0]]) count = 0 append_df = pandas.DataFrame() for cell in first_column: if len(cell) >= 1: ...
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, 45; 7, 82; 7, 99; 7, 131; 8, for_statement; 8, 9; 8, 10; 8, 19; 9, identifier:child; 10, call; 10, 11; 10, 14; 11, attr...
def parse_metadata(cls, obj, xml): for child in xml.xpath("ti:description", namespaces=XPATH_NAMESPACES): lg = child.get("{http://www.w3.org/XML/1998/namespace}lang") if lg is not None: obj.set_cts_property("description", child.text, lg) for child in xml.xpath("ti...
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, 16; 6, 24; 6, 45; 6, 68; 6, 94; 6, 159; 6, 184; 6, 234; 6, 252; 6, 307; 6, 336; 6, 357; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 14; 9, attribut...
def setup(self, app): super().setup(app) self.handlers = OrderedDict() app.ps.jinja2.cfg.template_folders.append(op.join(PLUGIN_ROOT, 'templates')) @app.ps.jinja2.filter def admtest(value, a, b=None): return a if value else b @app.ps.jinja2.filter def ...
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): current_1, queue_1 = __formatXpath__(xpath1) if xpath2 is None: result_1, loop = performXpath(parent, current_1) if loop is True: queue_1 = xpath1 central = None ...
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: futures = [asyncio.ensure_future(a, loop=self.loop) for a in awaitables + (self.wait(),)] try: done, pending = await asyncio.wait( futures, timeout=timeout, ...
0, module; 0, 1; 0, 10; 0, 12; 0, 23; 0, 29; 0, 33; 0, 37; 0, 210; 0, 218; 0, 227; 0, 245; 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, bl...
def get_tweets_count_times(twitter, count, query=None): r oldest_id, newest_id = _get_oldest_id(query=query) newest_id = newest_id or oldest_id all_tweets = [] i = 0 while i < count: i += 1 if oldest_id <= newest_id: tweets = get_tweets(query=query, max_id=oldest_id - 1, ...
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): if not _is_app_specific_func(code): raise ValueError( "only application-specific functions can be registered") name_mapping_data = [ (cls._func_from_name, name, "function name is already re...
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)): tokenizer = make_tokenizer(tokenizer) d = Dictionary() try: limit = min(limit, docs.count()) docs = docs.iterator() except (AttributeError, TypeError): pass for i, doc in en...
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, 11; 6, 15; 6, 19; 6, 61; 6, 118; 6, 141; 6, 155; 6, 162; 6, 172; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:textgroup...
def parse(self, resource): textgroups = [] texts = [] invalids = [] for folder in resource: cts_files = glob("{base_folder}/data/*/__cts__.xml".format(base_folder=folder)) for cts_file in cts_files: textgroup, cts_file = self._parse_textgroup(cts_f...
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, 22; 5, 38; 5, 56; 5, 81; 5, 95; 5, 128; 5, 138; 6, if_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:organisation_name; 10,...
def generate_address_label(self): if self.organisation_name: self.address_label.append(self.organisation_name) if self.department_name: self.address_label.append(self.department_name) if self.po_box_number: self.address_label.append('PO Box ' + self.po_box_num...
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, 17; 9, 23; 9, 33; 9, 45; 9, 55; ...
def verify_token(token, public_key_or_address, signing_algorithm="ES256K"): decoded_token = decode_token(token) decoded_token_payload = decoded_token["payload"] if "subject" not in decoded_token_payload: raise ValueError("Token doesn't have a subject") if "publicKey" not in decoded_token_payload...
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, 16; 6, 29; 6, 33; 6, 131; 6, 144; 6, 148; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:locale; 10, call; 10, 1...
def get_translations(self, locale): locale = self.normalize_locale(locale) if locale in self.translations: return self.translations[locale] translations = {} for path in self.dirs: file = os.path.join(path, '{}.py'.format(locale)) if not os.path.isfile...
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, 15; 6, 28; 6, 236; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:debugger; 10, call; 10, 11; 10, 14; 11, attrib...
def process_request(self, session): debugger = self.debugger() debugger_session_id = debugger.session_id() if debugger is not None else None try: request = session.read_request() if debugger_session_id is not None: debugger.request( debugger_session_id, request, session.protocol_version(), session....
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, 23; 6, 65; 7, if_statement; 7, 8; 7, 20; 8, boolean_operator:or; 8, 9; 8, 14; 9, comparison_operator:<; 9, 10; 9, 11; 10,...
def find_point_in_section_list(point, section_list): if point < section_list[0] or point > section_list[-1]: return None if point in section_list: if point == section_list[-1]: return section_list[-2] ind = section_list.bisect(point)-1 if ind == 0: return ...
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, 26; 7, 49; 7, 74; 8, if_statement; 8, 9; 8, 21; 9, boolean_operator:or; 9, 10; 9, 16; 10, com...
def find_range_ix_in_section_list(start, end, section_list): if start > section_list[-1] or end < section_list[0]: return [0, 0] if start < section_list[0]: start_section = section_list[0] else: start_section = find_point_in_section_list(start, section_list) if end > section_list...
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, 17; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:ind; 11, call; 11...
def find_range_in_section_list(start, end, section_list): ind = find_range_ix_in_section_list(start, end, section_list) return section_list[ind[0]: ind[1]]
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; 8, return_statement; 8, 9; 9, list:[point_list.bisect_left(start), point_list.bisect_right(end)]; 9,...
def find_range_ix_in_point_list(start, end, point_list): return [point_list.bisect_left(start), point_list.bisect_right(end)]
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, 40; 9, function_definition; 9, 10; 9, 11; 9, 13; 10, function_name:raise_exc...
def check(self, type_spec, arg_name, decorated_function): def raise_exception(x_spec): exc_text = 'Argument "%s" for function "%s" has invalid type' % ( arg_name, Verifier.function_name(decorated_function) ) exc_text += ' (%s should be %s)' % (x_spec, type_spec) raise TypeError(exc_text) if isinstan...
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, 38; 9, function_definition; 9, 10; 9, 11; 9, 13; 10, function_name:raise_exc...
def check(self, type_spec, arg_name, decorated_function): def raise_exception(text_spec): exc_text = 'Argument "%s" for function "%s" has invalid type' % ( arg_name, Verifier.function_name(decorated_function) ) exc_text += ' (%s)' % text_spec raise TypeError(exc_text) if isinstance(type_spec, (tuple...
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, 38; 9, function_definition; 9, 10; 9, 11; 9, 13; 10, function_name:raise_ex...
def check(self, value_spec, arg_name, decorated_function): def raise_exception(text_spec): exc_text = 'Argument "%s" for function "%s" has invalid value' % ( arg_name, Verifier.function_name(decorated_function) ) exc_text += ' (%s)' % text_spec raise ValueError(exc_text) if isinstance(value_spec, (t...
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, 21; 10, 30; 10, 41; 10, 128; 11, function_de...
def cache_control(validator=None, storage=None): def default_validator(*args, **kwargs): return True if validator is None: validator = default_validator if storage is None: storage = WGlobalSingletonCacheStorage() def first_level_decorator(decorated_function): def second_level_decorator(original_function, *...
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]: cleaned = " ".join(int_string.strip().split()) cleaned = cleaned.replace(" - ", "-") cleaned = cleaned.replace(",", " ") tokens = cleaned.split(" ") indices: Set[int] = set() for token in tokens: if "-" in token: endpoints =...
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, 12; 7, 19; 7, 82; 7, 101; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:ret; 11, strin...
def locations_within(a, b, tolerance): ret = '' b = dict(b) for (key, value) in a.items(): if key not in b: raise ValueError("b does not have the key: " + key) if abs(int(value) - int(b[key])) > tolerance: ret += 'key {0} differs: {1} {2}'.format(key, int(value), ...
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): rev_docs = mwxml.utilities.normalize(rev_docs) min_persisted = int(min_persisted) min_visible = int(min_visible) include = include if include is not None else lambda t:...
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, 10; 5, 106; 5, 112; 5, 116; 5, 185; 5, 207; 5, 213; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:idx; 9, dictionary; 10, for_statement; 10, 11;...
def update_index(self): idx = {} for _, p in sorted(self.permissions.items(), key=lambda x: str(x[0])): branch = idx parent_p = const.PERM_DENY for k in p.namespace.keys: if not k in branch: branch[k] = {"__": parent_p} ...
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, 101; 5, 310; 6, function_definition; 6, 7; 6, 8; 6, 12; 7, function_name:checkType; 8, parameters; 8, 9; 8, 10; 8, 11; 9, identifier:var_name; 10, identifier:var_val...
def type_check(func_handle): def checkType(var_name, var_val, annot): if var_name in annot: var_anno = annot[var_name] if var_val is None: type_ok = True elif (type(var_val) is bool): type_ok = (type(var_val) in var_anno) else: ...
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, 18; 7, 25; 7, 36; 7, 72; 7, 81; 7, 89; 7, 120; 7, 133; 7, 142; 7, 337; 7, 348; 7, 355; 7, 366; 8, expression_st...
def qteProcessKey(self, event, targetObj): msgObj = QtmacsMessage((targetObj, event), None) msgObj.setSignalName('qtesigKeypressed') self.qteMain.qtesigKeypressed.emit(msgObj) if event.key() in (QtCore.Qt.Key_Shift, QtCore.Qt.Key_Control, QtCore.Qt.Key_Meta, Qt...
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, 18; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:killTimer; 12, argument_...
def timerEvent(self, event): self.killTimer(event.timerId()) if event.timerId() == self._qteTimerRunMacro: self._qteTimerRunMacro = None while True: if len(self._qteMacroQueue) > 0: (macroName, qteWidget, event) = self._qteMacroQueue.pop(0) ...
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): if isinstance(ofsApp, str): ofsApp = self.qteGetApp...
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): app = qteGetAppletFromWidget(widgetObj) if app is not None: if sip.isdeleted(app): msg = 'Ignored macro <b>{...
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): if windowObj is None: windowObj = self.qteActiveWindow() if windowObj is None: msg = 'Cannot determine the currently active window.' self.qteLog...
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, 32; 9, 71; 9, 79; 9, 85; 9, 91; 9, 99; 9, 107; 9, 115; 9, 1...
def qteAddMiniApplet(self, appletObj: QtmacsApplet): if self._qteMiniApplet is not None: msg = 'Cannot replace mini applet more than once.' self.qteLogger.warning(msg) return False if appletObj.layout() is None: appLayout = QtGui.QHBoxLayout() ...
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, 14; 5, 41; 5, 175; 5, 183; 5, 191; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifie...
def qteKillMiniApplet(self): if self._qteMiniApplet is None: return if not self.qteIsMiniApplet(self._qteMiniApplet): msg = ('Mini applet does not have its mini applet flag set.' ' Ignored.') self.qteLogger.warning(msg) if self._qteMiniApple...
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): if isinstance(applet, str): newAppObj = self.qteGetAppletHandle(applet) else: newAppObj = applet if windowObj is ...