sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 30; 2, function_name:send_array; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:socket; 5, default_parameter; 5, 6; 5, 7; 6, identifier:A; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:metadata; 10, None; 11, default_...
def send_array( socket, A=None, metadata=None, flags=0, copy=False, track=False, compress=None, chunksize=50 * 1000 * 1000 ): md = {} md['timestamp'] = datetime.datetime.now().isoformat() if metadata: md.update(metadata) if A is None: md['parts'] = 0 socke...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:recv_array; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:socket; 5, default_parameter; 5, 6; 5, 7; 6, identifier:flags; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:copy; 10, False; 11, default_paramete...
def recv_array( socket, flags=0, copy=False, track=False, poll=None, poll_timeout=10000 ): if poll is None: md = socket.recv_json(flags=flags) else: socks = dict(poll.poll(poll_timeout)) if socks.get(socket) == zmq.POLLIN: reply...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:reduce_fit; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:interface; 5, identifier:state; 6, identifier:label; 7, identifier:inp; 8, block; 8, 9; 8, 15; 8, 20; 8, 29; 8, 44; 8, 48; 8, 56; 8, 60; 8, 301; 8, 395; 8, 414; 8, 432; 8, 445; 8,...
def reduce_fit(interface, state, label, inp): from disco.util import kvgroup import numpy as np out = interface.output(0) fit_model = {"y_labels": [], "y_sum": 0, "iv": set()} combiner = {} means, variances = [], [] k_prev = "" for key, value in kvgroup(inp): k_split = key.split(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:map_predict; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:interface; 5, identifier:state; 6, identifier:label; 7, identifier:inp; 8, block; 8, 9; 8, 14; 8, 23; 8, 46; 8, 69; 8, 81; 8, 93; 9, import_statement; 9, 10; 10, aliased_import; ...
def map_predict(interface, state, label, inp): import numpy as np out = interface.output(0) continuous = [j for i, j in enumerate(state["X_indices"]) if state["X_meta"][i] == "c"] discrete = [j for i, j in enumerate(state["X_indices"]) if state["X_meta"][i] == "d"] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:json_dumps; 3, parameters; 3, 4; 4, identifier:obj; 5, block; 5, 6; 5, 28; 5, 46; 5, 55; 5, 164; 6, try_statement; 6, 7; 6, 24; 7, block; 7, 8; 8, return_statement; 8, 9; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:json...
def json_dumps(obj): try: return json.dumps(obj, indent=2, sort_keys=True, allow_nan=False) except ValueError: pass json_str = json.dumps(obj, indent=2, sort_keys=True, allow_nan=True) json_obj = json.loads(json_str) def do_map(obj): if obj is None: return None ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:add_json_mask; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:start; 6, identifier:method_str; 7, identifier:json_producer; 8, block; 8, 9; 8, 274; 9, function_definition; 9, 10; 9, 11; 9, 14; 10, function_name:send_js...
def add_json_mask(self, start, method_str, json_producer): def send_json(drh, rem_path): obj = json_producer(drh, rem_path) if not isinstance(obj, Response): obj = Response(obj) ctype = obj.get_ctype("application/json") code = obj.code ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:add_text_mask; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:start; 6, identifier:method_str; 7, identifier:text_producer; 8, block; 8, 9; 8, 267; 9, function_definition; 9, 10; 9, 11; 9, 14; 10, function_name:send_te...
def add_text_mask(self, start, method_str, text_producer): def send_text(drh, rem_path): text = text_producer(drh, rem_path) if not isinstance(text, Response): text = Response(text) ctype = text.get_ctype("text/plain") code = text.code ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_token_obj; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:token; 6, default_parameter; 6, 7; 6, 8; 7, identifier:expire; 8, identifier:_token_default; 9, block; 9, 10; 9, 23; 9, 29; 9, 40; 10, if_statement; 10, 11; 10, 1...
def get_token_obj(self, token, expire=_token_default): if expire == _token_default: expire = self.get_default_token_expiration() now = get_time() until = now + expire if expire is not None else None with self._token_lock: first_valid = None for (pos, k...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:handle_cmd; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:cmd; 6, block; 6, 7; 6, 15; 6, 19; 6, 121; 6, 132; 6, 154; 6, 161; 6, 213; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:cmd; 10, call; 10, 11; ...
def handle_cmd(self, cmd): cmd = cmd.strip() segments = [] for s in cmd.split(): if s.startswith(' break segments.append(s) args = [] if not len(segments): return while segments: cur_cmd = "_".join(segments) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:handle_request; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 44; 5, 50; 5, 54; 5, 60; 5, 79; 5, 172; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:timeout; 9, call; 9, 10; 9, 15; 10, attribute; 10...
def handle_request(self): timeout = self.socket.gettimeout() if timeout is None: timeout = self.timeout elif self.timeout is not None: timeout = min(timeout, self.timeout) ctime = get_time() done_req = False shutdown_latency = self.shutdown_latency...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:info_gain_nominal; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:x; 5, identifier:y; 6, identifier:separate_max; 7, block; 7, 8; 7, 17; 7, 27; 7, 34; 7, 45; 7, 58; 7, 96; 7, 105; 7, 115; 7, 311; 8, expression_statement; 8, 9; 9, assignment; 9,...
def info_gain_nominal(x, y, separate_max): x_vals = np.unique(x) if len(x_vals) < 3: return None y_dist = Counter(y) h_y = h(y_dist.values()) dist, splits = nominal_splits(x, y, x_vals, y_dist, separate_max) indices, repeat = (range(1, len(dist)), 1) if len(dist) < 50 else (range(1, len(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_endpoints_using_catalog_api; 3, parameters; 3, 4; 3, 5; 4, identifier:domain; 5, identifier:token; 6, block; 6, 7; 6, 14; 6, 18; 6, 22; 6, 28; 6, 32; 6, 156; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:headers; ...
def get_endpoints_using_catalog_api(domain, token): headers = {"X-App-Token": token} uri = "http://api.us.socrata.com/api/catalog/v1?domains={0}&offset={1}&limit=1000" ret = [] endpoints_thus_far = set() offset = 0 while True: try: r = requests.get(uri.format(domain, offset),...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:stratify_by_scores; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:scores; 5, default_parameter; 5, 6; 5, 7; 6, identifier:goal_n_strata; 7, string:'auto'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:method; 10, string:'cum_sqrt_F'...
def stratify_by_scores(scores, goal_n_strata='auto', method='cum_sqrt_F', n_bins = 'auto'): available_methods = ['equal_size', 'cum_sqrt_F'] if method not in available_methods: raise ValueError("method argument is invalid") if (method == 'cum_sqrt_F') or (goal_n_strata == 'aut...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_target; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:target; 6, block; 6, 7; 6, 18; 6, 28; 6, 50; 6, 95; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:depth; 10, binary_operator:+; 10, 11; 10, 17;...
def _get_target(self, target): depth = target.count('.') + 1 parts = target.split('.', 1) for m in self.modules: if parts[0] == m.name: if depth < 3: return m for p in self.packages: if parts[0] == p.name: if dep...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:by_user; 3, parameters; 3, 4; 4, identifier:config; 5, block; 5, 6; 5, 12; 5, 18; 5, 25; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:client; 9, call; 9, 10; 9, 11; 10, identifier:Client; 11, argument_list; 12, expres...
def by_user(config): client = Client() client.prepare_connection() audit_api = API(client) CLI.parse_membership('Groups by User', audit_api.by_user())
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_sortkey; 3, parameters; 3, 4; 4, identifier:table; 5, block; 5, 6; 5, 20; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:wfs; 9, call; 9, 10; 9, 11; 10, identifier:WebFeatureService; 11, argument_list; 11, 12; 11, 1...
def get_sortkey(table): wfs = WebFeatureService(url=bcdata.OWS_URL, version="2.0.0") return sorted(wfs.get_schema("pub:" + table)["properties"].keys())[0]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:define_request; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:dataset; 5, default_parameter; 5, 6; 5, 7; 6, identifier:query; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:crs; 10, string:"epsg:4326"; 11, defa...
def define_request( dataset, query=None, crs="epsg:4326", bounds=None, sortby=None, pagesize=10000 ): table = validate_name(dataset) n = bcdata.get_count(table, query=query) chunks = math.ceil(n / pagesize) if chunks > 1 and not sortby: sortby = get_sortkey(table) param_dicts = [] fo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_sorted; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:resources; 6, block; 6, 7; 6, 11; 6, 48; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:tmp; 10, list:[]; 11, for_statement; 11, 12; 11, 13; 11,...
def _get_sorted(self, resources): tmp = [] for resource in resources: path = resource._path priority = path.count('/') * 10 - path.count('{') tmp.append((priority, resource)) return [resource for prio, resource in reversed(sorted(tmp))]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:find_new_posts_and_pages; 3, parameters; 3, 4; 4, identifier:db; 5, block; 5, 6; 5, 12; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:Q; 9, call; 9, 10; 9, 11; 10, identifier:Query; 11, argument_list; 12, for_statement...
def find_new_posts_and_pages(db): Q = Query() for root, dirs, files in os.walk(CONFIG['content_root']): for filename in sorted([f for f in files if f.endswith(('md', 'markdown'))]): fullpath = os.path.join(root, filename) _p = fullpath.split(CONFIG[...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_locations; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:filter_to_my_group; 7, False; 8, block; 8, 9; 8, 19; 8, 23; 8, 60; 8, 64; 8, 199; 9, expression_statement; 9, 10; 10, assignment; 10, ...
def get_locations(self, filter_to_my_group=False): resp = self._post('general-retrievelocations', 'locations') groups = {} if resp['groupinfo']: for group in resp['groupinfo']: groups[group['id']] = Group( name=group.get('na...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_image_url; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:image; 5, default_parameter; 5, 6; 5, 7; 6, identifier:dst_color; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:src_color; 10, None; 11, block; 11, 12; 11, 26; 11, 35; 11, ...
def _image_url(image, dst_color=None, src_color=None): if src_color and dst_color: if not Image: raise Exception("Images manipulation require PIL") file = StringValue(image).value path = None if callable(STATIC_ROOT): try: _file, _storage = list(STATIC_ROOT(file))...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:normalize_selectors; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:_selectors; 6, default_parameter; 6, 7; 6, 8; 7, identifier:extra_selectors; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:extra_parent...
def normalize_selectors(self, _selectors, extra_selectors=None, extra_parents=None): _selectors = _spaces_re.sub(' ', _selectors) if isinstance(extra_selectors, basestring): extra_selectors = extra_selectors.split(',') if isinstance(extra_parents, basestring): extra_paren...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:_get_properties; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 4, identifier:self; 5, identifier:rule; 6, identifier:p_selectors; 7, identifier:p_parents; 8, identifier:p_children; 9, identifier:scope; 10, iden...
def _get_properties(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr): prop, value = (_prop_split_re.split(c_property, 1) + [None])[:2] try: is_var = (c_property[len(prop)] == '=') except IndexError: is_var = False prop...
0, module; 0, 1; 1, ERROR; 1, 2; 1, 299; 2, function_definition; 2, 3; 2, 4; 2, 9; 3, function_name:link_with_parents; 4, parameters; 4, 5; 4, 6; 4, 7; 4, 8; 5, identifier:self; 6, identifier:parent; 7, identifier:c_selectors; 8, identifier:c_rules; 9, block; 9, 10; 9, 14; 9, 192; 9, 208; 10, expression_statement; 10, ...
def link_with_parents(self, parent, c_selectors, c_rules): parent_found = None for p_selectors, p_rules in self.parts.items(): _p_selectors, _, _ = p_selectors.partition(' extends ') _p_selectors = _p_selectors.split(',') new_selectors = set() found = Fals...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_extends; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 87; 5, 91; 5, 95; 6, for_statement; 6, 7; 6, 10; 6, 17; 7, pattern_list; 7, 8; 7, 9; 8, identifier:_selectors; 9, identifier:rules; 10, call; 10, 11; 10, 16; 11, attribu...
def parse_extends(self): for _selectors, rules in self.parts.items(): if ' extends ' in _selectors: selectors, _, parent = _selectors.partition(' extends ') parents = parent.split('&') del self.parts[_selectors] for parent in parents: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:scan; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:restrict; 6, block; 6, 7; 6, 189; 7, while_statement; 7, 8; 7, 9; 8, True; 9, block; 9, 10; 9, 14; 9, 18; 9, 74; 9, 105; 10, expression_statement; 10, 11; 11, assignment; 11, 12...
def scan(self, restrict): while True: best_pat = None best_pat_len = 0 for p, regexp in self.patterns: if restrict and p not in restrict and p not in self.ignore: continue m = regexp.match(self.input, self.pos) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:read_form_data; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 18; 5, 24; 6, if_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:processed_data; 10, block; 10, 11; 11, raise_statement; 11, 12; 12,...
def read_form_data(self): if self.processed_data: raise exceptions.AlreadyProcessed('The data has already been processed for this form') if self.readonly: return if request.method == self.method: if self.method == 'POST': data = request.form ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_imm_trans_setattr; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, identifier:value; 7, block; 7, 8; 7, 10; 7, 17; 7, 27; 8, expression_statement; 8, 9; 9, string:''' An immutable's transient setattr allows para...
def _imm_trans_setattr(self, name, value): ''' An immutable's transient setattr allows params to be set, and runs checks as they are. ''' params = _imm_param_data(self) dd = object.__getattribute__(self, '__dict__') if name in params: (_, tx_fn, arg_lists, check_fns, deps) = params[name]...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:verify_consistency; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:predictions; 5, identifier:scores; 6, identifier:proba; 7, identifier:opt_class; 8, block; 8, 9; 8, 25; 8, 40; 8, 55; 8, 70; 8, 85; 8, 100; 8, 115; 8, 132; 8, 149; 8, 207;...
def verify_consistency(predictions, scores, proba, opt_class): if predictions.shape != scores.shape: raise ValueError("predictions and scores arrays have inconsistent " + "dimensions.") n_class = scores.shape[1] if scores.ndim > 1 else 1 if proba is None: proba = np....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_call; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:context; 6, block; 6, 7; 6, 13; 6, 28; 6, 34; 6, 45; 6, 54; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:req; 10, attribute; 10, 11; 10, 12; 11, ide...
def _call(self, context): req = context.request if not req.has_key("method"): raise RpcException(ERR_INVALID_REQ, "Invalid Request. No 'method'.") method = req["method"] if method == "barrister-idl": return self.contract.idl_parsed iface_name, func_name = ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:validate; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:expected_type; 6, identifier:is_array; 7, identifier:val; 8, block; 8, 9; 8, 190; 9, if_statement; 9, 10; 9, 13; 9, 29; 9, 75; 9, 100; 9, 126; 9, 149; 9, 174; 10...
def validate(self, expected_type, is_array, val): if val == None: if expected_type.optional: return True, None else: return False, "Value cannot be null" elif is_array: if not isinstance(val, list): return self._type_err...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:validate; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:val; 6, block; 6, 7; 6, 25; 6, 90; 6, 99; 6, 132; 7, if_statement; 7, 8; 7, 14; 8, comparison_operator:is; 8, 9; 8, 13; 9, call; 9, 10; 9, 11; 10, identifier:type; 11, argum...
def validate(self, val): if type(val) is not dict: return False, "%s is not a dict" % (str(val)) for k, v in val.items(): field = self.field(k) if field: ok, msg = self.contract.validate(field, field.is_array, v) if not ok: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_struct; 3, parameters; 3, 4; 4, identifier:s; 5, block; 5, 6; 5, 12; 5, 20; 5, 33; 5, 37; 5, 41; 5, 45; 5, 92; 5, 96; 5, 100; 5, 104; 5, 108; 5, 207; 5, 211; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:docs; 9,...
def parse_struct(s): docs = s['comment'] code = '<span class="k">struct</span> <span class="gs">%s</span>' % s['name'] if s['extends']: code += ' extends <span class="gs">%s</span>' % s['extends'] code += ' {\n' namelen = 0 typelen = 0 for v in s["fields"]: tlen = len(format_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_interface; 3, parameters; 3, 4; 4, identifier:iface; 5, block; 5, 6; 5, 10; 5, 16; 5, 24; 5, 129; 5, 133; 5, 144; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sections; 9, list:[ ]; 10, expression_statement; 10,...
def parse_interface(iface): sections = [ ] docs = iface['comment'] code = '<span class="k">interface</span> <span class="gs">%s</span> {\n' % iface['name'] for v in iface["functions"]: func_code = ' <span class="nf">%s</span>(' % v['name'] i = 0 for p in v["params"]: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:run; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 18; 5, 24; 5, 30; 5, 37; 5, 60; 5, 80; 5, 86; 5, 94; 5, 101; 5, 211; 5, 218; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:model; 9, attribute; 9,...
def run(self): model = self.model configfile = self.configfile interval = self.interval sockets = self.sockets model.initialize(configfile) if model.state == 'pause': logger.info( "model initialized and started in pause mode, waiting for reques...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:save; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 185; 10, if_statement; 10, 11; 10, 14; 11, attribute; 11, 1...
def save(self, *args, **kwargs): if self.publication: publication = self.publication if not self.title: self.title = publication.title if not self.subtitle: first_author = publication.first_author if first_author == publication....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:cmd; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:send; 5, identifier:msg; 6, identifier:args; 7, block; 7, 8; 7, 20; 7, 26; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:implements; 11, list:['the golden gate bri...
def cmd(send, msg, args): implements = ['the golden gate bridge', 'a large trout', 'a clue-by-four', 'a fresh haddock', 'moon', 'an Itanium', 'fwilson', 'a wombat'] methods = ['around a bit', 'upside the head'] if not msg: channel = args['target'] if args['target'] != 'private' else args['config']['...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:cmd; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:send; 5, identifier:msg; 6, identifier:args; 7, block; 7, 8; 7, 18; 7, 24; 7, 53; 7, 79; 7, 96; 7, 113; 7, 119; 7, 125; 7, 144; 7, 155; 8, if_statement; 8, 9; 8, 11; 9, not_operator; 9, 10; 10...
def cmd(send, msg, args): if not msg: send("Invalid Syntax.") return char = msg[0] msg = [x.replace(r'\/', '/') for x in re.split(r'(?<!\\)\%s' % char, msg[1:], maxsplit=2)] if len(msg) == 2 and args['config']['feature'].getboolean('lazyregex'): msg.append('') if not msg or l...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_add_single_session_to_to_ordered_dict; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:d; 6, identifier:dataset_index; 7, identifier:recommended_only; 8, block; 8, 9; 9, for_statement; 9, 10; 9, 13; 9, 19; 10, pattern_...
def _add_single_session_to_to_ordered_dict(self, d, dataset_index, recommended_only): for model_index, model in enumerate(self.models): show_null = False if recommended_only: if self.recommendation_enabled: if self.recommended_model is None: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_group_models; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 99; 5, 127; 5, 146; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:od; 9, call; 9, 10; 9, 11; 10, identifier:OrderedDict; 11, argument_li...
def _group_models(self): od = OrderedDict() for i, model in enumerate(self.models): output = getattr(model, "output", {}) if output.get("AIC") and output.get("BMD") and output["BMD"] > 0: key = "{}-{}".format(output["AIC"], output["BMD"]) if key in...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:random_stats; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:all_stats; 6, identifier:race; 7, identifier:ch_class; 8, block; 8, 9; 8, 13; 8, 17; 8, 38; 8, 42; 8, 135; 9, expression_statement; 9, 10; 10, assignment; 10...
def random_stats(self, all_stats, race, ch_class): stats = [] res = {} for s in all_stats: stats.append(s['stat']) res[s['stat']] = 0 cur_stat = 0 for stat in stats: for ndx, i in enumerate(self.classes.dat): if i['name'] == ch_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:palette; 3, parameters; 3, 4; 3, 5; 4, identifier:fg; 5, default_parameter; 5, 6; 5, 7; 6, identifier:bg; 7, unary_operator:-; 7, 8; 8, integer:1; 9, block; 9, 10; 9, 24; 9, 38; 9, 52; 9, 76; 9, 94; 9, 134; 9, 174; 9, 187; 10, if_statement; 10,...
def palette(fg, bg=-1): if not hasattr(palette, "counter"): palette.counter = 1 if not hasattr(palette, "selections"): palette.selections = {} selection = "%s%s" % (str(fg), str(bg)) if not selection in palette.selections: palette.selections[selection] = palette.counter p...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:coordinate; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:panes; 7, list:[]; 8, default_parameter; 8, 9; 8, 10; 9, identifier:index; 10, integer:0; 11, block; 11, 12; 11, 16; 12, expressio...
def coordinate(self, panes=[], index=0): y = 0 for i, element in enumerate(self.panes): x = 0 if isinstance(element, list): current_height = 0 for j, pane in enumerate(element): if pane.hidden: continue curre...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:_MakePackagePages; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:package; 6, default_parameter; 6, 7; 6, 8; 7, identifier:showprivate; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:nested; 11, F...
def _MakePackagePages(self, package, showprivate=False, nested=False, showinh=False): def checkNoNested(mod): try: all = mod.__all__ except AttributeError: return False mems = inspect.getmembers(mod, inspect.ismodule) mems = [m for ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:_DocPackageFromTop; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:packages; 6, default_parameter; 6, 7; 6, 8; 7, identifier:showprivate; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:showinh; 11, False...
def _DocPackageFromTop(self, packages, showprivate=False, showinh=False): appIndex = '' if not isinstance(packages, list): packages = [packages] if os.path.exists('content'): shutil.rmtree('content') os.makedirs('content') appIndex += r''' .. toctree:: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:cmd; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:send; 5, identifier:msg; 6, identifier:args; 7, block; 7, 8; 7, 27; 7, 40; 7, 81; 7, 93; 7, 97; 7, 101; 7, 163; 7, 178; 8, if_statement; 8, 9; 8, 20; 9, not_operator; 9, 10; 10, call; 10, 11; ...
def cmd(send, msg, args): if not args['config']['feature'].getboolean('hooks'): send("Hooks are disabled, and this command depends on hooks. Please contact the bot admin(s).") return if args['type'] == 'privmsg': send("Note-passing should be done in public.") return try: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:add_category; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:category; 6, block; 6, 7; 6, 9; 7, expression_statement; 7, 8; 8, string:''' Add unicode category to set Unicode categories are strings like 'Ll', 'Lu', ...
def add_category(self, category): ''' Add unicode category to set Unicode categories are strings like 'Ll', 'Lu', 'Nd', etc. See `unicodedata.category()` ''' if category == sre.CATEGORY_DIGIT: self._categories |= UNICODE_DIGIT_CATEGORIES elif category ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_estimate_free; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 32; 5, 40; 5, 47; 5, 60; 5, 67; 5, 80; 5, 94; 5, 102; 5, 114; 5, 120; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:capacity_deferred; ...
def _estimate_free(self): capacity_deferred = self.channel.total_capacity() open_tasks_deferred = self.channel.tasks(state=[task_states.OPEN]) avg_delta_deferred = self.estimate_duration() deferreds = [capacity_deferred, open_tasks_deferred, avg_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:package; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 21; 5, 37; 5, 52; 5, 67; 5, 75; 5, 82; 5, 164; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:==; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identif...
def package(self): if self.method == 'buildNotification': return self.params[1]['name'] if self.method in ('createImage', 'image', 'livecd'): return self.params[0] if self.method == 'indirectionimage': return self.params[0]['name'] if self.method not i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:is_admin; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:send; 6, identifier:nick; 7, default_parameter; 7, 8; 7, 9; 8, identifier:required_role; 9, string:'admin'; 10, block; 10, 11; 10, 17; 11, if_statement; 11, 12;...
def is_admin(self, send, nick, required_role='admin'): if not required_role: return True with self.db.session_scope() as session: admin = session.query(orm.Permissions).filter(orm.Permissions.nick == nick).first() if admin is None: return False ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:do_mode; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:target; 6, identifier:msg; 7, identifier:nick; 8, identifier:send; 9, block; 9, 10; 9, 21; 9, 84; 9, 138; 10, expression_statement; 10, 11; 11, assignment; ...
def do_mode(self, target, msg, nick, send): mode_changes = irc.modes.parse_channel_modes(msg) with self.data_lock: for change in mode_changes: if change[1] == 'v': self.voiced[target][change[2]] = True if change[0] == '+' else False if chan...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:do_kick; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:send; 6, identifier:target; 7, identifier:nick; 8, identifier:msg; 9, default_parameter; 9, 10; 9, 11; 10, identifier:slogan; 11, True; 12, block; 12...
def do_kick(self, send, target, nick, msg, slogan=True): if not self.kick_enabled: return if target not in self.channels: send("%s: you're lucky, private message kicking hasn't been implemented yet." % nick) return with self.data_lock: ops = [k for...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:handle_msg; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:c; 6, identifier:e; 7, block; 7, 8; 7, 36; 7, 64; 7, 77; 7, 106; 7, 137; 7, 148; 7, 160; 7, 178; 7, 196; 7, 227; 7, 245; 7, 276; 7, 294; 7, 305; 7, 313; 7, 329; 7, 3...
def handle_msg(self, c, e): if e.type not in ['authenticate', 'error', 'join', 'part', 'quit']: nick = e.source.nick else: nick = e.source if e.arguments is None: msg = "" else: msg = " ".join(e.arguments).strip() target = nick if e...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:cmd; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:send; 5, identifier:msg; 6, identifier:args; 7, block; 7, 8; 7, 14; 7, 33; 7, 67; 7, 77; 7, 87; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:nick; 11, subscript; ...
def cmd(send, msg, args): nick = args['nick'] channel = args['target'] if args['target'] != 'private' else args['config']['core']['channel'] levels = { 1: 'Whirr...', 2: 'Vrrm...', 3: 'Zzzzhhhh...', 4: 'SHFRRRRM...', 5: 'GEEEEZZSH...', 6: 'PLAAAAIIID...', ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:cmdloop; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:intro; 7, None; 8, block; 8, 9; 8, 11; 8, 17; 8, 65; 9, expression_statement; 9, 10; 10, string:''' Override the command loop to handle Ctrl...
def cmdloop(self, intro=None): ''' Override the command loop to handle Ctrl-C. ''' self.preloop() if self.use_rawinput and self.completekey: try: import readline self.old_completer = readline.get_completer() readline.set_completer(self....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:free; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:local_path; 6, block; 6, 7; 6, 9; 6, 17; 6, 27; 6, 35; 6, 45; 6, 52; 6, 61; 6, 72; 6, 83; 6, 93; 6, 131; 6, 140; 6, 288; 7, expression_statement; 7, 8; 8, string:''' Stop ...
def free(self, local_path): ''' Stop synchronization of local_path ''' config = self.get_config() folder = st_util.find_folder_with_path(local_path, config) self.delete_folder(local_path, config) pruned = st_util.prune_devices(folder, config) self.set_config(config) if pruned: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_package_update_list; 3, parameters; 3, 4; 3, 5; 4, identifier:package_name; 5, identifier:version; 6, block; 6, 7; 6, 18; 6, 25; 6, 33; 6, 37; 6, 41; 6, 45; 6, 49; 6, 53; 6, 57; 6, 61; 6, 65; 6, 69; 6, 284; 6, 310; 6, 321; 7, expression_sta...
def get_package_update_list(package_name, version): package_version = semantic_version.Version.coerce(version) package_data = get_pypi_package_data(package_name) version_data = get_pypi_package_data(package_name, version) current_release = '' current_release_license = '' latest_release = '' ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:page_location_template; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 26; 5, 38; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:cycle; 9, attribute; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, ...
def page_location_template(self): cycle = self.election_day.cycle.name model_class = self.model_type.model_class() if model_class == ElectionDay: return "/{}/".format(cycle) if model_class == Office: if self.jurisdiction: if self.division_level.nam...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_ask; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:answers; 6, block; 6, 7; 6, 38; 7, if_statement; 7, 8; 7, 15; 7, 28; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, 14; 11, attribute; 11, 12; 11...
def _ask(self, answers): if isinstance(self.validator, list): for v in self.validator: v.answers = answers else: self.validator.answers = answers while(True): q = self.question % answers if not self.choices(): logger...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:_annotate_fn_args; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 11; 4, identifier:stack; 5, identifier:fn_opname; 6, identifier:nargs; 7, default_parameter; 7, 8; 7, 9; 8, identifier:nkw; 9, unary_operator:-; 9, 10; 10, integer:1; 11, default_par...
def _annotate_fn_args(stack, fn_opname, nargs, nkw=-1, consume_fn_name=True): kwarg_names = [] if nkw == -1: if sys.version_info[0] < 3: nargs, nkw = (nargs % 256, 2 * nargs // 256) else: if fn_opname == 'CALL_FUNCTION_KW': if qj._DEBUG_QJ: assert len(stack) and stack[-1].opnam...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:generate_mediation_matrix; 3, parameters; 3, 4; 4, identifier:dsm; 5, block; 5, 6; 5, 12; 5, 18; 5, 26; 5, 37; 5, 52; 5, 70; 5, 385; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:cat; 9, attribute; 9, 10; 9, 11; 10, id...
def generate_mediation_matrix(dsm): cat = dsm.categories ent = dsm.entities size = dsm.size[0] if not cat: cat = ['appmodule'] * size packages = [e.split('.')[0] for e in ent] mediation_matrix = [[0 for _ in range(size)] for _ in ra...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:check; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:dsm; 6, default_parameter; 6, 7; 6, 8; 7, identifier:independence_factor; 8, integer:5; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs; 11, block; 11, 1...
def check(self, dsm, independence_factor=5, **kwargs): least_common_mechanism = False message = '' data = dsm.data categories = dsm.categories dsm_size = dsm.size[0] if not categories: categories = ['appmodule'] * dsm_size dependent_module_number = [] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:abstract; 3, parameters; 3, 4; 4, identifier:class_; 5, block; 5, 6; 5, 20; 5, 24; 5, 31; 5, 63; 5, 69; 6, if_statement; 6, 7; 6, 14; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:inspect; 11, identifie...
def abstract(class_): if not inspect.isclass(class_): raise TypeError("@abstract can only be applied to classes") abc_meta = None class_meta = type(class_) if class_meta not in (_ABCMetaclass, _ABCObjectMetaclass): if class_meta is type: abc_meta = _ABCMetaclass elif ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:final; 3, parameters; 3, 4; 4, identifier:arg; 5, block; 5, 6; 5, 41; 5, 54; 5, 60; 6, if_statement; 6, 7; 6, 13; 6, 29; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:inspect; 10, identifier:isclass; 11, argument_list; 11, 12; ...
def final(arg): if inspect.isclass(arg): if not isinstance(arg, ObjectMetaclass): raise ValueError("@final can only be applied to a class " "that is a subclass of Object") elif not is_method(arg): raise TypeError("@final can only be applied to classes or ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:override; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:base; 6, identifier:ABSENT; 7, block; 7, 8; 7, 12; 7, 45; 7, 55; 7, 71; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:arg; 11, identifie...
def override(base=ABSENT): arg = base if inspect.isfunction(arg) or isinstance(arg, NonInstanceMethod): _OverrideDecorator.maybe_signal_classmethod(arg) decorator = _OverrideDecorator(None) return decorator(arg) if arg is ABSENT: return _OverrideDecorator(None) if is_clas...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_index; 3, parameters; 3, 4; 3, 6; 4, list_splat_pattern; 4, 5; 5, identifier:args; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 19; 8, 29; 8, 143; 8, 150; 8, 164; 8, 168; 9, expression_statement; 9, 10; 10, assig...
def _index(*args, **kwargs): start = kwargs.pop('start', 0) step = kwargs.pop('step', 1) if len(args) == 2: elem, list_ = args ensure_sequence(list_) predicate = lambda item: item == elem else: ensure_keyword_args(kwargs, mandatory=('in_',), op...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:tally_poll; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 14; 5, 26; 5, 35; 5, 45; 5, 52; 5, 63; 5, 87; 5, 104; 5, 113; 5, 130; 5, 170; 5, 176; 5, 185; 5, 211; 5, 218; 5, 226; 6, if_statement; 6, 7; 6, 11; 7, not_operator; 7, 8; 8...
def tally_poll(args): if not args.msg: return "Syntax: !vote tally <pollnum>" if not args.msg.isdigit(): return "Not A Valid Positive Integer." pid = int(args.msg) poll = get_open_poll(args.session, pid) if poll is None: return "That poll doesn't exist or was deleted. Use !po...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_setup_pages; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:config; 6, block; 6, 7; 6, 13; 6, 19; 6, 25; 6, 31; 6, 38; 6, 42; 6, 46; 6, 80; 6, 90; 6, 102; 7, import_from_statement; 7, 8; 7, 11; 8, dotted_name; 8, 9; 8, 10; 9, iden...
def _setup_pages(cls, config): from cms.exceptions import NoHomeFound from cms.models import Page from cms.utils import get_language_list from django.conf import settings from django.utils.translation import override app_page = None get_url = False if geta...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:pretty_description; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:description; 5, default_parameter; 5, 6; 5, 7; 6, identifier:wrap_at; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:indent; 10, integer:0; 11, block; 11, 12; 11, 45...
def pretty_description(description, wrap_at=None, indent=0): if wrap_at is None or wrap_at < 0: width = console_width(default=79) if wrap_at is None: wrap_at = width else: wrap_at += width indent = ' ' * indent text_wrapper = textwrap.TextWrapper( widt...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 10; 3, 13; 3, 16; 4, identifier:term; 5, default_parameter; 5, 6; 5, 7; 6, identifier:category; 7, attribute; 7, 8; 7, 9; 8, identifier:Categories; 9, identifier:ALL; 10, default_parameter; 10, 11; 10, 12;...
def search(term, category=Categories.ALL, pages=1, sort=None, order=None): s = Search() s.search(term=term, category=category, pages=pages, sort=sort, order=order) return s
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:popular; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:category; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:sortOption; 9, string:"title"; 10, block; 10, 11; 10, 17; 10, 25; 11, expression_statement; ...
def popular(category=None, sortOption = "title"): s = Search() s.popular(category, sortOption) return s
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:recent; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:category; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:pages; 9, integer:1; 10, default_parameter; 10, 11; 10, 12; 11, identifier:sort...
def recent(category=None, pages=1, sort=None, order=None): s = Search() s.recent(category, pages, sort, order) return s
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:pick_action_todo; 3, parameters; 4, block; 4, 5; 4, 67; 5, for_statement; 5, 6; 5, 9; 5, 13; 6, pattern_list; 6, 7; 6, 8; 7, identifier:ndx; 8, identifier:todo; 9, call; 9, 10; 9, 11; 10, identifier:enumerate; 11, argument_list; 11, 12; 12, ide...
def pick_action_todo(): for ndx, todo in enumerate(things_to_do): if roll_dice(todo["chance"]): cur_act = actions[get_action_by_name(todo["name"])] if todo["WHERE_COL"] == "energy" and my_char["energy"] > todo["WHERE_VAL"]: return cur_act if todo["WHERE_CO...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:select; 3, parameters; 3, 4; 3, 5; 4, identifier:soup; 5, identifier:selector; 6, block; 6, 7; 6, 15; 6, 20; 6, 266; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:tokens; 10, call; 10, 11; 10, 14; 11, attribute; 11, 1...
def select(soup, selector): tokens = selector.split() current_context = [soup] for token in tokens: m = attribselect_re.match(token) if m: tag, attribute, operator, value = m.groups() if not tag: tag = True checker = attribute_checker(opera...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:try_; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:block; 5, default_parameter; 5, 6; 5, 7; 6, identifier:except_; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:else_; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, i...
def try_(block, except_=None, else_=None, finally_=None): ensure_callable(block) if not (except_ or else_ or finally_): raise TypeError("at least one of `except_`, `else_` or `finally_` " "functions must be provided") if else_ and not except_: raise TypeError("`else_`...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:replace_u_end_day; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:day; 5, identifier:year; 6, identifier:month; 7, block; 7, 8; 7, 17; 7, 24; 7, 36; 7, 58; 7, 75; 7, 109; 7, 128; 7, 152; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 1...
def replace_u_end_day(day, year, month): day = day.lstrip('-') year = int(year) month = int(month.lstrip('-')) if day == 'uu' or day == '3u': return str(calendar.monthrange(year, month)[1]) if day == '0u' or day == '1u': return day.replace('u', '9') if day == '2u' or day == 'u9':...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:zero_year_special_case; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:from_date; 5, identifier:to_date; 6, identifier:start; 7, identifier:end; 8, block; 8, 9; 9, if_statement; 9, 10; 9, 17; 9, 240; 9, 251; 10, boolean_operator:and; 10, ...
def zero_year_special_case(from_date, to_date, start, end): if start == 'pos' and end == 'pos': if from_date.startswith('0000') and not to_date.startswith('0000'): return True if not from_date.startswith('0000') and to_date.startswith('0000'): return False if from_dat...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:is_valid_interval; 3, parameters; 3, 4; 4, identifier:edtf_candidate; 5, block; 5, 6; 5, 10; 5, 14; 5, 22; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:from_date; 9, None; 10, expression_statement; 10, 11; 11, assignm...
def is_valid_interval(edtf_candidate): from_date = None to_date = None end, start = 'pos', 'pos' if edtf_candidate.count('/') == 1: edtf_candidate = replace_all(edtf_candidate, interval_replacements) edtf_candidate = re.sub(U_PATTERN, replace_u, edtf_candidate) parts = edtf_candi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:template; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:page; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:layout; 9, None; 10, dictionary_splat_pattern; 10, 11; 11, identifier:kwargs; 12, block;...
def template(page=None, layout=None, **kwargs): pkey = "_template_extends__" def decorator(f): if inspect.isclass(f): layout_ = layout or page extends = kwargs.pop("extends", None) if extends and hasattr(extends, pkey): items = getattr(extends, pkey).i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:getargspec; 3, parameters; 3, 4; 4, identifier:obj; 5, block; 5, 6; 5, 18; 5, 122; 5, 135; 5, 200; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 13; 8, pattern_list; 8, 9; 8, 10; 8, 11; 8, 12; 9, identifier:argnames; 10, identifier:var...
def getargspec(obj): argnames, varargs, varkw, _defaults = None, None, None, None if inspect.isfunction(obj) or inspect.ismethod(obj): argnames, varargs, varkw, _defaults = inspect.getargspec(obj) elif inspect.isclass(obj): if inspect.ismethoddescriptor(obj.__init__): argnames, v...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_find_overlap; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:queries; 5, identifier:client; 6, identifier:find_method; 7, identifier:get_method; 8, identifier:overlap_function; 9, block; 9, 10; 9, 14; 9, 69; 10, expression_statemen...
async def _find_overlap(queries, client, find_method, get_method, overlap_function): results = [] for query in queries: candidates = await getattr(client, find_method)(query) if not candidates: raise ValueError('no result found for {!r}'.format(query)) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:power; 3, parameters; 3, 4; 4, identifier:set_; 5, block; 5, 6; 5, 11; 5, 35; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:ensure_countable; 9, argument_list; 9, 10; 10, identifier:set_; 11, expression_statement; 11, 12; 12...
def power(set_): ensure_countable(set_) result = chain.from_iterable(combinations(set_, r) for r in xrange(len(set_) + 1)) return _harmonize_subset_types(set_, result)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:generate_pws_in_order; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:n; 6, default_parameter; 6, 7; 6, 8; 7, identifier:filter_func; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:N_max; 11, float:1e6; 1...
def generate_pws_in_order(self, n, filter_func=None, N_max=1e6): states = [(-1.0, helper.START)] p_min = 1e-9 / (n**2) ret = [] done = set() already_added_in_heap = set() while len(ret) < n and len(states) > 0: p, s = heapq.heappop(states) if p < 0...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:expand_seed; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:start_seed; 6, identifier:num_iterations; 7, identifier:val; 8, block; 8, 9; 8, 24; 8, 34; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 16; 11, attri...
def expand_seed(self, start_seed, num_iterations, val): self.grd.set_tile(start_seed[0], start_seed[1], val) cur_pos = [start_seed[0], start_seed[1]] while num_iterations > 0: num_iterations -= 1 for y in range(cur_pos[0]-randint(0,2), cur_pos[0] + randint(0,2)): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:denoise_grid; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:val; 6, default_parameter; 6, 7; 6, 8; 7, identifier:expand; 8, integer:1; 9, block; 9, 10; 9, 46; 9, 240; 10, expression_statement; 10, 11; 11, assignment; 11, 12...
def denoise_grid(self, val, expand=1): updated_grid = [[self.grd.get_tile(y,x) \ for x in range(self.grd.grid_width)] \ for y in range(self.grd.grid_height)] for row in range(self.grd.get_grid_height() - expand): for col in range(self.grd.get_g...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:run; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:num_runs; 6, identifier:show_trails; 7, identifier:log_file_base; 8, block; 8, 9; 8, 14; 8, 33; 8, 58; 8, 78; 8, 84; 8, 131; 8, 268; 9, expression_statement; 9, 10; 1...
def run(self, num_runs, show_trails, log_file_base): print("--------------------------------------------------") print("Starting Simulation - target = ", self.agent_list[0].target_y, self.agent_list[0].target_x) self.world.grd.set_tile(self.agent_list[0].target_y , self.agent_list[0].target_x , ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:merge; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:arg; 5, list_splat_pattern; 5, 6; 6, identifier:rest; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 19; 9, 25; 9, 37; 9, 41; 9, 71; 10, expression_statement; 1...
def merge(arg, *rest, **kwargs): ensure_keyword_args(kwargs, optional=('default',)) has_default = 'default' in kwargs if has_default: default = ensure_callable(kwargs['default']) unary_result = True if rest: fs = (ensure_callable(arg),) + tuple(imap(ensure_callable, rest)) un...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:cmd; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:send; 5, identifier:msg; 6, identifier:args; 7, block; 7, 8; 7, 27; 7, 33; 7, 44; 7, 52; 7, 62; 7, 72; 7, 87; 7, 115; 8, if_statement; 8, 9; 8, 20; 9, not_operator; 9, 10; 10, call; 10, 11; 10...
def cmd(send, msg, args): if not args['config']['feature'].getboolean('hooks'): send("Hooks are disabled, and this command depends on hooks. Please contact the bot admin(s).") return session = args['db'] parser = arguments.ArgParser(args['config']) group = parser.add_mutually_exclusive_g...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:buildPrices; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:data; 5, default_parameter; 5, 6; 5, 7; 6, identifier:roles; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:regex; 10, identifier:default_price_regex; 11, def...
def buildPrices(data, roles=None, regex=default_price_regex, default=None, additional={}): ''' Create a dictionary with price information. Multiple ways are supported. :rtype: :obj:`dict`: keys are role as str, values are the prices as cent count''' if isinstance(dat...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:toTag; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:output; 6, block; 6, 7; 6, 9; 6, 18; 6, 41; 6, 64; 6, 87; 6, 110; 6, 133; 6, 155; 6, 178; 6, 207; 6, 308; 7, expression_statement; 7, 8; 8, string:''' This methods adds all dat...
def toTag(self, output): ''' This methods adds all data of this canteen as canteen xml tag to the given xml Document. :meth:`toXMLFeed` uses this method to create the XML Feed. So there is normally no need to call it directly. :param output: XML Document to which the data should ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 33; 2, function_name:AddAnalogShortIdMsecRecord; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 4, identifier:site_service; 5, identifier:tag; 6, identifier:time_value; 7, identifier:msec; 8, identifier:value; 9...
def AddAnalogShortIdMsecRecord(site_service, tag, time_value, msec, value, low_warn=False, high_warn=False, low_alarm=False, high_alarm=False, oor_low=False, oor_high=False, unreliable=False, manual=False): szService = c_char_p(site_service.encode('utf-8')) szPointId = c_char_p(tag.encode('utf-8')) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:update_node_ids; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sub_job_num; 7, None; 8, block; 8, 9; 8, 27; 8, 31; 8, 35; 8, 67; 8, 82; 8, 87; 8, 104; 8, 121; 8, 133; 9, expression_statement; 9, ...
def update_node_ids(self, sub_job_num=None): dag_id = '%s.%s' % (self.cluster_id, sub_job_num) if sub_job_num else str(self.cluster_id) job_delimiter = '+++' attr_delimiter = ';;;' format = [ '-format', '"%d' + attr_delimiter + '"', 'ClusterId', '-format', '"%v' +...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:concat_cols; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 14; 4, identifier:df1; 5, identifier:df2; 6, identifier:idx_col; 7, identifier:df1_cols; 8, identifier:df2_cols; 9, identifier:df1_suffix; 10, identifier:df2_suff...
def concat_cols(df1,df2,idx_col,df1_cols,df2_cols, df1_suffix,df2_suffix,wc_cols=[],suffix_all=False): df1=df1.set_index(idx_col) df2=df2.set_index(idx_col) if not len(wc_cols)==0: for wc in wc_cols: df1_cols=df1_cols+[c for c in df1.columns if wc in c] df...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:to_json; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:indent; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort_keys; 10, True; 11, block; 11, 12; 12, return_statement; 12, 1...
def to_json(self, indent=None, sort_keys=True): return json.dumps(self.to_dict(), indent=indent, sort_keys=sort_keys)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_validate_method_decoration; 3, parameters; 3, 4; 3, 5; 4, identifier:meta; 5, identifier:class_; 6, block; 6, 7; 6, 17; 6, 40; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:super_mro; 10, subscript; 10, 11; 10, 14; 1...
def _validate_method_decoration(meta, class_): super_mro = class_.__mro__[1:] own_methods = ((name, member) for name, member in class_.__dict__.items() if is_method(member)) for name, method in own_methods: shadowed_method, base_class = n...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_parse_status; 3, parameters; 3, 4; 4, identifier:bug_el; 5, block; 5, 6; 5, 12; 5, 40; 5, 57; 5, 74; 5, 97; 5, 109; 5, 121; 5, 133; 5, 145; 5, 168; 5, 191; 5, 214; 5, 239; 5, 264; 5, 285; 5, 302; 6, expression_statement; 6, 7; 7, assignment; 7...
def _parse_status(bug_el): bug = Bugreport() for field in ('originator', 'subject', 'msgid', 'package', 'severity', 'owner', 'summary', 'location', 'source', 'pending', 'forwarded'): setattr(bug, field, _parse_string_el(bug_el(field))) bug.date = datetime.utcfromt...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:set; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:attr; 6, identifier:value; 7, block; 7, 8; 7, 62; 7, 73; 7, 100; 7, 123; 7, 141; 7, 166; 7, 237; 8, function_definition; 8, 9; 8, 10; 8, 15; 9, function_name:escape_new_syn...
def set(self, attr, value): def escape_new_syntax(value, double_quote_escape='"'): value = str(value) value = value.replace("'", "''") value = value.replace('"', '%s"' % double_quote_escape) if ' ' in value or '\t' in value: value = "'%s'" % value ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_update_status; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sub_job_num; 7, None; 8, block; 8, 9; 8, 27; 8, 34; 8, 49; 8, 54; 8, 71; 8, 88; 8, 105; 8, 115; 8, 124; 8, 177; 8, 183; 8, 197; 8, 23...
def _update_status(self, sub_job_num=None): job_id = '%s.%s' % (self.cluster_id, sub_job_num) if sub_job_num else str(self.cluster_id) format = ['-format', '"%d"', 'JobStatus'] cmd = 'condor_q {0} {1} && condor_history {0} {1}'.format(job_id, ' '.join(format)) args = [cmd] out, e...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:mangle; 3, parameters; 3, 4; 4, identifier:text; 5, block; 5, 6; 5, 15; 5, 22; 5, 28; 5, 34; 5, 39; 5, 43; 5, 47; 5, 51; 5, 60; 5, 292; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:text_bytes; 9, call; 9, 10; 9, 13; 1...
def mangle(text): text_bytes = text.encode('utf-8') buff = BytesIO(text_bytes) mangled = BytesIO() last_tok = token.INDENT last_line = -1 last_col = 0 last_line_text = '' open_list_dicts = 0 tokens = tokenizer(buff.readline) for t, text, (line_s, col_s), (line_e, col_e), line in ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 1, 34; 2, function_name:get_array_from_hist2D; 3, parameters; 3, 4; 3, 8; 3, 13; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:hist; 6, type; 6, 7; 7, identifier:Hist; 8, typed_default_parameter; 8, 9; 8, 10; 8, 12; 9, identifier:set_zero_to_NaN; 10, type; 10,...
def get_array_from_hist2D(hist: Hist, set_zero_to_NaN: bool = True, return_bin_edges: bool = False) -> Tuple[np.ndarray, np.ndarray, np.ndarray]: shape = (hist.GetYaxis().GetNbins(), hist.GetXaxis().GetNbins()) hist_array = np.array([hist.GetBinContent(x) for x in range(1, hist.GetNcells()) if not hist.IsBinUnd...