1 | | input | is_correct | expected_cond | predicted_cond | score |
---|
2 | 0 | def stream_edit ( request, stream_id, response_format = "html" ) : <TAB> "Stream edit page" <TAB> user = request. user. profile <TAB> stream = get_object_or_404 ( MessageStream, pk = stream_id ) <TAB> if not request. user. profile. has_permission ( stream, mode = "w" ) : <TAB> <TAB> return user_denied ( <TAB> <TAB> <TAB> request, <TAB> <TAB> <TAB> message = "You don't have access to this Stream", <TAB> <TAB> <TAB> response_format = response_format, <TAB> <TAB> ) <TAB> if request. POST : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> form = MessageStreamForm ( user, request. POST, instance = stream ) <TAB> <TAB> <TAB> if form. is_valid ( ) : <TAB> <TAB> <TAB> <TAB> stream = form. save ( ) <TAB> <TAB> <TAB> <TAB> return HttpResponseRedirect ( <TAB> <TAB> <TAB> <TAB> <TAB> reverse ( "messaging_stream_view", args = [ stream. id ] ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return HttpResponseRedirect ( <TAB> <TAB> <TAB> <TAB> reverse ( "messaging_stream_view", args = [ stream. id ] ) <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> form = MessageStreamForm ( user, instance = stream ) <TAB> context = _get_default_context ( request ) <TAB> context. update ( { "form" : form, "stream" : stream } ) <TAB> return render_to_response ( <TAB> <TAB> "messaging/stream_edit", <TAB> <TAB> context, <TAB> <TAB> context_instance = RequestContext ( request ), <TAB> <TAB> response_format = response_format, <TAB> ) | False | 'cancel' not in request.POST | stream.id < 5 | 0.6595945358276367 |
3 | 1 | def _read_and_parse_includes ( self ) : <TAB> <TAB> included_files = { } <TAB> <TAB> forward_declarations = { } <TAB> files_seen = { } <TAB> for node in self. ast_list : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if node. system : <TAB> <TAB> <TAB> <TAB> filename = node. filename <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> module = self. _get_module ( node ) <TAB> <TAB> <TAB> <TAB> filename = module. filename <TAB> <TAB> <TAB> <TAB> _, ext = os. path. splitext ( filename ) <TAB> <TAB> <TAB> <TAB> if ext. lower ( )!= ".hxx" : <TAB> <TAB> <TAB> <TAB> <TAB> included_files [ filename ] = node, module <TAB> <TAB> <TAB> if is_cpp_file ( filename ) : <TAB> <TAB> <TAB> <TAB> self. _add_warning ( <TAB> <TAB> <TAB> <TAB> <TAB> "should not #include C++ source file '{}'". format ( node. filename ), <TAB> <TAB> <TAB> <TAB> <TAB> node, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if filename == self. filename : <TAB> <TAB> <TAB> <TAB> self. _add_warning ( "'{}' #includes itself". format ( node. filename ), node ) <TAB> <TAB> <TAB> if filename in files_seen : <TAB> <TAB> <TAB> <TAB> include_node = files_seen [ filename ] <TAB> <TAB> <TAB> <TAB> line_num = get_line_number ( self. metrics, include_node ) <TAB> <TAB> <TAB> <TAB> self. _add_warning ( <TAB> <TAB> <TAB> <TAB> <TAB> "'{}' already #included on line {}". format ( node. filename, line_num ), <TAB> <TAB> <TAB> <TAB> | False | isinstance(node, ast.Include) | node.filename | 0.6480394601821899 |
4 | 2 | def _get_list_key ( self, spaces, lines ) : <TAB> key_list = [ ] <TAB> parse_key = False <TAB> key, desc, ptype = None, "", None <TAB> param_spaces = 0 <TAB> for line in lines : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> curr_spaces = get_leading_spaces ( line ) <TAB> <TAB> if not param_spaces : <TAB> <TAB> <TAB> param_spaces = len ( curr_spaces ) <TAB> <TAB> if len ( curr_spaces ) == param_spaces : <TAB> <TAB> <TAB> if parse_key : <TAB> <TAB> <TAB> <TAB> key_list. append ( ( key, desc, ptype ) ) <TAB> <TAB> <TAB> if ":" in line : <TAB> <TAB> <TAB> <TAB> elems = line. split ( ":", 1 ) <TAB> <TAB> <TAB> <TAB> ptype = None <TAB> <TAB> <TAB> <TAB> key = elems [ 0 ]. strip ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if "(" in key and ")" in key : <TAB> <TAB> <TAB> <TAB> <TAB> tstart = key. index ( "(" ) + 1 <TAB> <TAB> <TAB> <TAB> <TAB> tend = key. index ( ")" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if "," in key : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> tend = key. index ( "," ) <TAB> <TAB> <TAB> <TAB> <TAB> ptype = key [ tstart : tend ]. strip ( ) <TAB> <TAB> <TAB> <TAB> <TAB> key = key [ : tstart - 1 ]. strip ( ) <TAB> <TAB> <TAB> <TAB> desc = elems [ 1 ]. strip ( ) <TAB> <TAB> <TAB> <TAB> parse_key = True <TAB> <TAB> < | False | len(line.strip()) == 0 | line.startswith(space) | 0.6560866832733154 |
5 | 3 | def search_host ( self, search_string ) : <TAB> results = [ ] <TAB> for host_entry in self. config_data : <TAB> <TAB> if host_entry. get ( "type" )!= "entry" : <TAB> <TAB> <TAB> continue <TAB> <TAB> if host_entry. get ( "host" ) == "*" : <TAB> <TAB> <TAB> continue <TAB> <TAB> searchable_information = host_entry. get ( "host" ) <TAB> <TAB> for key, value in six. iteritems ( host_entry. get ( "options" ) ) : <TAB> <TAB> <TAB> if isinstance ( value, list ) : <TAB> <TAB> <TAB> <TAB> value = " ". join ( value ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> value = str ( value ) <TAB> <TAB> <TAB> searchable_information += " " + value <TAB> <TAB> if search_string in searchable_information : <TAB> <TAB> <TAB> results. append ( host_entry ) <TAB> return results | False | isinstance(value, int) | isinstance(value, str) | 0.650113582611084 |
6 | 4 | def pop ( self, key : Union [ str, Enum ], default : Any = DEFAULT_VALUE_MARKER ) -> Any : <TAB> try : <TAB> <TAB> if self. _get_flag ( "readonly" ) : <TAB> <TAB> <TAB> raise ReadonlyConfigError ( "Cannot pop from read-only node" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ConfigTypeError ( "DictConfig in struct mode does not support pop" ) <TAB> <TAB> if self. _is_typed ( ) and self. _get_node_flag ( "struct" ) is not False : <TAB> <TAB> <TAB> raise ConfigTypeError ( <TAB> <TAB> <TAB> <TAB> f"{type_str(self._metadata.object_type)} (DictConfig) does not support pop" <TAB> <TAB> <TAB> ) <TAB> <TAB> key = self. _validate_and_normalize_key ( key ) <TAB> <TAB> node = self. _get_node ( key = key, validate_access = False ) <TAB> <TAB> if node is not None : <TAB> <TAB> <TAB> value = self. _resolve_with_default ( <TAB> <TAB> <TAB> <TAB> key = key, value = node, default_value = default <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> del self [ key ] <TAB> <TAB> <TAB> return value <TAB> <TAB> else : <TAB> <TAB> <TAB> if default is not DEFAULT_VALUE_MARKER : <TAB> <TAB> <TAB> <TAB> return default <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> full = self. _get_full_key ( key = key ) <TAB> <TAB> <TAB> <TAB> if full!= key : <TAB> <TAB> <TAB> <TAB> <TAB> raise ConfigKeyError ( f"Key not found: '{key}' (path: '{full}')" ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> raise ConfigKeyError ( f"Key not | False | self._get_flag('struct') | self._is_struct(key) | 0.6553546190261841 |
7 | 5 | def _key ( self, index ) : <TAB> len_self = len ( self ) <TAB> if<mask> : <TAB> <TAB> index += len_self <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise IndexError ( "deque index out of range" ) <TAB> elif index >= len_self : <TAB> <TAB> raise IndexError ( "deque index out of range" ) <TAB> diff = len_self - index - 1 <TAB> _cache_iterkeys = self. _cache. iterkeys <TAB> try : <TAB> <TAB> if index <= diff : <TAB> <TAB> <TAB> iter_keys = _cache_iterkeys ( ) <TAB> <TAB> <TAB> key = next ( islice ( iter_keys, index, index + 1 ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> iter_keys = _cache_iterkeys ( reverse = True ) <TAB> <TAB> <TAB> key = next ( islice ( iter_keys, diff, diff + 1 ) ) <TAB> except StopIteration : <TAB> <TAB> raise IndexError ( "deque index out of range" ) <TAB> return key | True | index < 0 | index < 0 | 0.675930380821228 |
8 | 6 | def convert ( src, dst ) : <TAB> """Convert keys in pycls pretrained RegNet models to mmdet style.""" <TAB> <TAB> regnet_model = torch. load ( src ) <TAB> blobs = regnet_model [ "model_state" ] <TAB> <TAB> state_dict = OrderedDict ( ) <TAB> converted_names = set ( ) <TAB> for key, weight in blobs. items ( ) : <TAB> <TAB> if "stem" in key : <TAB> <TAB> <TAB> convert_stem ( key, weight, state_dict, converted_names ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> convert_head ( key, weight, state_dict, converted_names ) <TAB> <TAB> elif key. startswith ( "s" ) : <TAB> <TAB> <TAB> convert_reslayer ( key, weight, state_dict, converted_names ) <TAB> <TAB> for key in blobs : <TAB> <TAB> if key not in converted_names : <TAB> <TAB> <TAB> print ( f"not converted: {key}" ) <TAB> <TAB> checkpoint = dict ( ) <TAB> checkpoint [ "state_dict" ] = state_dict <TAB> torch. save ( checkpoint, dst ) | False | 'head' in key | key.startswith(("head", "s") | 0.6630789041519165 |
9 | 7 | def run ( self, args, ** kwargs ) : <TAB> <TAB> if args. action : <TAB> <TAB> kwargs [ "action" ] = args. action <TAB> if args. status : <TAB> <TAB> kwargs [ "status" ] = args. status <TAB> if args. trigger_instance : <TAB> <TAB> kwargs [ "trigger_instance" ] = args. trigger_instance <TAB> if not args. showall : <TAB> <TAB> <TAB> <TAB> kwargs [ "parent" ] = "null" <TAB> if args. timestamp_gt : <TAB> <TAB> kwargs [ "timestamp_gt" ] = args. timestamp_gt <TAB> if args. timestamp_lt : <TAB> <TAB> kwargs [ "timestamp_lt" ] = args. timestamp_lt <TAB> if args. sort_order : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kwargs [ "sort_asc" ] = True <TAB> <TAB> elif args. sort_order in [ "desc", "descending" ] : <TAB> <TAB> <TAB> kwargs [ "sort_desc" ] = True <TAB> <TAB> include_attributes = self. _get_include_attributes ( args = args ) <TAB> if include_attributes : <TAB> <TAB> kwargs [ "include_attributes" ] = ",". join ( include_attributes ) <TAB> return self. manager. query_with_count ( limit = args. last, ** kwargs ) | False | args.sort_order in ['asc', 'ascending'] | args.sort_order in ['asc', 'descending'] | 0.6580512523651123 |
10 | 8 | def goToPrevMarkedHeadline ( self, event = None ) : <TAB> """Select the next marked node.""" <TAB> c = self <TAB> p = c. p <TAB> if not p : <TAB> <TAB> return <TAB> p. moveToThreadBack ( ) <TAB> wrapped = False <TAB> while 1 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> elif p : <TAB> <TAB> <TAB> p. moveToThreadBack ( ) <TAB> <TAB> elif wrapped : <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> wrapped = True <TAB> <TAB> <TAB> p = c. rootPosition ( ) <TAB> if not p : <TAB> <TAB> g. blue ( "done" ) <TAB> c. treeSelectHelper ( p ) | False | p and p.isMarked() | c.nodeIsBack() | 0.6556696891784668 |
11 | 9 | def read ( self, iprot ) : <TAB> if ( <TAB> <TAB> iprot. __class__ == TBinaryProtocol. TBinaryProtocolAccelerated <TAB> <TAB> and isinstance ( iprot. trans, TTransport. CReadableTransport ) <TAB> <TAB> and self. thrift_spec is not None <TAB> <TAB> and fastbinary is not None <TAB> ) : <TAB> <TAB> fastbinary. decode_binary ( self, iprot. trans, ( self. __class__, self. thrift_spec ) ) <TAB> <TAB> return <TAB> iprot. readStructBegin ( ) <TAB> while True : <TAB> <TAB> ( fname, ftype, fid ) = iprot. readFieldBegin ( ) <TAB> <TAB> if ftype == TType. STOP : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 0 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. success = [ ] <TAB> <TAB> <TAB> <TAB> ( _etype683, _size680 ) = iprot. readListBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i684 in xrange ( _size680 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _elem685 = iprot. readString ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. success. append ( _elem685 ) <TAB> <TAB> <TAB> <TAB> iprot. readListEnd ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 1 : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. o1 = MetaException ( ) <TAB> <TAB> <TAB> <TAB> self. o1. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> else : <TAB> <TAB> | False | ftype == TType.LIST | ftype == TType.ENUM | 0.6605467796325684 |
12 | 10 | def __iter__ ( self ) : <TAB> n_samples = self. image_dataset. _X_shape [ 0 ] <TAB> worker_info = torch. utils. data. get_worker_info ( ) <TAB> if worker_info is None : <TAB> <TAB> first_sample = 0 <TAB> <TAB> last_sample = n_samples <TAB> else : <TAB> <TAB> first_sample = worker_info. id * n_samples // worker_info. num_workers <TAB> <TAB> last_sample = ( worker_info. id + 1 ) * n_samples // worker_info. num_workers <TAB> for epoch in range ( self. epochs ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> order = first_sample + np. arange ( last_sample - first_sample ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> random = np. random. RandomState ( epoch ) <TAB> <TAB> <TAB> order = random. permutation ( n_samples ) [ first_sample : last_sample ] <TAB> <TAB> if self. batch_size is None : <TAB> <TAB> <TAB> for i in order : <TAB> <TAB> <TAB> <TAB> yield ( <TAB> <TAB> <TAB> <TAB> <TAB> self. image_dataset. _get_image ( self. image_dataset. _X, i ), <TAB> <TAB> <TAB> <TAB> <TAB> self. image_dataset. _get_image ( self. image_dataset. _y, i ), <TAB> <TAB> <TAB> <TAB> <TAB> self. image_dataset. _w [ i ], <TAB> <TAB> <TAB> <TAB> <TAB> self. image_dataset. _ids [ i ], <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> for i in range ( 0, len ( order ), self. batch_size ) : <TAB> <TAB> <TAB> <TAB> indices = order [ i : i + self. batch_size ] <TAB> | False | self.deterministic | self.training | 0.6621298789978027 |
13 | 11 | def on_leave ( self, instance ) : <TAB> """Called when the mouse cursor goes outside the button of stack.""" <TAB> if self. state == "open" : <TAB> <TAB> for widget in self. children : <TAB> <TAB> <TAB> if isinstance ( widget, MDFloatingLabel ) and self. hint_animation : <TAB> <TAB> <TAB> <TAB> Animation. cancel_all ( widget ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> Animation ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _canvas_width = 0, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _padding_right = 0, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> d = self. opening_time, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> t = self. opening_transition, <TAB> <TAB> <TAB> <TAB> <TAB> ). start ( instance ) <TAB> <TAB> <TAB> <TAB> <TAB> if self. hint_animation : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> Animation ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> opacity = 0, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> d = 0.1, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> t = self. opening_transition, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ). start ( widget ) <TAB> <TAB> <TAB> <TAB> <TAB> break | False | self.data[instance.icon] == widget.text | self.opening_time | 0.6539744138717651 |
14 | 12 | def reset_init_only_vars ( <TAB> self, info : TypeInfo, attributes : List [ DataclassAttribute ] ) -> None : <TAB> """Remove init-only vars from the class and reset init var declarations.""" <TAB> for attr in attributes : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if attr. name in info. names : <TAB> <TAB> <TAB> <TAB> del info. names [ attr. name ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> assert attr. is_init_var <TAB> <TAB> <TAB> for stmt in info. defn. defs. body : <TAB> <TAB> <TAB> <TAB> if isinstance ( stmt, AssignmentStmt ) and stmt. unanalyzed_type : <TAB> <TAB> <TAB> <TAB> <TAB> lvalue = stmt. lvalues [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( lvalue, NameExpr ) and lvalue. name == attr. name : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> lvalue. node = None | False | attr.is_init_var | isinstance(attr, Variable) | 0.6558442115783691 |
15 | 13 | def __call__ ( self, request ) : <TAB> if ( <TAB> <TAB> request. path. startswith ( get_script_prefix ( ) + "control" ) <TAB> <TAB> and request. user. is_authenticated <TAB> ) : <TAB> <TAB> if is_hijacked ( request ) : <TAB> <TAB> <TAB> hijack_history = request. session. get ( "hijack_history", False ) <TAB> <TAB> <TAB> hijacker = get_object_or_404 ( User, pk = hijack_history [ 0 ] ) <TAB> <TAB> <TAB> ss = hijacker. get_active_staff_session ( <TAB> <TAB> <TAB> <TAB> request. session. get ( "hijacker_session" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> ss. logs. create ( <TAB> <TAB> <TAB> <TAB> <TAB> url = request. path, method = request. method, impersonating = request. user <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ss = request. user. get_active_staff_session ( request. session. session_key ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> ss. logs. create ( url = request. path, method = request. method ) <TAB> response = self. get_response ( request ) <TAB> return response | False | ss | not ss.is_authenticated() | 0.6921205520629883 |
16 | 14 | def test_other_attributes ( self ) : <TAB> print_test_name ( "TEST OTHER ATTRIBUTES" ) <TAB> correct = 0 <TAB> props = { } <TAB> for example in OTHER_PROP_EXAMPLES : <TAB> <TAB> original_schema = schema. parse ( example. schema_string ) <TAB> <TAB> round_trip_schema = schema. parse ( str ( original_schema ) ) <TAB> <TAB> self. assertEqual ( original_schema. other_props, round_trip_schema. other_props ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> field_props = 0 <TAB> <TAB> <TAB> for f in original_schema. fields : <TAB> <TAB> <TAB> <TAB> if f. other_props : <TAB> <TAB> <TAB> <TAB> <TAB> props. update ( f. other_props ) <TAB> <TAB> <TAB> <TAB> <TAB> field_props += 1 <TAB> <TAB> <TAB> self. assertEqual ( field_props, len ( original_schema. fields ) ) <TAB> <TAB> if original_schema. other_props : <TAB> <TAB> <TAB> props. update ( original_schema. other_props ) <TAB> <TAB> <TAB> correct += 1 <TAB> for k in props : <TAB> <TAB> v = props [ k ] <TAB> <TAB> if k == "cp_boolean" : <TAB> <TAB> <TAB> self. assertEqual ( type ( v ), bool ) <TAB> <TAB> elif k == "cp_int" : <TAB> <TAB> <TAB> self. assertEqual ( type ( v ), int ) <TAB> <TAB> elif k == "cp_object" : <TAB> <TAB> <TAB> self. assertEqual ( type ( v ), dict ) <TAB> <TAB> elif k == "cp_float" : <TAB> <TAB> <TAB> self. assertEqual ( type ( v ), float ) <TAB> <TAB> elif k == "cp_array" : <TAB> <TAB> <TAB> self. assertEqual ( type ( v ), list ) <TAB> self. | False | original_schema.type == 'record' | original_schema.fields | 0.6533740162849426 |
17 | 15 | def test_no_unknown_state_fields_in_mp_events ( ) : <TAB> all_fields = ins. MediaPlayerStateIterator. fields. keys ( ) <TAB> ok = True <TAB> for evname in ins. mp_events : <TAB> <TAB> if evname == "version" : <TAB> <TAB> <TAB> continue <TAB> <TAB> for name in ins. mp_events [ evname ] [ "update_names" ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> "Error, in evname '%s' unknown field '%s' in 'update_names'" <TAB> <TAB> <TAB> <TAB> <TAB> % ( evname, name ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ok = False <TAB> <TAB> for name in ins. mp_events [ evname ] [ "other_fields" ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> "Error, in evname '%s' unknown field '%s' in 'other_fields'" <TAB> <TAB> <TAB> <TAB> <TAB> % ( evname, name ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ok = False <TAB> if ok : <TAB> <TAB> print ( "test_no_unknown_state_fields_in_mp_events: passed" ) | False | name not in all_fields | all_fields | 0.6561712026596069 |
18 | 16 | def __call__ ( self, A, a, order = 10, mu = 0.1, s = 0.5 ) : <TAB> <TAB> print ( "Chebyshev Series -----------------" ) <TAB> if order == 1 : <TAB> <TAB> return a <TAB> node_number = a. shape [ 0 ] <TAB> A = sp. eye ( node_number ) + A <TAB> DA = preprocessing. normalize ( A, norm = "l1" ) <TAB> L = sp. eye ( node_number ) - DA <TAB> M = L - mu * sp. eye ( node_number ) <TAB> Lx0 = a <TAB> Lx1 = M. dot ( a ) <TAB> Lx1 = 0.5 * M. dot ( Lx1 ) - a <TAB> conv = iv ( 0, s ) * Lx0 <TAB> conv -= 2 * iv ( 1, s ) * Lx1 <TAB> for i in range ( 2, order ) : <TAB> <TAB> Lx2 = M. dot ( Lx1 ) <TAB> <TAB> Lx2 = ( M. dot ( Lx2 ) - 2 * Lx1 ) - Lx0 <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> conv += 2 * iv ( i, s ) * Lx2 <TAB> <TAB> else : <TAB> <TAB> <TAB> conv -= 2 * iv ( i, s ) * Lx2 <TAB> <TAB> Lx0 = Lx1 <TAB> <TAB> Lx1 = Lx2 <TAB> <TAB> del Lx2 <TAB> mm = A. dot ( a - conv ) <TAB> return mm | False | i % 2 == 0 | i < 3 | 0.6680158376693726 |
19 | 17 | def parse_clusterflow_logs ( self, f ) : <TAB> """Parse Clusterflow logs""" <TAB> module = None <TAB> job_id = None <TAB> pipeline_id = None <TAB> for l in f [ "f" ] : <TAB> <TAB> <TAB> <TAB> module_r = re. match ( r"Module:\s+(.+)$", l ) <TAB> <TAB> if module_r : <TAB> <TAB> <TAB> module = module_r. group ( 1 ) <TAB> <TAB> job_id_r = re. match ( r"Job ID:\s+(.+)$", l ) <TAB> <TAB> if job_id_r : <TAB> <TAB> <TAB> job_id = job_id_r. group ( 1 ) <TAB> <TAB> <TAB> if module is not None : <TAB> <TAB> <TAB> <TAB> pipeline_r = re. match ( <TAB> <TAB> <TAB> <TAB> <TAB> r"(cf_.+)_" + re. escape ( module ) + r"_\d+$", job_id <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if pipeline_r : <TAB> <TAB> <TAB> <TAB> <TAB> pipeline_id = pipeline_r. group ( 1 ) <TAB> <TAB> <TAB> <TAB> if l. startswith ( "###CFCMD" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> pipeline_id = "unknown" <TAB> <TAB> <TAB> if pipeline_id not in self. clusterflow_commands. keys ( ) : <TAB> <TAB> <TAB> <TAB> self. clusterflow_commands [ pipeline_id ] = list ( ) <TAB> <TAB> <TAB> self. clusterflow_commands [ pipeline_id ]. append ( l [ 8 : ] ) | True | pipeline_id is None | pipeline_id is None | 0.6590132713317871 |
20 | 18 | def check_other_queues ( queue_counts_dict : Dict [ str, int ] ) -> List [ Dict [ str, Any ] ] : <TAB> """Do a simple queue size check for queues whose workers don't publish stats files.""" <TAB> results = [ ] <TAB> for queue, count in queue_counts_dict. items ( ) : <TAB> <TAB> if queue in normal_queues : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> results. append ( <TAB> <TAB> <TAB> <TAB> dict ( status = CRITICAL, name = queue, message = f"count critical: {count}" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif count > WARN_COUNT_THRESHOLD_DEFAULT : <TAB> <TAB> <TAB> results. append ( <TAB> <TAB> <TAB> <TAB> dict ( status = WARNING, name = queue, message = f"count warning: {count}" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> results. append ( dict ( status = OK, name = queue, message = "" ) ) <TAB> return results | True | count > CRITICAL_COUNT_THRESHOLD_DEFAULT | count > CRITICAL_COUNT_THRESHOLD_DEFAULT | 0.6601839065551758 |
21 | 19 | def handle ( self ) : <TAB> <TAB> self. _send_textline ( "* OK IMAP4rev1" ) <TAB> while 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> line = b"" <TAB> <TAB> while 1 : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> part = self. rfile. read ( 1 ) <TAB> <TAB> <TAB> <TAB> if part == b"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> line += part <TAB> <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> if line. endswith ( b"\r\n" ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if verbose : <TAB> <TAB> <TAB> print ( "GOT: %r" % line. strip ( ) ) <TAB> <TAB> if self. continuation : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> self. continuation. send ( line ) <TAB> <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> <TAB> self. continuation = None <TAB> <TAB> <TAB> continue <TAB> <TAB> splitline = line. decode ( "ASCII" ). split ( ) <TAB> <TAB> tag = splitline [ 0 ] <TAB> <TAB> cmd = splitline [ 1 ] <TAB> <TAB> args = splitline [ 2 : ] <TAB> <TAB> if hasattr ( self, "cmd_" + cmd ) : <TAB> <TAB> <TAB> continuation = getattr ( self, "cmd_" + cmd ) ( tag, args ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. continuation = continuation <TAB> <TAB> <TAB> <TAB> next ( continuation ) <TAB> | False | continuation | continuing | 0.6953333616256714 |
22 | 20 | def get_indexes ( self, cursor, table_name ) : <TAB> <TAB> <TAB> cursor. execute ( self. _get_indexes_query, [ table_name, self. connection. schema_name ] ) <TAB> indexes = { } <TAB> for row in cursor. fetchall ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if " " in row [ 1 ] : <TAB> <TAB> <TAB> continue <TAB> <TAB> if row [ 0 ] not in indexes : <TAB> <TAB> <TAB> indexes [ row [ 0 ] ] = { "primary_key" : False, "unique" : False } <TAB> <TAB> <TAB> <TAB> if row [ 3 ] : <TAB> <TAB> <TAB> indexes [ row [ 0 ] ] [ "primary_key" ] = True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> indexes [ row [ 0 ] ] [ "unique" ] = True <TAB> return indexes | False | row[2] | row[4] | 0.6649578213691711 |
23 | 21 | def _cache_key ( ui, url = None, locale = None, additional_key_data = None ) : <TAB> if url is None : <TAB> <TAB> url = request. base_url <TAB> if locale is None : <TAB> <TAB> locale = g. locale. language if g. locale else "en" <TAB> k = "ui:{}:{}:{}". format ( ui, url, locale ) <TAB> if callable ( additional_key_data ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> ak = additional_key_data ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not isinstance ( ak, ( list, tuple ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> ak = [ ak ] <TAB> <TAB> <TAB> <TAB> k = "{}:{}". format ( k, ":". join ( ak ) ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> _logger. exception ( <TAB> <TAB> <TAB> <TAB> "Error while trying to retrieve additional cache key parts for ui {}". format ( <TAB> <TAB> <TAB> <TAB> <TAB> ui <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> return k | False | ak | ak is None | 0.698824405670166 |
24 | 22 | def _ArgumentListHasDictionaryEntry ( self, token ) : <TAB> """Check if the function argument list has a dictionary as an arg.""" <TAB> if _IsArgumentToFunction ( token ) : <TAB> <TAB> while token : <TAB> <TAB> <TAB> if token. value == "{" : <TAB> <TAB> <TAB> <TAB> length = token. matching_bracket. total_length - token. total_length <TAB> <TAB> <TAB> <TAB> return length + self. stack [ - 2 ]. indent > self. column_limit <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if token. OpensScope ( ) : <TAB> <TAB> <TAB> <TAB> token = token. matching_bracket <TAB> <TAB> <TAB> token = token. next_token <TAB> return False | False | token.ClosesScope() | token.value == '}' | 0.6620413064956665 |
25 | 23 | def parse_escaped_hierarchical_category_name ( category_name ) : <TAB> """Parse a category name.""" <TAB> result = [ ] <TAB> current = None <TAB> index = 0 <TAB> next_backslash = category_name. find ( "\\", index ) <TAB> next_slash = category_name. find ( "/", index ) <TAB> while index < len ( category_name ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> current = ( current if current else "" ) + category_name [ index : ] <TAB> <TAB> <TAB> index = len ( category_name ) <TAB> <TAB> elif next_slash >= 0 and ( next_backslash == - 1 or next_backslash > next_slash ) : <TAB> <TAB> <TAB> result. append ( <TAB> <TAB> <TAB> <TAB> ( current if current else "" ) + category_name [ index : next_slash ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> current = "" <TAB> <TAB> <TAB> index = next_slash + 1 <TAB> <TAB> <TAB> next_slash = category_name. find ( "/", index ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if len ( category_name ) == next_backslash + 1 : <TAB> <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> <TAB> "Unexpected '\\' in '{0}' at last position!". format ( category_name ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> esc_ch = category_name [ next_backslash + 1 ] <TAB> <TAB> <TAB> if esc_ch not in { "/", "\\" } : <TAB> <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> <TAB> "Unknown escape sequence '\\{0}' in '{1}'!". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> esc_ch, category_name <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> < | False | next_backslash == -1 and next_slash == -1 | current | 0.6594604849815369 |
26 | 24 | def addStudent ( self, name, age ) : <TAB> new_names = self. getNames ( ) <TAB> found = False <TAB> for item in new_names : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> found = True <TAB> <TAB> <TAB> break <TAB> if not found : <TAB> <TAB> new_names. append ( ( name, age ) ) <TAB> new_names. sort ( ) <TAB> while len ( self. children ) : <TAB> <TAB> self. remove ( self. children [ 0 ] ) <TAB> <TAB> <TAB> self. addTitle ( ) <TAB> for student in new_names : <TAB> <TAB> sw = StudentWidget ( student [ 0 ], student [ 1 ] ) <TAB> <TAB> makeDraggable ( sw ) <TAB> <TAB> self. append ( sw ) <TAB> <TAB> self. setCellVerticalAlignment ( sw, HasVerticalAlignment. ALIGN_TOP ) | False | item == (name, age) | item | 0.6567255854606628 |
27 | 25 | def mockup ( self, records ) : <TAB> provider = TransipProvider ( "", "", "" ) <TAB> _dns_entries = [ ] <TAB> for record in records : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> entries_for = getattr ( provider, "_entries_for_{}". format ( record. _type ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> name = record. name <TAB> <TAB> <TAB> if name == "" : <TAB> <TAB> <TAB> <TAB> name = provider. ROOT_RECORD <TAB> <TAB> <TAB> _dns_entries. extend ( entries_for ( name, record ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _dns_entries. append ( DnsEntry ( "@", "3600", "NS", "ns01.transip.nl." ) ) <TAB> self. mockupEntries = _dns_entries | False | record._type in provider.SUPPORTS | record._type != WebSocketRecord.NONE | 0.6495593190193176 |
28 | 26 | def _compare ( d1, d2, skip_keys = None ) : <TAB> """Compare two lists or dictionaries or array""" <TAB> if type ( d1 )!= type ( d2 ) : <TAB> <TAB> return False <TAB> if isinstance ( d1, dict ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> for key in d1 : <TAB> <TAB> <TAB> if skip_keys is not None and key in skip_keys : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if not _compare ( d1 [ key ], d2 [ key ], skip_keys = skip_keys ) : <TAB> <TAB> <TAB> <TAB> return False <TAB> elif isinstance ( d1, list ) : <TAB> <TAB> for i, _ in enumerate ( d1 ) : <TAB> <TAB> <TAB> if not _compare ( d1 [ i ], d2 [ i ], skip_keys = skip_keys ) : <TAB> <TAB> <TAB> <TAB> return False <TAB> elif isinstance ( d1, np. ndarray ) : <TAB> <TAB> if not np. array_equal ( d1, d2 ) : <TAB> <TAB> <TAB> return False <TAB> else : <TAB> <TAB> if d1!= d2 : <TAB> <TAB> <TAB> return False <TAB> return True | False | set(d1) != set(d2) | d1 != d2 | 0.6493426561355591 |
29 | 27 | def _get_families ( self ) : <TAB> families = [ ] <TAB> for name, ext in self. _get_family_dirs ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> family = self. get_resource ( <TAB> <TAB> <TAB> <TAB> FileSystemPackageFamilyResource. key, location = self. location, name = name <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> family = self. get_resource ( <TAB> <TAB> <TAB> <TAB> FileSystemCombinedPackageFamilyResource. key, <TAB> <TAB> <TAB> <TAB> location = self. location, <TAB> <TAB> <TAB> <TAB> name = name, <TAB> <TAB> <TAB> <TAB> ext = ext, <TAB> <TAB> <TAB> ) <TAB> <TAB> families. append ( family ) <TAB> return families | False | ext is None | ext | 0.6625068187713623 |
30 | 28 | def _module_repr_from_spec ( spec ) : <TAB> """Return the repr to use for the module.""" <TAB> <TAB> name = "?" if spec. name is None else spec. name <TAB> if spec. origin is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return "<module {!r}>". format ( name ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return "<module {!r} ({!r})>". format ( name, spec. loader ) <TAB> else : <TAB> <TAB> if spec. has_location : <TAB> <TAB> <TAB> return "<module {!r} from {!r}>". format ( name, spec. origin ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return "<module {!r} ({})>". format ( spec. name, spec. origin ) | True | spec.loader is None | spec.loader is None | 0.6524957418441772 |
31 | 29 | def doDir ( elem ) : <TAB> for child in elem. childNodes : <TAB> <TAB> if not isinstance ( child, minidom. Element ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if child. tagName == "Directory" : <TAB> <TAB> <TAB> doDir ( child ) <TAB> <TAB> elif child. tagName == "Component" : <TAB> <TAB> <TAB> for grandchild in child. childNodes : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if grandchild. tagName!= "File" : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> files. add ( grandchild. getAttribute ( "Source" ). replace ( os. sep, "/" ) ) | False | not isinstance(grandchild, minidom.Element) | grandchild.tagName == 'Error' | 0.6502865552902222 |
32 | 30 | def test_row ( self, row ) : <TAB> for idx, test in self. patterns. items ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> value = row [ idx ] <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> value = "" <TAB> <TAB> result = test ( value ) <TAB> <TAB> if self. any_match : <TAB> <TAB> <TAB> if result : <TAB> <TAB> <TAB> <TAB> return not self. inverse <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return self. inverse <TAB> if self. any_match : <TAB> <TAB> return self. inverse <TAB> else : <TAB> <TAB> return not self. inverse | False | not result | result | 0.6757747530937195 |
33 | 31 | def _validate_scalar_extensions ( self ) -> List [ str ] : <TAB> errors = [ ] <TAB> for extension in [ <TAB> <TAB> x for x in self. extensions if isinstance ( x, GraphQLScalarTypeExtension ) <TAB> ] : <TAB> <TAB> extended = self. type_definitions. get ( extension. name ) <TAB> <TAB> ext_errors = _validate_extension ( <TAB> <TAB> <TAB> extended, extension. name, GraphQLScalarType, "SCALAR" <TAB> <TAB> ) <TAB> <TAB> errors. extend ( ext_errors ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> errors. extend ( _validate_extension_directives ( extension, extended, "SCALAR" ) ) <TAB> return errors | False | not ext_errors | extension.directives | 0.661431074142456 |
34 | 32 | def call ( monad, * args ) : <TAB> for arg, name in izip ( args, ( "hour", "minute", "second", "microsecond" ) ) : <TAB> <TAB> if not isinstance ( arg, NumericMixin ) or arg. type is not int : <TAB> <TAB> <TAB> throw ( <TAB> <TAB> <TAB> <TAB> TypeError, <TAB> <TAB> <TAB> <TAB> "'%s' argument of time(...) function must be of 'int' type. Got: %r" <TAB> <TAB> <TAB> <TAB> % ( name, type2str ( arg. type ) ), <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> throw ( NotImplementedError ) <TAB> return ConstMonad. new ( time ( * tuple ( arg. value for arg in args ) ) ) | False | not isinstance(arg, ConstMonad) | monad.type is None and arg.type is not int | 0.6584521532058716 |
35 | 33 | def get_config ( ) : <TAB> try : <TAB> <TAB> config_str = config. get ( "plugins", "equalizer_levels", "[]" ) <TAB> <TAB> config_dict = ast. literal_eval ( config_str ) <TAB> <TAB> if isinstance ( config_dict, list ) : <TAB> <TAB> <TAB> print_w ( "Converting old EQ config to new format." ) <TAB> <TAB> <TAB> config_dict = { "Current" : config_dict } <TAB> <TAB> if not isinstance ( config_dict, dict ) : <TAB> <TAB> <TAB> raise ValueError ( "Saved config is of wrong type." ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( "Saved config was malformed." ) <TAB> <TAB> <TAB> <TAB> for key in config_dict. keys ( ) : <TAB> <TAB> <TAB> [ float ( s ) for s in config_dict [ key ] ] <TAB> <TAB> return config_dict <TAB> except ( config. Error, ValueError ) as e : <TAB> <TAB> print_e ( str ( e ) ) <TAB> <TAB> return { "Current" : [ ] } | False | not 'Current' in config_dict.keys() | config_dict.get('error') | 0.6510497331619263 |
36 | 34 | def _parse ( self, contents ) : <TAB> entries = [ ] <TAB> for line in contents. splitlines ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> entries. append ( ( "blank", [ line ] ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> ( head, tail ) = chop_comment ( line. strip ( ), "#" ) <TAB> <TAB> if not len ( head ) : <TAB> <TAB> <TAB> entries. append ( ( "all_comment", [ line ] ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> entries. append ( ( "option", [ head. split ( None ), tail ] ) ) <TAB> return entries | False | not len(line.strip()) | not line | 0.6477398872375488 |
37 | 35 | def _brush_modified_cb ( self, settings ) : <TAB> """Updates the brush's base setting adjustments on brush changes""" <TAB> for cname in settings : <TAB> <TAB> adj = self. brush_adjustment. get ( cname, None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> value = self. brush. get_base_value ( cname ) <TAB> <TAB> adj. set_value ( value ) | True | adj is None | adj is None | 0.6785727143287659 |
38 | 36 | def upgrade ( migrate_engine ) : <TAB> print ( __doc__ ) <TAB> metadata. bind = migrate_engine <TAB> liftoverjobs = dict ( ) <TAB> jobs = context. query ( DeferredJob ). filter_by ( plugin = "LiftOverTransferPlugin" ). all ( ) <TAB> for job in jobs : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> liftoverjobs [ job. params [ "parentjob" ] ] = [ ] <TAB> <TAB> liftoverjobs [ job. params [ "parentjob" ] ]. append ( job. id ) <TAB> for parent in liftoverjobs : <TAB> <TAB> lifts = liftoverjobs [ parent ] <TAB> <TAB> deferred = context. query ( DeferredJob ). filter_by ( id = parent ). first ( ) <TAB> <TAB> deferred. params [ "liftover" ] = lifts <TAB> context. flush ( ) | False | job.params['parentjob'] not in liftoverjobs | job.plugin == 'LiftOverTransferPlugin' | 0.661872923374176 |
39 | 37 | def bump_version ( bump_type ) : <TAB> """Bumps version to the next release, or development version.""" <TAB> cur_ver = _get_version ( ) <TAB> click. echo ( "current version: %s" % cur_ver ) <TAB> ver_split = cur_ver. split ( "." ) <TAB> if "dev" in ver_split [ - 1 ] : <TAB> <TAB> if bump_type == "dev" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ver_split [ - 1 ] = "dev%d" % ( int ( ver_split [ - 1 ]. strip ( "dev" ) or 0 ) + 1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ver_split = ver_split [ : - 1 ] <TAB> else : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ver_split. append ( "1" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if "b" in ver_split [ 2 ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> minor, beta = ver_split [ - 1 ]. split ( "b" ) <TAB> <TAB> <TAB> <TAB> ver_split [ - 1 ] = "%sb%s" % ( minor, int ( beta ) + 1 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> ver_split [ - 1 ] = str ( int ( ver_split [ - 1 ] ) + 1 ) <TAB> <TAB> if bump_type == "dev" : <TAB> <TAB> <TAB> ver_split. append ( "dev" ) <TAB> new_version = ".". join ( ver_split ) <TAB> for line in fileinput. FileInput ( "flexget/_version.py", inplace = 1 ) : <TAB> <TAB> if line. startswith ( "__version__ =" ) : <TAB> <TAB> <TAB> line = "__version__ = '%s'\n | False | len(ver_split) == 2 | len(ver_split) > 1 | 0.6541119813919067 |
40 | 38 | def __find_smallest ( self ) : <TAB> """Find the smallest uncovered value in the matrix.""" <TAB> minval = sys. maxsize <TAB> for i in range ( self. n ) : <TAB> <TAB> for j in range ( self. n ) : <TAB> <TAB> <TAB> if ( not self. row_covered [ i ] ) and ( not self. col_covered [ j ] ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> minval = self. C [ i ] [ j ] <TAB> return minval | False | minval > self.C[i][j] | self.C[i] is not None | 0.6620251536369324 |
41 | 39 | def git_branch_for_post ( self, path, interactive = False ) : <TAB> if path is None : <TAB> <TAB> return None <TAB> if path in self. git_local_branches : <TAB> <TAB> return self. git_branch ( path ) <TAB> branches = [ ] <TAB> for branch in self. git_local_branches : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> branches. append ( branch ) <TAB> if len ( branches ) == 0 : <TAB> <TAB> if path in self. dir ( ) : <TAB> <TAB> <TAB> return self. git_branch ( self. config. published_branch ) <TAB> <TAB> return None <TAB> if len ( branches ) == 1 : <TAB> <TAB> return self. git_branch ( branches [ 0 ] ) <TAB> <TAB> if interactive : <TAB> <TAB> print ( "There are multiple branches for post '{}'.". format ( path ) ) <TAB> <TAB> for i, branch in enumerate ( branches ) : <TAB> <TAB> <TAB> print ( "{}. {}". format ( i, branch ) ) <TAB> <TAB> response = None <TAB> <TAB> while not isinstance ( response, int ) : <TAB> <TAB> <TAB> response = input ( "Please select the branch you would like to use: " ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> response = int ( response ) <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> response = None <TAB> else : <TAB> <TAB> response = 0 <TAB> return self. git_branch ( branches [ response ] ) | False | path in self.git_local_posts(branches=[branch]) | path in branch | 0.656347393989563 |
42 | 40 | def update_brush ( self, * args ) : <TAB> with self. output : <TAB> <TAB> if not self. brush. brushing : <TAB> <TAB> <TAB> self. figure. interaction = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ( x1, y1 ), ( x2, y2 ) = self. brush. selected <TAB> <TAB> <TAB> mode = self. modes_names [ <TAB> <TAB> <TAB> <TAB> self. modes_labels. index ( self. button_selection_mode. value ) <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> self. plot. select_rectangle ( x1, y1, x2, y2, mode = mode ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. dataset. select_nothing ( ) <TAB> <TAB> if ( <TAB> <TAB> <TAB> not self. brush. brushing <TAB> <TAB> ) : <TAB> <TAB> <TAB> self. figure. interaction = self. brush | False | self.brush.selected is not None | self.button_selection_mode.value is not None | 0.6603747606277466 |
43 | 41 | def check ( self, check_all = False, do_reload = True ) : <TAB> """Check whether some modules need to be reloaded.""" <TAB> if not self. enabled and not check_all : <TAB> <TAB> return <TAB> if check_all or self. check_all : <TAB> <TAB> modules = list ( sys. modules. keys ( ) ) <TAB> else : <TAB> <TAB> modules = list ( self. modules. keys ( ) ) <TAB> for modname in modules : <TAB> <TAB> m = sys. modules. get ( modname, None ) <TAB> <TAB> if modname in self. skip_modules : <TAB> <TAB> <TAB> continue <TAB> <TAB> py_filename, pymtime = self. filename_and_mtime ( m ) <TAB> <TAB> if py_filename is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> if pymtime <= self. modules_mtimes [ modname ] : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> self. modules_mtimes [ modname ] = pymtime <TAB> <TAB> <TAB> continue <TAB> <TAB> else : <TAB> <TAB> <TAB> if self. failed. get ( py_filename, None ) == pymtime : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> self. modules_mtimes [ modname ] = pymtime <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> superreload ( m, reload, self. old_objects ) <TAB> <TAB> <TAB> <TAB> if py_filename in self. failed : <TAB> <TAB> <TAB> <TAB> <TAB> del self. failed [ py_filename ] <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> "[autoreload of %s failed: %s]" <TAB> <TAB> <TAB | True | do_reload | do_reload | 0.6698036193847656 |
44 | 42 | def viewresult_to_response ( context, request ) : <TAB> result = view ( context, request ) <TAB> if result. __class__ is Response : <TAB> <TAB> response = result <TAB> else : <TAB> <TAB> response = info. registry. queryAdapterOrSelf ( result, IResponse ) <TAB> <TAB> if response is None : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> append = ( <TAB> <TAB> <TAB> <TAB> <TAB> " You may have forgotten to return a value " <TAB> <TAB> <TAB> <TAB> <TAB> "from the view callable." <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif isinstance ( result, dict ) : <TAB> <TAB> <TAB> <TAB> append = ( <TAB> <TAB> <TAB> <TAB> <TAB> " You may have forgotten to define a " <TAB> <TAB> <TAB> <TAB> <TAB> "renderer in the view configuration." <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> append = "" <TAB> <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> <TAB> "Could not convert return value of the view " <TAB> <TAB> <TAB> <TAB> "callable %s into a response object. " <TAB> <TAB> <TAB> <TAB> "The value returned was %r." + append <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise ValueError ( msg % ( view_description ( view ), result ) ) <TAB> return response | False | result is None | isinstance(result, list) | 0.6762720346450806 |
45 | 43 | def put ( <TAB> self, <TAB> value : V = None, <TAB> key : K = None, <TAB> partition : Optional [ int ] = None, <TAB> timestamp : Optional [ float ] = None, <TAB> headers : HeadersArg = None, <TAB> key_serializer : CodecArg = None, <TAB> value_serializer : CodecArg = None, <TAB> *, <TAB> reply_to : ReplyToArg = None, <TAB> correlation_id : str = None, <TAB> wait : bool = True ) -> EventT : <TAB> if reply_to : <TAB> <TAB> value, headers = self. _create_req ( key, value, reply_to, correlation_id, headers ) <TAB> channel = cast ( ChannelT, self. stream ( ). channel ) <TAB> message = self. to_message ( <TAB> <TAB> key, <TAB> <TAB> value, <TAB> <TAB> partition = partition, <TAB> <TAB> offset = self. sent_offset, <TAB> <TAB> timestamp = timestamp, <TAB> <TAB> headers = headers, <TAB> ) <TAB> event : EventT = await channel. decode ( message ) <TAB> await channel. put ( event ) <TAB> self. sent_offset += 1 <TAB> if wait : <TAB> <TAB> async with self. new_value_processed : <TAB> <TAB> <TAB> await self. new_value_processed. wait ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise self. _crash_reason from self. _crash_reason <TAB> return event | False | self._crash_reason | self._crash_reason is not None | 0.6541967391967773 |
46 | 44 | def __setattr__ ( self, name : str, val : Any ) : <TAB> if name. startswith ( "COMPUTED_" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> old_val = self [ name ] <TAB> <TAB> <TAB> if old_val == val : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> raise KeyError ( <TAB> <TAB> <TAB> <TAB> "Computed attributed '{}' already exists " <TAB> <TAB> <TAB> <TAB> "with a different value! old={}, new={}.". format ( name, old_val, val ) <TAB> <TAB> <TAB> ) <TAB> <TAB> self [ name ] = val <TAB> else : <TAB> <TAB> super ( ). __setattr__ ( name, val ) | True | name in self | name in self | 0.6766839623451233 |
47 | 45 | def _try_parser ( self, parse_method ) : <TAB> _order = self. _settings. DATE_ORDER <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if "DATE_ORDER" not in self. _settings. _mod_settings : <TAB> <TAB> <TAB> <TAB> self. _settings. DATE_ORDER = self. locale. info. get ( "date_order", _order ) <TAB> <TAB> date_obj, period = date_parser. parse ( <TAB> <TAB> <TAB> self. _get_translated_date ( ), <TAB> <TAB> <TAB> parse_method = parse_method, <TAB> <TAB> <TAB> settings = self. _settings, <TAB> <TAB> ) <TAB> <TAB> self. _settings. DATE_ORDER = _order <TAB> <TAB> return DateData ( <TAB> <TAB> <TAB> date_obj = date_obj, <TAB> <TAB> <TAB> period = period, <TAB> <TAB> ) <TAB> except ValueError : <TAB> <TAB> self. _settings. DATE_ORDER = _order <TAB> <TAB> return None | False | self._settings.PREFER_LOCALE_DATE_ORDER | parse_method == 'TAB > or parse_method == 'NONE' | 0.6579128503799438 |
48 | 46 | def _merge_substs ( self, subst, new_substs ) : <TAB> subst = subst. copy ( ) <TAB> for new_subst in new_substs : <TAB> <TAB> for name, var in new_subst. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> subst [ name ] = var <TAB> <TAB> <TAB> elif subst [ name ] is not var : <TAB> <TAB> <TAB> <TAB> subst [ name ]. PasteVariable ( var ) <TAB> return subst | True | name not in subst | name not in subst | 0.6805781126022339 |
49 | 47 | def calculate ( self ) : <TAB> for task in taskmods. DllList. calculate ( self ) : <TAB> <TAB> pid = task. UniqueProcessId <TAB> <TAB> if task. ObjectTable. HandleTableList : <TAB> <TAB> <TAB> for handle in task. ObjectTable. handles ( ) : <TAB> <TAB> <TAB> <TAB> if not handle. is_valid ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> name = "" <TAB> <TAB> <TAB> <TAB> object_type = handle. get_object_type ( ) <TAB> <TAB> <TAB> <TAB> if object_type == "File" : <TAB> <TAB> <TAB> <TAB> <TAB> file_obj = handle. dereference_as ( "_FILE_OBJECT" ) <TAB> <TAB> <TAB> <TAB> <TAB> name = str ( file_obj. file_name_with_device ( ) ) <TAB> <TAB> <TAB> <TAB> elif object_type == "Key" : <TAB> <TAB> <TAB> <TAB> <TAB> key_obj = handle. dereference_as ( "_CM_KEY_BODY" ) <TAB> <TAB> <TAB> <TAB> <TAB> name = key_obj. full_key_name ( ) <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> proc_obj = handle. dereference_as ( "_EPROCESS" ) <TAB> <TAB> <TAB> <TAB> <TAB> name = "{0}({1})". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> proc_obj. ImageFileName, proc_obj. UniqueProcessId <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> elif object_type == "Thread" : <TAB> <TAB> <TAB> <TAB> <TAB> thrd_obj = handle. dereference_as ( "_ETHREAD" ) <TAB> <TAB> <TAB> <TAB> <TAB> name = "T | True | object_type == 'Process' | object_type == 'Process' | 0.6585580110549927 |
50 | 48 | def _maybe_female ( self, path_elements, female, strict ) : <TAB> if female : <TAB> <TAB> if self. has_gender_differences : <TAB> <TAB> <TAB> elements = path_elements + [ "female" ] <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> return self. _get_file ( elements, ".png", strict = strict ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> if strict : <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> raise ValueError ( "Pokemon %s has no gender differences" % self. species_id ) <TAB> return self. _get_file ( path_elements, ".png", strict = strict ) | False | strict | self.has_gender_differences | 0.6987574696540833 |
51 | 49 | def process_target ( decompiler, pos, partial = False ) : <TAB> if pos is None : <TAB> <TAB> limit = None <TAB> elif partial : <TAB> <TAB> limit = decompiler. targets. get ( pos, None ) <TAB> else : <TAB> <TAB> limit = decompiler. targets. pop ( pos, None ) <TAB> top = decompiler. stack. pop ( ) <TAB> while True : <TAB> <TAB> top = simplify ( top ) <TAB> <TAB> if top is limit : <TAB> <TAB> <TAB> break <TAB> <TAB> if isinstance ( top, ast. GenExprFor ) : <TAB> <TAB> <TAB> break <TAB> <TAB> if not decompiler. stack : <TAB> <TAB> <TAB> break <TAB> <TAB> top2 = decompiler. stack [ - 1 ] <TAB> <TAB> if isinstance ( top2, ast. GenExprFor ) : <TAB> <TAB> <TAB> break <TAB> <TAB> if partial and hasattr ( top2, "endpos" ) and top2. endpos == pos : <TAB> <TAB> <TAB> break <TAB> <TAB> if isinstance ( top2, ( ast. And, ast. Or ) ) : <TAB> <TAB> <TAB> if top2. __class__ == top. __class__ : <TAB> <TAB> <TAB> <TAB> top2. nodes. extend ( top. nodes ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> top2. nodes. append ( top ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> top2. else_ = top <TAB> <TAB> <TAB> if hasattr ( top, "endpos" ) : <TAB> <TAB> <TAB> <TAB> top2. endpos = top. endpos <TAB> <TAB> <TAB> <TAB> if decompiler. targets. get ( top. endpos ) is top : <TAB> <TAB> <TAB> <TAB> <TAB> decompiler. targets [ top. endpos ] = top2 <TAB> <TAB> else : <TAB> <TAB> <TAB> throw | False | isinstance(top2, ast.IfExp) | top2.endpos is not None | 0.6477982997894287 |
52 | 50 | def test_inkey_0s_raw_ctrl_c ( ) : <TAB> "0-second inkey with raw allows receiving ^C." <TAB> pid, master_fd = pty. fork ( ) <TAB> if pid is 0 : <TAB> <TAB> try : <TAB> <TAB> <TAB> cov = __import__ ( "cov_core_init" ). init ( ) <TAB> <TAB> except ImportError : <TAB> <TAB> <TAB> cov = None <TAB> <TAB> term = TestTerminal ( ) <TAB> <TAB> read_until_semaphore ( sys. __stdin__. fileno ( ), semaphore = SEMAPHORE ) <TAB> <TAB> with term. raw ( ) : <TAB> <TAB> <TAB> os. write ( sys. __stdout__. fileno ( ), RECV_SEMAPHORE ) <TAB> <TAB> <TAB> inp = term. inkey ( timeout = 0 ) <TAB> <TAB> <TAB> os. write ( sys. __stdout__. fileno ( ), inp. encode ( "latin1" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cov. stop ( ) <TAB> <TAB> <TAB> cov. save ( ) <TAB> <TAB> os. _exit ( 0 ) <TAB> with echo_off ( master_fd ) : <TAB> <TAB> os. write ( master_fd, SEND_SEMAPHORE ) <TAB> <TAB> <TAB> <TAB> read_until_semaphore ( master_fd ) <TAB> <TAB> os. write ( master_fd, u"\x03". encode ( "latin1" ) ) <TAB> <TAB> stime = time. time ( ) <TAB> <TAB> output = read_until_eof ( master_fd ) <TAB> pid, status = os. waitpid ( pid, 0 ) <TAB> if os. environ. get ( "TRAVIS", None ) is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> assert output in ( u"", u"\x03" ) <TAB> <TAB> assert os | False | cov is not None | os.stat(master_fd) is not None | 0.666993260383606 |
53 | 51 | def doLabels ( ) : <TAB> global difficulty, answers <TAB> answers = [ ] <TAB> for loop in range ( 10 ) : <TAB> <TAB> numa = random. randint ( 1 * difficulty * 2, 10 * difficulty * 2 ) <TAB> <TAB> numb = random. randint ( 1 * difficulty * 2, 10 * difficulty * 2 ) <TAB> <TAB> action = random. choice ( actions ) <TAB> <TAB> if action == "+" : <TAB> <TAB> <TAB> answers. append ( numa + numb ) <TAB> <TAB> elif action == "-" : <TAB> <TAB> <TAB> answers. append ( numa - numb ) <TAB> <TAB> elif action == "*" : <TAB> <TAB> <TAB> answers. append ( numa * numb ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> answers. append ( numa / numb ) <TAB> <TAB> lab = str ( numa ) + " " + action + " " + str ( numb ) + " = " <TAB> <TAB> try : <TAB> <TAB> <TAB> win. addLabel ( "l" + str ( loop ), lab, 2 + loop, 0 ) <TAB> <TAB> <TAB> win. addEntry ( "l" + str ( loop ), 2 + loop, 1 ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> win. setLabel ( "l" + str ( loop ), lab ) <TAB> <TAB> <TAB> win. enableEntry ( "l" + str ( loop ) ) <TAB> <TAB> <TAB> win. setEntryBg ( "l" + str ( loop ), "white" ) <TAB> <TAB> <TAB> win. setEntry ( "l" + str ( loop ), "" ) | False | action == '/' | action == /0.0 | 0.6787170171737671 |
54 | 52 | def _convert_timestamp ( timestamp, precision = None ) : <TAB> if isinstance ( timestamp, Integral ) : <TAB> <TAB> return timestamp <TAB> if isinstance ( _get_unicode ( timestamp ), text_type ) : <TAB> <TAB> timestamp = parse ( timestamp ) <TAB> if isinstance ( timestamp, datetime ) : <TAB> <TAB> ns = timegm ( timestamp. utctimetuple ( ) ) * 1e9 + timestamp. microsecond * 1e3 <TAB> <TAB> if precision is None or precision == "n" : <TAB> <TAB> <TAB> return ns <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return ns / 1e3 <TAB> <TAB> elif precision == "ms" : <TAB> <TAB> <TAB> return ns / 1e6 <TAB> <TAB> elif precision == "s" : <TAB> <TAB> <TAB> return ns / 1e9 <TAB> <TAB> elif precision == "m" : <TAB> <TAB> <TAB> return ns / 1e9 / 60 <TAB> <TAB> elif precision == "h" : <TAB> <TAB> <TAB> return ns / 1e9 / 3600 <TAB> raise ValueError ( timestamp ) | False | precision == 'u' | precision == 't' | 0.6641597747802734 |
55 | 53 | def gotHeaders ( self, headers ) : <TAB> HTTPClientFactory. gotHeaders ( self, headers ) <TAB> if self. requestedPartial : <TAB> <TAB> contentRange = headers. get ( b"content-range", None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. requestedPartial = 0 <TAB> <TAB> <TAB> return <TAB> <TAB> start, end, realLength = http. parseContentRange ( contentRange [ 0 ] ) <TAB> <TAB> if start!= self. requestedPartial : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. requestedPartial = 0 | True | not contentRange | not contentRange | 0.6694787740707397 |
56 | 54 | def _strip_extras_markers ( marker ) : <TAB> <TAB> if marker is None or not isinstance ( marker, ( list, tuple ) ) : <TAB> <TAB> raise TypeError ( "Expecting a marker type, received {0!r}". format ( marker ) ) <TAB> markers_to_remove = [ ] <TAB> <TAB> <TAB> <TAB> for i, marker_list in enumerate ( marker ) : <TAB> <TAB> if isinstance ( marker_list, list ) : <TAB> <TAB> <TAB> cleaned = _strip_extras_markers ( marker_list ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> markers_to_remove. append ( i ) <TAB> <TAB> elif isinstance ( marker_list, tuple ) and marker_list [ 0 ]. value == "extra" : <TAB> <TAB> <TAB> markers_to_remove. append ( i ) <TAB> for i in reversed ( markers_to_remove ) : <TAB> <TAB> del marker [ i ] <TAB> <TAB> if i > 0 and marker [ i - 1 ] == "and" : <TAB> <TAB> <TAB> del marker [ i - 1 ] <TAB> return marker | False | not cleaned | cleaned | 0.6836735606193542 |
57 | 55 | def updateStats ( self, stats ) : <TAB> stats [ "global" ] [ "day" ] = date. fromordinal ( stats [ "global" ] [ "day" ] ) <TAB> self. applyDict ( self. deck. _globalStats, stats [ "global" ] ) <TAB> self. deck. _globalStats. toDB ( self. deck. s ) <TAB> for record in stats [ "daily" ] : <TAB> <TAB> record [ "day" ] = date. fromordinal ( record [ "day" ] ) <TAB> <TAB> stat = Stats ( ) <TAB> <TAB> id = self. deck. s. scalar ( <TAB> <TAB> <TAB> "select id from stats where " "type = :type and day = :day", <TAB> <TAB> <TAB> type = 1, <TAB> <TAB> <TAB> day = record [ "day" ], <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> stat. fromDB ( self. deck. s, id ) <TAB> <TAB> else : <TAB> <TAB> <TAB> stat. create ( self. deck. s, 1, record [ "day" ] ) <TAB> <TAB> self. applyDict ( stat, record ) <TAB> <TAB> stat. toDB ( self. deck. s ) | False | id | id > 0 | 0.6899368166923523 |
58 | 56 | def rotate_selected ( self ) : <TAB> opts = self. rotate_selected_opts <TAB> if self. actions. pressed ( opts [ "move_done_pressed" ] ) : <TAB> <TAB> return "main" <TAB> if self. actions. released ( opts [ "move_done_released" ] ) : <TAB> <TAB> return "main" <TAB> if self. actions. pressed ( opts [ "move_cancelled" ] ) : <TAB> <TAB> self. undo_cancel ( ) <TAB> <TAB> return "main" <TAB> if ( self. actions. mouse - opts [ "mouselast" ] ). length == 0 : <TAB> <TAB> return <TAB> if time. time ( ) < opts [ "lasttime" ] + 0.05 : <TAB> <TAB> return <TAB> opts [ "mouselast" ] = self. actions. mouse <TAB> opts [ "lasttime" ] = time. time ( ) <TAB> delta = Direction2D ( self. actions. mouse - opts [ "center" ] ) <TAB> dx, dy = opts [ "rotate_x" ]. dot ( delta ), opts [ "rotate_y" ]. dot ( delta ) <TAB> theta = math. atan2 ( dy, dx ) <TAB> set2D_vert = self. set2D_vert <TAB> for bmv, xy in opts [ "bmverts" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> dxy = xy - opts [ "center" ] <TAB> <TAB> nx = dxy. x * math. cos ( theta ) - dxy. y * math. sin ( theta ) <TAB> <TAB> ny = dxy. x * math. sin ( theta ) + dxy. y * math. cos ( theta ) <TAB> <TAB> nxy = Point2D ( ( nx, ny ) ) + opts [ "center" ] <TAB> <TAB> set2D_vert ( bmv, nxy ) <TAB> self. update_verts_faces ( v for v, _ in opts [ "bmverts" ] ) <TAB> self. dirty ( ) | False | not bmv.is_valid | opts['mouselast'] == False | 0.6510132551193237 |
59 | 57 | def _cache_mem ( curr_out, prev_mem, mem_len, reuse_len = None ) : <TAB> """cache hidden states into memory.""" <TAB> if mem_len is None or mem_len == 0 : <TAB> <TAB> return None <TAB> else : <TAB> <TAB> if reuse_len is not None and reuse_len > 0 : <TAB> <TAB> <TAB> curr_out = curr_out [ : reuse_len ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> new_mem = curr_out [ - mem_len : ] <TAB> <TAB> else : <TAB> <TAB> <TAB> new_mem = tf. concat ( [ prev_mem, curr_out ], 0 ) [ - mem_len : ] <TAB> return tf. keras. backend. stop_gradient ( new_mem ) | False | prev_mem is None | curr_out.size - mem_len > 0 | 0.650373101234436 |
60 | 58 | def data_download ( chunksize, filename, dataset, name ) : <TAB> <TAB> key = get_api_key ( ) <TAB> api = shodan. Shodan ( key ) <TAB> <TAB> file = None <TAB> try : <TAB> <TAB> files = api. data. list_files ( dataset ) <TAB> <TAB> for tmp in files : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> file = tmp <TAB> <TAB> <TAB> <TAB> break <TAB> except shodan. APIError as e : <TAB> <TAB> raise click. ClickException ( e. value ) <TAB> <TAB> if not file : <TAB> <TAB> raise click. ClickException ( "File not found" ) <TAB> <TAB> response = requests. get ( file [ "url" ], stream = True ) <TAB> <TAB> filesize = response. headers. get ( "content-length", None ) <TAB> if not filesize : <TAB> <TAB> <TAB> <TAB> filesize = file [ "size" ] <TAB> else : <TAB> <TAB> filesize = int ( filesize ) <TAB> chunk_size = 1024 <TAB> limit = filesize / chunk_size <TAB> <TAB> if not filename : <TAB> <TAB> filename = "{}-{}". format ( dataset, name ) <TAB> <TAB> with open ( filename, "wb" ) as fout : <TAB> <TAB> with click. progressbar ( <TAB> <TAB> <TAB> response. iter_content ( chunk_size = chunk_size ), length = limit <TAB> <TAB> ) as bar : <TAB> <TAB> <TAB> for chunk in bar : <TAB> <TAB> <TAB> <TAB> if chunk : <TAB> <TAB> <TAB> <TAB> <TAB> fout. write ( chunk ) <TAB> click. echo ( click. style ( "Download completed: {}". format ( filename ), "green" ) ) | False | tmp['name'] == name | tmp | 0.6580382585525513 |
61 | 59 | def build ( opt ) : <TAB> dpath = os. path. join ( opt [ "datapath" ], "HotpotQA" ) <TAB> if not build_data. built ( dpath, version_string = VERSION ) : <TAB> <TAB> print ( "[building data: " + dpath + "]" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> build_data. remove_dir ( dpath ) <TAB> <TAB> build_data. make_dir ( dpath ) <TAB> <TAB> <TAB> <TAB> for downloadable_file in RESOURCES : <TAB> <TAB> <TAB> downloadable_file. download_file ( dpath ) <TAB> <TAB> with PathManager. open ( os. path. join ( dpath, TRAIN_FILENAME ) ) as f : <TAB> <TAB> <TAB> data = json. load ( f ) <TAB> <TAB> <TAB> make_parlai_format ( dpath, "train", data ) <TAB> <TAB> with PathManager. open ( os. path. join ( dpath, DEV_DISTRACTOR_FILENAME ) ) as f : <TAB> <TAB> <TAB> data = json. load ( f ) <TAB> <TAB> <TAB> make_parlai_format ( dpath, "valid_distractor", data ) <TAB> <TAB> with PathManager. open ( os. path. join ( dpath, DEV_FULLWIKI_FILENAME ) ) as f : <TAB> <TAB> <TAB> data = json. load ( f ) <TAB> <TAB> <TAB> make_parlai_format ( dpath, "valid_fullwiki", data ) <TAB> <TAB> <TAB> <TAB> build_data. mark_done ( dpath, version_string = VERSION ) | False | build_data.built(dpath) | PathManager.exists(dpath) | 0.6459711790084839 |
62 | 60 | def scanvars ( reader, frame, locals ) : <TAB> """Scan one logical line of Python and look up values of variables used.""" <TAB> vars, lasttoken, parent, prefix, value = [ ], None, None, "", __UNDEF__ <TAB> for ttype, token, start, end, line in tokenize. generate_tokens ( reader ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> if ttype == tokenize. NAME and token not in keyword. kwlist : <TAB> <TAB> <TAB> if lasttoken == "." : <TAB> <TAB> <TAB> <TAB> if parent is not __UNDEF__ : <TAB> <TAB> <TAB> <TAB> <TAB> value = getattr ( parent, token, __UNDEF__ ) <TAB> <TAB> <TAB> <TAB> <TAB> vars. append ( ( prefix + token, prefix, value ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> where, value = lookup ( token, frame, locals ) <TAB> <TAB> <TAB> <TAB> vars. append ( ( token, where, value ) ) <TAB> <TAB> elif token == "." : <TAB> <TAB> <TAB> prefix += lasttoken + "." <TAB> <TAB> <TAB> parent = value <TAB> <TAB> else : <TAB> <TAB> <TAB> parent, prefix = None, "" <TAB> <TAB> lasttoken = token <TAB> return vars | False | ttype == tokenize.NEWLINE | ttype == tokenize.BREAK | 0.6613770127296448 |
63 | 61 | def queue_viewing ( request ) : <TAB> addon_ids = request. GET. get ( "addon_ids" ) <TAB> if not addon_ids : <TAB> <TAB> return { } <TAB> viewing = { } <TAB> user_id = request. user. id <TAB> for addon_id in addon_ids. split ( "," ) : <TAB> <TAB> addon_id = addon_id. strip ( ) <TAB> <TAB> key = get_reviewing_cache_key ( addon_id ) <TAB> <TAB> currently_viewing = cache. get ( key ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> viewing [ addon_id ] = UserProfile. objects. get ( id = currently_viewing ). name <TAB> return viewing | False | currently_viewing and currently_viewing != user_id | currently_viewing | 0.6519143581390381 |
64 | 62 | def decompile ( decompiler ) : <TAB> for pos, next_pos, opname, arg in decompiler. instructions : <TAB> <TAB> if pos in decompiler. targets : <TAB> <TAB> <TAB> decompiler. process_target ( pos ) <TAB> <TAB> method = getattr ( decompiler, opname, None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> throw ( DecompileError ( "Unsupported operation: %s" % opname ) ) <TAB> <TAB> decompiler. pos = pos <TAB> <TAB> decompiler. next_pos = next_pos <TAB> <TAB> x = method ( * arg ) <TAB> <TAB> if x is not None : <TAB> <TAB> <TAB> decompiler. stack. append ( x ) | True | method is None | method is None | 0.6689596176147461 |
65 | 63 | def add_directive ( self, name, obj, content = None, arguments = None, ** options ) : <TAB> if isinstance ( obj, clstypes ) and issubclass ( obj, Directive ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ExtensionError ( <TAB> <TAB> <TAB> <TAB> "when adding directive classes, no " "additional arguments may be given" <TAB> <TAB> <TAB> ) <TAB> <TAB> directives. register_directive ( name, directive_dwim ( obj ) ) <TAB> else : <TAB> <TAB> obj. content = content <TAB> <TAB> obj. arguments = arguments <TAB> <TAB> obj. options = options <TAB> <TAB> directives. register_directive ( name, obj ) | False | content or arguments or options | arguments is None | 0.6630731821060181 |
66 | 64 | def discover ( self, * objlist ) : <TAB> ret = [ ] <TAB> for l in self. splitlines ( ) : <TAB> <TAB> if len ( l ) < 5 : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> int ( l [ 2 ] ) <TAB> <TAB> <TAB> int ( l [ 3 ] ) <TAB> <TAB> except : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> ret. append ( l [ 0 ] ) <TAB> ret. sort ( ) <TAB> for item in objlist : <TAB> <TAB> ret. append ( item ) <TAB> return ret | False | l[0] == 'Filename' | l[1] not in objlist | 0.6621029376983643 |
67 | 65 | def pop ( self ) : <TAB> if not HAS_SQL : <TAB> <TAB> return None <TAB> tries = 3 <TAB> wait = 0.1 <TAB> try : <TAB> <TAB> conn, c = self. connect ( ) <TAB> except sqlite3. Error : <TAB> <TAB> log. traceback ( logging. DEBUG ) <TAB> <TAB> return None <TAB> heartbeat = None <TAB> loop = True <TAB> while loop and tries > - 1 : <TAB> <TAB> try : <TAB> <TAB> <TAB> c. execute ( "BEGIN IMMEDIATE" ) <TAB> <TAB> <TAB> c. execute ( "SELECT * FROM {0} LIMIT 1". format ( self. table_name ) ) <TAB> <TAB> <TAB> row = c. fetchone ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> id = row [ 0 ] <TAB> <TAB> <TAB> <TAB> heartbeat = Heartbeat ( <TAB> <TAB> <TAB> <TAB> <TAB> json. loads ( row [ 1 ] ), self. args, self. configs, _clone = True <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> c. execute ( "DELETE FROM {0} WHERE id=?". format ( self. table_name ), [ id ] ) <TAB> <TAB> <TAB> conn. commit ( ) <TAB> <TAB> <TAB> loop = False <TAB> <TAB> except sqlite3. Error : <TAB> <TAB> <TAB> log. traceback ( logging. DEBUG ) <TAB> <TAB> <TAB> sleep ( wait ) <TAB> <TAB> <TAB> tries -= 1 <TAB> try : <TAB> <TAB> conn. close ( ) <TAB> except sqlite3. Error : <TAB> <TAB> log. traceback ( logging. DEBUG ) <TAB> return heartbeat | False | row is not None | row | 0.6631377935409546 |
68 | 66 | def _translate_bboxes ( self, results, offset ) : <TAB> """Shift bboxes horizontally or vertically, according to offset.""" <TAB> h, w, c = results [ "img_shape" ] <TAB> for key in results. get ( "bbox_fields", [ ] ) : <TAB> <TAB> min_x, min_y, max_x, max_y = np. split ( <TAB> <TAB> <TAB> results [ key ], results [ key ]. shape [ - 1 ], axis = - 1 <TAB> <TAB> ) <TAB> <TAB> if self. direction == "horizontal" : <TAB> <TAB> <TAB> min_x = np. maximum ( 0, min_x + offset ) <TAB> <TAB> <TAB> max_x = np. minimum ( w, max_x + offset ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> min_y = np. maximum ( 0, min_y + offset ) <TAB> <TAB> <TAB> max_y = np. minimum ( h, max_y + offset ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> results [ key ] = np. concatenate ( [ min_x, min_y, max_x, max_y ], axis = - 1 ) | True | self.direction == 'vertical' | self.direction == 'vertical' | 0.6605814695358276 |
69 | 67 | def runScripts ( self ) : <TAB> pythonCmd = shutil. which ( "python3" ) <TAB> if pythonCmd is None : <TAB> <TAB> pythonCmd = shutil. which ( "python" ) <TAB> if pythonCmd is None : <TAB> <TAB> pythonCmd = "python" <TAB> if not self. noDownload : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> os. environ [ "GIT_OFFICIAL_CLONE_LOCATION" ] = self. assetRepoLocation <TAB> <TAB> <TAB> self. runProcess ( [ pythonCmd, "download_assets_git.py" ] ) <TAB> <TAB> except subprocess. CalledProcessError : <TAB> <TAB> <TAB> print ( "check that download_assets_git.py is working correctly" ) <TAB> <TAB> <TAB> sys. exit ( 1 ) <TAB> <TAB> print ( "\n" ) <TAB> <TAB> try : <TAB> <TAB> self. runProcess ( [ pythonCmd, "compile_targets.py" ] ) <TAB> except subprocess. CalledProcessError : <TAB> <TAB> print ( "check that compile_targets.py is working correctly" ) <TAB> <TAB> sys. exit ( 1 ) <TAB> print ( "\n" ) <TAB> <TAB> try : <TAB> <TAB> self. runProcess ( [ pythonCmd, "compile_models.py" ] ) <TAB> except subprocess. CalledProcessError : <TAB> <TAB> print ( "check that compile_models.py is working correctly" ) <TAB> <TAB> sys. exit ( 1 ) <TAB> print ( "\n" ) <TAB> <TAB> try : <TAB> <TAB> self. runProcess ( [ pythonCmd, "compile_proxies.py" ] ) <TAB> except subprocess. CalledProcessError : <TAB> <TAB> print ( "check that compile_proxies.py is working correctly" ) <TAB> <TAB> sys. exit ( 1 ) <TAB> print ( "\n" ) | False | not self.assetRepoLocation is None | self.assetRepoLocation is not None | 0.6513268947601318 |
70 | 68 | def assert_backend ( self, expected_translated, language = "cs" ) : <TAB> """Check that backend has correct data.""" <TAB> translation = self. get_translation ( language ) <TAB> translation. commit_pending ( "test", None ) <TAB> store = translation. component. file_format_cls ( translation. get_filename ( ), None ) <TAB> messages = set ( ) <TAB> translated = 0 <TAB> for unit in store. content_units : <TAB> <TAB> id_hash = unit. id_hash <TAB> <TAB> self. assertFalse ( id_hash in messages, "Duplicate string in in backend file!" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> translated += 1 <TAB> self. assertEqual ( <TAB> <TAB> translated, <TAB> <TAB> expected_translated, <TAB> <TAB> "Did not found expected number of translations ({}!= {}).". format ( <TAB> <TAB> <TAB> translated, expected_translated <TAB> <TAB> ), <TAB> ) | False | unit.is_translated() | expected_translated is not None and translated < expected_translated | 0.656049370765686 |
71 | 69 | def process_results_file ( f, region ) : <TAB> try : <TAB> <TAB> formatted_findings_list = [ ] <TAB> <TAB> results = results_file_to_dict ( f ) <TAB> <TAB> aws_account_id = results [ "account_id" ] <TAB> <TAB> creation_date = datetime. datetime. strptime ( <TAB> <TAB> <TAB> results [ "last_run" ] [ "time" ], "%Y-%m-%d %H:%M:%S%z" <TAB> <TAB> ). isoformat ( ) <TAB> <TAB> for service in results. get ( "service_list" ) : <TAB> <TAB> <TAB> for finding_key, finding_value in ( <TAB> <TAB> <TAB> <TAB> results. get ( "services", { } ). get ( service ). get ( "findings" ). items ( ) <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> formatted_finding = format_finding_to_securityhub_format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> aws_account_id, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> region, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> creation_date, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> finding_key, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> finding_value, <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> formatted_findings_list. append ( formatted_finding ) <TAB> <TAB> return formatted_findings_list <TAB> except Exception as e : <TAB> <TAB> print_exception ( f"Unable to process results file: {e}" ) | False | finding_value.get('items') | hasattr(self, 'securityhub_format') | 0.6513504981994629 |
72 | 70 | def _open_archive ( self, archive_name ) : <TAB> try : <TAB> <TAB> <TAB> <TAB> archive = None <TAB> <TAB> if tarfile. is_tarfile ( archive_name ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> archive = tarfile. open ( archive_name, "r", bufsize = CHUNK_SIZE * 2 ) <TAB> <TAB> elif zipfile. is_zipfile ( archive_name ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> archive = ZipThatPretendsToBeTar ( archive_name, "r" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. emit ( "error", None, _ ( "Downloaded file is corrupted." ) ) <TAB> <TAB> <TAB> <TAB> for pathname in archive. getnames ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> path = pathname. replace ( "\\", "/" ). split ( "/" ) [ 1 : ] <TAB> <TAB> <TAB> if len ( path ) < 1 : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> filename = path [ 0 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> tinfo = archive. getmember ( pathname ) <TAB> <TAB> <TAB> <TAB> log. debug ( "Extracting '%s'..." % ( pathname, ) ) <TAB> <TAB> <TAB> <TAB> if tinfo. isfile ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> compressed = archive. extractfile ( pathname ) <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> os. makedirs ( os. path. split ( self. target ) [ 0 ] ) <TAB> <TAB> <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> | False | filename in ('syncthing', 'syncthing.exe') | filename.startswith('/') | 0.6522713899612427 |
73 | 71 | def worker_callback ( self, worker ) : <TAB> process_request_count = 0 <TAB> while not worker. stop_event. is_set ( ) : <TAB> <TAB> worker. process_pause_signal ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> result, task = self. input_queue. get ( True, 0.1 ) <TAB> <TAB> except queue. Empty : <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> worker. is_busy_event. set ( ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> process_request_count += 1 <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> handler = self. spider. find_task_handler ( task ) <TAB> <TAB> <TAB> <TAB> except NoTaskHandler as ex : <TAB> <TAB> <TAB> <TAB> <TAB> ex. tb = format_exc ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. spider. task_dispatcher. input_queue. put ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ( ex, task, { "exc_info" : sys. exc_info ( ) } ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> self. spider. stat. inc ( "parser:handler-not-found" ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> self. execute_task_handler ( handler, result, task ) <TAB> <TAB> <TAB> <TAB> <TAB> self. spider. stat. inc ( "parser:handler-processed" ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> if process_request_count >= self. spider. parser_requests_per_process : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB | False | self.spider.parser_requests_per_process | worker.start_event.is_set() | 0.6507764458656311 |
74 | 72 | def _construct ( self, node ) : <TAB> self. flatten_mapping ( node ) <TAB> ret = self. construct_pairs ( node ) <TAB> keys = [ d [ 0 ] for d in ret ] <TAB> keys_sorted = sorted ( keys, key = _natsort_key ) <TAB> for key in keys : <TAB> <TAB> expected = keys_sorted. pop ( 0 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ConstructorError ( <TAB> <TAB> <TAB> <TAB> None, <TAB> <TAB> <TAB> <TAB> None, <TAB> <TAB> <TAB> <TAB> "keys out of order: " <TAB> <TAB> <TAB> <TAB> "expected {} got {} at {}". format ( expected, key, node. start_mark ), <TAB> <TAB> <TAB> ) <TAB> return dict ( ret ) | False | key != expected | expected not in node.end_mark | 0.6784542798995972 |
75 | 73 | def __iter__ ( self ) : <TAB> consumed = 0 <TAB> skipped = 0 <TAB> for query in self. queries : <TAB> <TAB> query_copy = copy ( query ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> query = query. limit ( self. _limit - consumed ) <TAB> <TAB> if self. _offset : <TAB> <TAB> <TAB> query = query. offset ( self. _offset - skipped ) <TAB> <TAB> obj_count = 0 <TAB> <TAB> for obj in query : <TAB> <TAB> <TAB> consumed += 1 <TAB> <TAB> <TAB> obj_count += 1 <TAB> <TAB> <TAB> yield obj <TAB> <TAB> if not obj_count : <TAB> <TAB> <TAB> skipped += query_copy. count ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> skipped += obj_count | True | self._limit | self._limit | 0.6864940524101257 |
76 | 74 | def refresh ( self ) : <TAB> self. window. erase ( ) <TAB> for index, line in enumerate ( self. lines ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif index > self. head_position + self. text_height - 1 : <TAB> <TAB> <TAB> continue <TAB> <TAB> x = 0 <TAB> <TAB> y = index - self. head_position <TAB> <TAB> if len ( line ) > 0 : <TAB> <TAB> <TAB> self. window. addstr ( y, x, line ) <TAB> xpos = self. width <TAB> for index, item in enumerate ( self. menu_items ) : <TAB> <TAB> if index == self. menu_position : <TAB> <TAB> <TAB> mode = curses. color_pair ( 3 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> mode = curses. color_pair ( 2 ) <TAB> <TAB> self. window. addstr ( self. text_height + 1, xpos - len ( item [ 0 ] ) - 4, item [ 0 ], mode ) <TAB> <TAB> xpos = xpos - len ( item [ 0 ] ) - 4 <TAB> self. render_scroll_bar ( ) <TAB> self. window. refresh ( ) <TAB> self. panel. top ( ) <TAB> self. panel. show ( ) <TAB> curses. panel. update_panels ( ) <TAB> curses. doupdate ( ) | False | index < self.head_position | self.is_empty(line) | 0.6581344604492188 |
77 | 75 | def process_one_node ( self, p, result, environment ) : <TAB> """Handle one node.""" <TAB> c = self. c <TAB> if not self. code_only : <TAB> <TAB> result. append ( self. underline2 ( p ) ) <TAB> d = c. scanAllDirectives ( p ) <TAB> if self. verbose : <TAB> <TAB> g. trace ( d. get ( "language" ) or "None", ":", p. h ) <TAB> s, code = self. process_directives ( p. b, d ) <TAB> result. append ( s ) <TAB> result. append ( "\n\n" ) <TAB> <TAB> if code and self. execcode : <TAB> <TAB> s, err = self. exec_code ( code, environment ) <TAB> <TAB> <TAB> <TAB> if not self. restoutput and s. strip ( ) : <TAB> <TAB> <TAB> s = self. format_output ( s ) <TAB> <TAB> result. append ( s ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> err = self. format_output ( err, prefix = "**Error**::" ) <TAB> <TAB> <TAB> result. append ( err ) | False | err | err and err.strip() | 0.6918526887893677 |
78 | 76 | def getReferences ( view, name = "" ) : <TAB> """Find all reference definitions.""" <TAB> <TAB> refs = [ ] <TAB> name = re. escape ( name ) <TAB> if name == "" : <TAB> <TAB> refs. extend ( view. find_all ( r"(?<=^\[)([^\]]+)(?=\]:)", 0 ) ) <TAB> else : <TAB> <TAB> refs. extend ( view. find_all ( r"(?<=^\[)(%s)(?=\]:)" % name, 0 ) ) <TAB> regions = refs <TAB> ids = { } <TAB> for reg in regions : <TAB> <TAB> name = view. substr ( reg ). strip ( ) <TAB> <TAB> key = name. lower ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ids [ key ]. regions. append ( reg ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ids [ key ] = Obj ( regions = [ reg ], label = name ) <TAB> return ids | True | key in ids | key in ids | 0.6798847913742065 |
79 | 77 | def download_chunk ( args ) : <TAB> global counter <TAB> x, y, latest, level = args <TAB> url_format = ( <TAB> <TAB> "https://himawari8-dl.nict.go.jp/himawari8/img/D531106/{}d/{}/{}_{}_{}.png" <TAB> ) <TAB> url = url_format. format ( level, WIDTH, strftime ( "%Y/%m/%d/%H%M%S", latest ), x, y ) <TAB> tiledata = download ( url ) <TAB> <TAB> if tiledata. __sizeof__ ( ) == 2867 : <TAB> <TAB> sys. exit ( <TAB> <TAB> <TAB> "No image available for {}.". format ( strftime ( "%Y/%m/%d %H:%M:%S", latest ) ) <TAB> <TAB> ) <TAB> with counter. get_lock ( ) : <TAB> <TAB> counter. value += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( "Downloading tiles: completed." ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> "Downloading tiles: {}/{} completed...". format ( <TAB> <TAB> <TAB> <TAB> <TAB> counter. value, level * level <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> return x, y, tiledata | False | counter.value == level * level | level == 1 | 0.6567804217338562 |
80 | 78 | def save ( self, mute = False, visited = None, * args, ** kwargs ) : <TAB> from ralph. ui. views. common import SAVE_PRIORITY <TAB> <TAB> visited = visited or set ( ) <TAB> visited. add ( self ) <TAB> priority = kwargs. get ( "priority" ) <TAB> change_author = kwargs. get ( "user" ) <TAB> if priority is None : <TAB> <TAB> priority = SAVE_PRIORITY <TAB> changes = [ ] <TAB> for obj, fields in self. get_synced_objs_and_fields ( ) : <TAB> <TAB> if obj in visited : <TAB> <TAB> <TAB> continue <TAB> <TAB> for f in fields : <TAB> <TAB> <TAB> setattr ( obj, f, getattr ( self, f ) ) <TAB> <TAB> obj. save ( visited = visited, mute = True, priority = priority ) <TAB> <TAB> <TAB> <TAB> if not mute : <TAB> <TAB> changes = [ ] <TAB> <TAB> try : <TAB> <TAB> <TAB> old_obj = type ( self ). objects. get ( pk = self. pk ) <TAB> <TAB> except type ( self ). DoesNotExist : <TAB> <TAB> <TAB> old_obj = None <TAB> <TAB> for field in self. _meta. fields : <TAB> <TAB> <TAB> if field. name not in SYNC_FIELD_MIXIN_NOTIFICATIONS_WHITELIST : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> old_value = getattr ( old_obj, field. name ) if old_obj else None <TAB> <TAB> <TAB> new_value = getattr ( self, field. name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> changes. append ( ChangeTuple ( field. name, old_value, new_value ) ) <TAB> <TAB> fields_synced_signal. send_robust ( <TAB> <TAB> <TAB> sender = self, changes = changes, change_author = change_author <TAB> <TAB> | False | old_value != new_value | new_value | 0.655549168586731 |
81 | 79 | def tail ( f, n, grep ) : <TAB> if n <= 0 : <TAB> <TAB> raise ValueError ( "Invalid amount of lines: {}". format ( n ) ) <TAB> BUFSIZ = 4096 <TAB> CR = "\n" <TAB> data = "" <TAB> f. seek ( 0, os. SEEK_END ) <TAB> fsize = f. tell ( ) <TAB> block = - 1 <TAB> exit = False <TAB> retval = [ ] <TAB> while not exit : <TAB> <TAB> step = block * BUFSIZ <TAB> <TAB> if abs ( step ) >= fsize : <TAB> <TAB> <TAB> f. seek ( 0 ) <TAB> <TAB> <TAB> newdata = f. read ( BUFSIZ - ( abs ( step ) - fsize ) ) <TAB> <TAB> <TAB> exit = True <TAB> <TAB> else : <TAB> <TAB> <TAB> f. seek ( step, os. SEEK_END ) <TAB> <TAB> <TAB> newdata = f. read ( BUFSIZ ) <TAB> <TAB> data = newdata + data <TAB> <TAB> if len ( retval ) + data. count ( CR ) >= n : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> lines = data. splitlines ( ) <TAB> <TAB> <TAB> <TAB> llines = len ( lines ) <TAB> <TAB> <TAB> <TAB> for idx in xrange ( llines - 1 ) : <TAB> <TAB> <TAB> <TAB> <TAB> line = lines [ llines - idx - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> if grep. search ( line ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> retval. insert ( 0, line ) <TAB> <TAB> <TAB> <TAB> <TAB> if len ( retval ) >= n : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> if len ( retval ) >= n : <TAB> <TAB> <TAB> <TAB> <TAB | False | grep | data.count() | 0.6853044629096985 |
82 | 80 | def getattr ( self, path, fh = None ) : <TAB> logger. debug ( "getattr -> '%s' '%s'" % ( path, fh ) ) <TAB> if self. cache. is_deleting ( path ) : <TAB> <TAB> logger. debug ( "getattr path '%s' is deleting -- throwing ENOENT" % ( path ) ) <TAB> <TAB> raise FuseOSError ( errno. ENOENT ) <TAB> with self. cache. get_lock ( <TAB> <TAB> path <TAB> ) : <TAB> <TAB> cache = True <TAB> <TAB> recheck_s3 = False <TAB> <TAB> if self. cache. is_empty ( path ) : <TAB> <TAB> <TAB> logger. debug ( "getattr <- '%s' '%s' cache ENOENT" % ( path, fh ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> cache = False <TAB> <TAB> <TAB> <TAB> recheck_s3 = True <TAB> <TAB> <TAB> <TAB> logger. debug ( <TAB> <TAB> <TAB> <TAB> <TAB> "getattr rechecking on s3 <- '%s' '%s' cache ENOENT" % ( path, fh ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise FuseOSError ( errno. ENOENT ) <TAB> <TAB> attr = self. get_metadata ( path, "attr" ) <TAB> <TAB> if attr == None : <TAB> <TAB> <TAB> logger. debug ( "getattr <- '%s' '%s' ENOENT" % ( path, fh ) ) <TAB> <TAB> <TAB> raise FuseOSError ( errno. ENOENT ) <TAB> <TAB> if attr [ "st_size" ] == 0 and stat. S_ISDIR ( attr [ "st_mode" ] ) : <TAB> <TAB> <TAB> attr [ "st_size" ] = 4096 <TAB> <TAB> attr [ "st_nlink" ] = 1 <TAB> <TAB> if self. st_blksize : <TAB | False | self.recheck_s3 | self.cache.get_s3(path) | 0.6540836095809937 |
83 | 81 | def execute_commands_and_raise_on_return_code ( <TAB> commands, error = None ) : <TAB> for command in commands : <TAB> <TAB> bad_return = error if error else "execute {}". format ( command ) <TAB> <TAB> output, return_code = execute_shell_command_get_return_code ( command ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise InstallationError ( "Failed to {}\n{}". format ( bad_return, output ) ) | True | return_code != 0 | return_code != 0 | 0.6576579213142395 |
84 | 82 | def image_diff ( test, ref, key = "image", prompt_num = None ) : <TAB> """Diff two base64-encoded images.""" <TAB> if test == ref : <TAB> <TAB> return True, "" <TAB> message = "Mismatch in %s output" % key <TAB> if prompt_num is not None : <TAB> <TAB> message += " (#%d)" % prompt_num <TAB> try : <TAB> <TAB> test = base64_to_array ( test ) <TAB> <TAB> ref = base64_to_array ( ref ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> import numpy as np <TAB> <TAB> <TAB> diff = np. abs ( test - ref ). mean ( ) * 100 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if diff < 5 : <TAB> <TAB> <TAB> <TAB> return True, "" <TAB> <TAB> <TAB> message += ": %.3g%% difference" % diff <TAB> <TAB> else : <TAB> <TAB> <TAB> message += ": Test image (%dx%d)" % test. shape [ : 2 ] <TAB> <TAB> <TAB> message += "; Ref image (%dx%d)" % ref. shape [ : 2 ] <TAB> except ImportError : <TAB> <TAB> pass <TAB> return False, message | False | test.shape == ref.shape | test > ref | 0.6618626117706299 |
85 | 83 | def get_event ( payload : Dict [ str, Any ] ) -> Optional [ str ] : <TAB> action = get_action_with_primary_id ( payload ) <TAB> event = "{}_{}". format ( action [ "entity_type" ], action [ "action" ] ) <TAB> if event in IGNORED_EVENTS : <TAB> <TAB> return None <TAB> changes = action. get ( "changes" ) <TAB> if changes is not None : <TAB> <TAB> if changes. get ( "description" ) is not None : <TAB> <TAB> <TAB> event = "{}_{}". format ( event, "description" ) <TAB> <TAB> elif changes. get ( "state" ) is not None : <TAB> <TAB> <TAB> event = "{}_{}". format ( event, "state" ) <TAB> <TAB> elif changes. get ( "workflow_state_id" ) is not None : <TAB> <TAB> <TAB> event = "{}_{}". format ( event, "state" ) <TAB> <TAB> elif changes. get ( "name" ) is not None : <TAB> <TAB> <TAB> event = "{}_{}". format ( event, "name" ) <TAB> <TAB> elif changes. get ( "archived" ) is not None : <TAB> <TAB> <TAB> event = "{}_{}". format ( event, "archived" ) <TAB> <TAB> elif changes. get ( "complete" ) is not None : <TAB> <TAB> <TAB> event = "{}_{}". format ( event, "complete" ) <TAB> <TAB> elif changes. get ( "epic_id" ) is not None : <TAB> <TAB> <TAB> event = "{}_{}". format ( event, "epic" ) <TAB> <TAB> elif changes. get ( "estimate" ) is not None : <TAB> <TAB> <TAB> event = "{}_{}". format ( event, "estimate" ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> event = "{}_{}". format ( event, "attachment" ) <TAB> <TAB> elif changes. get ( "label_ids" ) is not None : <TAB> <TAB | False | changes.get('file_ids') is not None | changes.get('attachment') is not None | 0.645397424697876 |
86 | 84 | def cd ( self, name ) : <TAB> path = self. abspath ( name ) <TAB> if name == ".." : <TAB> <TAB> self. path = "/". join ( self. path. split ( "/" ) [ : - 1 ] ) <TAB> <TAB> if self. path == "" : <TAB> <TAB> <TAB> self. path = "/" <TAB> <TAB> return <TAB> try : <TAB> <TAB> <TAB> <TAB> self. client. files_list_folder ( path, recursive = False ) <TAB> except dropbox. exceptions. ApiError as api_e : <TAB> <TAB> e = api_e. reason <TAB> <TAB> if e. is_other ( ) : <TAB> <TAB> <TAB> raise OperationFailure ( repr ( e ) ) <TAB> <TAB> elif e. is_path ( ) : <TAB> <TAB> <TAB> pe = e. get_path ( ) <TAB> <TAB> <TAB> if pe. is_not_folder ( ) : <TAB> <TAB> <TAB> <TAB> raise IsFile ( ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> raise OperationFailure ( "Not Found!" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise OperationFailure ( repr ( e ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise OperationFailure ( "Not found!" ) <TAB> else : <TAB> <TAB> self. path = path | False | pe.is_not_found() | not pe.is_file() | 0.6508831977844238 |
87 | 85 | def concatenateCharacterTokens ( tokens ) : <TAB> pendingCharacters = [ ] <TAB> for token in tokens : <TAB> <TAB> type = token [ "type" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pendingCharacters. append ( token [ "data" ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if pendingCharacters : <TAB> <TAB> <TAB> <TAB> yield { "type" : "Characters", "data" : "". join ( pendingCharacters ) } <TAB> <TAB> <TAB> <TAB> pendingCharacters = [ ] <TAB> <TAB> <TAB> yield token <TAB> if pendingCharacters : <TAB> <TAB> yield { "type" : "Characters", "data" : "". join ( pendingCharacters ) } | False | type in ('Characters', 'SpaceCharacters') | type == 'Characters' | 0.6518173217773438 |
88 | 86 | def verify_output ( actual, expected ) : <TAB> actual = _read_file ( actual, "Actual" ) <TAB> expected = _read_file ( join ( CURDIR, expected ), "Expected" ) <TAB> if len ( expected )!= len ( actual ) : <TAB> <TAB> raise AssertionError ( <TAB> <TAB> <TAB> "Lengths differ. Expected %d lines but got %d" <TAB> <TAB> <TAB> % ( len ( expected ), len ( actual ) ) <TAB> <TAB> ) <TAB> for exp, act in zip ( expected, actual ) : <TAB> <TAB> tester = fnmatchcase if "*" in exp else eq <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise AssertionError ( <TAB> <TAB> <TAB> <TAB> "Lines differ.\nExpected: %s\nActual: %s" % ( exp, act ) <TAB> <TAB> <TAB> ) | False | not tester(act.rstrip(), exp.rstrip()) | tester != act | 0.6507447957992554 |
89 | 87 | def forward ( self, inputs, feat_layers ) : <TAB> out = { } <TAB> res = self. conv_bn_init ( inputs ) <TAB> res = fluid. layers. relu ( res ) <TAB> res = self. maxpool ( res ) <TAB> <TAB> for i in range ( len ( self. block_collect ) ) : <TAB> <TAB> for layer in self. block_collect [ i ] : <TAB> <TAB> <TAB> res = layer ( res ) <TAB> <TAB> name = "block{}". format ( i ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> out [ name ] = res <TAB> <TAB> <TAB> if len ( out ) == len ( feat_layers ) : <TAB> <TAB> <TAB> <TAB> return out <TAB> res = self. global_pool ( res ) <TAB> B, C, _, _ = res. shape <TAB> res = fluid. layers. reshape ( res, [ B, C ] ) <TAB> res = self. fc ( res ) <TAB> out [ "fc" ] = res <TAB> return out | True | name in feat_layers | name in feat_layers | 0.6611325740814209 |
90 | 88 | def _test_forever ( self, tests ) : <TAB> while True : <TAB> <TAB> for test_name in tests : <TAB> <TAB> <TAB> yield test_name <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> if self. ns. fail_env_changed and self. environment_changed : <TAB> <TAB> <TAB> <TAB> return | False | self.bad | not self.ns.ok_test_name | 0.6596339344978333 |
91 | 89 | def init_wake_button_switch ( self ) : <TAB> try : <TAB> <TAB> import RPi. GPIO <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. wake_button_switch. set_active ( True ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. wake_button_switch. set_active ( False ) <TAB> except ImportError : <TAB> <TAB> self. wake_button_switch. set_sensitive ( False ) <TAB> except RuntimeError : <TAB> <TAB> self. wake_button_switch. set_sensitive ( False ) | False | susicfg.get('wakebutton') == 'enabled' | RPi.GPIO.get_active() | 0.663475513458252 |
92 | 90 | def transform ( self, node, results ) : <TAB> names_inserted = set ( ) <TAB> testlist = results [ "args" ] <TAB> args = testlist. children <TAB> new_args = [ ] <TAB> iterator = enumerate ( args ) <TAB> for idx, arg in iterator : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if idx < len ( args ) - 1 and args [ idx + 1 ]. type == token. COMMA : <TAB> <TAB> <TAB> <TAB> next ( iterator ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> else : <TAB> <TAB> <TAB> new_args. append ( arg ) <TAB> <TAB> <TAB> if arg. type == token. NAME : <TAB> <TAB> <TAB> <TAB> names_inserted. add ( arg. value ) <TAB> if new_args and new_args [ - 1 ]. type == token. COMMA : <TAB> <TAB> del new_args [ - 1 ] <TAB> if len ( new_args ) == 1 : <TAB> <TAB> atom = testlist. parent <TAB> <TAB> new_args [ 0 ]. prefix = atom. prefix <TAB> <TAB> atom. replace ( new_args [ 0 ] ) <TAB> else : <TAB> <TAB> args [ : ] = new_args <TAB> <TAB> node. changed ( ) | False | arg.type == token.NAME and arg.value in names_inserted | arg.type == token.COMMA | 0.6539357900619507 |
93 | 91 | def scan ( self, targets ) : <TAB> for target in targets : <TAB> <TAB> target. print_infos ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. target [ "other" ]. append ( target ) <TAB> <TAB> <TAB> if self. match ( target ) : <TAB> <TAB> <TAB> <TAB> return target <TAB> return None | False | self.is_interesting(target) | target.get('other') | 0.6490728855133057 |
94 | 92 | def decode ( self, segment ) : <TAB> numbers = [ ] <TAB> accu = 0 <TAB> weight = 1 <TAB> for char in segment : <TAB> <TAB> ordinal = self. decoding [ char ] <TAB> <TAB> isContinuation = ordinal >= 32 <TAB> <TAB> if isContinuation : <TAB> <TAB> <TAB> ordinal -= 32 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sign = - 1 if ordinal % 2 else 1 <TAB> <TAB> <TAB> ordinal //= 2 <TAB> <TAB> accu += weight * ordinal <TAB> <TAB> if isContinuation : <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> weight == 1 <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> weight = 16 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> weight *= 32 <TAB> <TAB> else : <TAB> <TAB> <TAB> numbers. append ( sign * accu ) <TAB> <TAB> <TAB> accu = 0 <TAB> <TAB> <TAB> weight = 1 <TAB> return numbers | False | weight == 1 | ordinal % 2 | 0.6824924945831299 |
95 | 93 | def new_f ( * args, ** kwargs ) : <TAB> try : <TAB> <TAB> D = pickle. load ( open ( filename, "rb" ) ) <TAB> <TAB> cache_exists = True <TAB> except : <TAB> <TAB> D = { } <TAB> <TAB> cache_exists = False <TAB> <TAB> Dargs = D. get ( "args" ) <TAB> Dkwargs = D. get ( "kwargs" ) <TAB> try : <TAB> <TAB> args_match = args == Dargs <TAB> except : <TAB> <TAB> args_match = np. all ( [ np. all ( a1 == a2 ) for ( a1, a2 ) in zip ( Dargs, args ) ] ) <TAB> try : <TAB> <TAB> kwargs_match = kwargs == Dkwargs <TAB> except : <TAB> <TAB> kwargs_match = ( sorted ( Dkwargs. keys ( ) ) == sorted ( kwargs. keys ( ) ) ) and ( <TAB> <TAB> <TAB> np. all ( [ np. all ( Dkwargs [ key ] == kwargs [ key ] ) for key in kwargs ] ) <TAB> <TAB> ) <TAB> if ( <TAB> <TAB> type ( D ) == dict <TAB> <TAB> and D. get ( "funcname" ) == f. __name__ <TAB> <TAB> and args_match <TAB> <TAB> and kwargs_match <TAB> ) : <TAB> <TAB> if verbose : <TAB> <TAB> <TAB> print ( "@pickle_results: using precomputed " "results from '%s'" % filename ) <TAB> <TAB> retval = D [ "retval" ] <TAB> else : <TAB> <TAB> if verbose : <TAB> <TAB> <TAB> print ( "@pickle_results: computing results " "and saving to '%s'" % filename ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print ( " warning: cache file '%s' exists" % filename ) <TAB> <TAB> <TAB> <TAB> print ( " - args match: %s" % args_match ) <TAB> <TAB> <TAB> <TAB | False | cache_exists | verbose | 0.664352297782898 |
96 | 94 | def interface_update ( self, request : web. Request ) -> None : <TAB> """Update the configuration of an interface.""" <TAB> interface = self. _get_interface ( request. match_info. get ( ATTR_INTERFACE ) ) <TAB> <TAB> body = await api_validate ( SCHEMA_UPDATE, request ) <TAB> if not body : <TAB> <TAB> raise APIError ( "You need to supply at least one option to update" ) <TAB> <TAB> for key, config in body. items ( ) : <TAB> <TAB> if key == ATTR_IPV4 : <TAB> <TAB> <TAB> interface. ipv4 = attr. evolve ( <TAB> <TAB> <TAB> <TAB> interface. ipv4 or IpConfig ( InterfaceMethod. STATIC, [ ], None, [ ] ), <TAB> <TAB> <TAB> <TAB> ** config, <TAB> <TAB> <TAB> ) <TAB> <TAB> elif key == ATTR_IPV6 : <TAB> <TAB> <TAB> interface. ipv6 = attr. evolve ( <TAB> <TAB> <TAB> <TAB> interface. ipv6 or IpConfig ( InterfaceMethod. STATIC, [ ], None, [ ] ), <TAB> <TAB> <TAB> <TAB> ** config, <TAB> <TAB> <TAB> ) <TAB> <TAB> elif key == ATTR_WIFI : <TAB> <TAB> <TAB> interface. wifi = attr. evolve ( <TAB> <TAB> <TAB> <TAB> interface. wifi <TAB> <TAB> <TAB> <TAB> or WifiConfig ( WifiMode. INFRASTRUCTURE, "", AuthMethod. OPEN, None, None ), <TAB> <TAB> <TAB> <TAB> ** config, <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> interface. enabled = config <TAB> await asyncio. shield ( self. sys_host. network. apply_changes ( interface ) ) | True | key == ATTR_ENABLED | key == ATTR_ENABLED | 0.6689105033874512 |
97 | 95 | def cache_dst ( self ) : <TAB> final_dst = None <TAB> final_linenb = None <TAB> for linenb, assignblk in enumerate ( self ) : <TAB> <TAB> for dst, src in viewitems ( assignblk ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if final_dst is not None : <TAB> <TAB> <TAB> <TAB> <TAB> raise ValueError ( "Multiple destinations!" ) <TAB> <TAB> <TAB> <TAB> final_dst = src <TAB> <TAB> <TAB> <TAB> final_linenb = linenb <TAB> self. _dst = final_dst <TAB> self. _dst_linenb = final_linenb <TAB> return final_dst | False | dst.is_id('IRDst') | linenb is not None and src is not None | 0.6583995819091797 |
98 | 96 | def _tab_only_directories ( self ) : <TAB> from os. path import dirname, basename, expanduser, join, isdir <TAB> line = parse ( self. line ) <TAB> cwd = self. fm. env. cwd. path <TAB> try : <TAB> <TAB> rel_dest = line. rest ( 1 ) <TAB> except IndexError : <TAB> <TAB> rel_dest = "" <TAB> <TAB> if rel_dest. startswith ( "~" ) : <TAB> <TAB> rel_dest = expanduser ( rel_dest ) <TAB> <TAB> abs_dest = join ( cwd, rel_dest ) <TAB> abs_dirname = dirname ( abs_dest ) <TAB> rel_basename = basename ( rel_dest ) <TAB> rel_dirname = dirname ( rel_dest ) <TAB> try : <TAB> <TAB> <TAB> <TAB> if rel_dest. endswith ( "/" ) or rel_dest == "" : <TAB> <TAB> <TAB> _, dirnames, _ = os. walk ( abs_dest ). next ( ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> _, dirnames, _ = os. walk ( abs_dirname ). next ( ) <TAB> <TAB> <TAB> dirnames = [ dn for dn in dirnames if dn. startswith ( rel_basename ) ] <TAB> except ( OSError, StopIteration ) : <TAB> <TAB> <TAB> <TAB> pass <TAB> else : <TAB> <TAB> dirnames. sort ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> if len ( dirnames ) == 1 : <TAB> <TAB> <TAB> return line + join ( rel_dirname, dirnames [ 0 ] ) + "/" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return ( line + join ( rel_dirname, dirname ) for dirname in dirnames ) | True | len(dirnames) == 0 | len(dirnames) == 0 | 0.6558115482330322 |
99 | 97 | def parse ( self, backend, x509_obj ) : <TAB> extensions = [ ] <TAB> seen_oids = set ( ) <TAB> for i in range ( self. ext_count ( backend, x509_obj ) ) : <TAB> <TAB> ext = self. get_ext ( backend, x509_obj, i ) <TAB> <TAB> backend. openssl_assert ( ext!= backend. _ffi. NULL ) <TAB> <TAB> crit = backend. _lib. X509_EXTENSION_get_critical ( ext ) <TAB> <TAB> critical = crit == 1 <TAB> <TAB> oid = x509. ObjectIdentifier ( _obj2txt ( backend, ext. object ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise x509. DuplicateExtension ( <TAB> <TAB> <TAB> <TAB> "Duplicate {0} extension found". format ( oid ), oid <TAB> <TAB> <TAB> ) <TAB> <TAB> try : <TAB> <TAB> <TAB> handler = self. handlers [ oid ] <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> if critical : <TAB> <TAB> <TAB> <TAB> raise x509. UnsupportedExtension ( <TAB> <TAB> <TAB> <TAB> <TAB> "Critical extension {0} is not currently supported". format ( oid ), oid <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. unsupported_exts and oid in self. unsupported_exts : <TAB> <TAB> <TAB> <TAB> ext_data = ext <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> ext_data = backend. _lib. X509V3_EXT_d2i ( ext ) <TAB> <TAB> <TAB> <TAB> if ext_data == backend. _ffi. NULL : <TAB> <TAB> <TAB> <TAB> <TAB> backend. _consume_errors ( ) <TAB> <TAB> < | True | oid in seen_oids | oid in seen_oids | 0.6713815927505493 |
100 | 98 | def __init__ ( self, parent, dir, mask, with_dirs = True ) : <TAB> filelist = [ ] <TAB> dirlist = [ ".." ] <TAB> self. dir = dir <TAB> self. file = "" <TAB> mask = mask. upper ( ) <TAB> pattern = self. MakeRegex ( mask ) <TAB> for i in os. listdir ( dir ) : <TAB> <TAB> if i == "." or i == ".." : <TAB> <TAB> <TAB> continue <TAB> <TAB> path = os. path. join ( dir, i ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> dirlist. append ( i ) <TAB> <TAB> <TAB> continue <TAB> <TAB> path = path. upper ( ) <TAB> <TAB> value = i. upper ( ) <TAB> <TAB> if pattern. match ( value ) is not None : <TAB> <TAB> <TAB> filelist. append ( i ) <TAB> self. files = filelist <TAB> if with_dirs : <TAB> <TAB> self. dirs = dirlist | False | os.path.isdir(path) | path.upper() == '' | 0.6477745771408081 |
101 | 99 | def initialize ( self ) : <TAB> nn. init. xavier_uniform_ ( self. linear. weight. data ) <TAB> if self. linear. bias is not None : <TAB> <TAB> self. linear. bias. data. uniform_ ( - 1.0, 1.0 ) <TAB> if self. self_layer : <TAB> <TAB> nn. init. xavier_uniform_ ( self. linear_self. weight. data ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. linear_self. bias. data. uniform_ ( - 1.0, 1.0 ) | False | self.linear_self.bias is not None | self.self_layer | 0.6544812917709351 |
102 | 100 | def datestamp ( ) : <TAB> """Enter today's date as the release date in the changelog.""" <TAB> dt = datetime. datetime. now ( ) <TAB> stamp = "({} {}, {})". format ( dt. strftime ( "%B" ), dt. day, dt. year ) <TAB> marker = "(in development)" <TAB> lines = [ ] <TAB> underline_length = None <TAB> with open ( CHANGELOG ) as f : <TAB> <TAB> for line in f : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> line = line. replace ( marker, stamp ) <TAB> <TAB> <TAB> <TAB> lines. append ( line ) <TAB> <TAB> <TAB> <TAB> underline_length = len ( line. strip ( ) ) <TAB> <TAB> <TAB> elif underline_length : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> lines. append ( "-" * underline_length + "\n" ) <TAB> <TAB> <TAB> <TAB> underline_length = None <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> lines. append ( line ) <TAB> with open ( CHANGELOG, "w" ) as f : <TAB> <TAB> for line in lines : <TAB> <TAB> <TAB> f. write ( line ) | False | marker in line | marker | 0.6756542921066284 |
103 | 101 | def go ( self, pyfile ) : <TAB> for line in open ( pyfile ) : <TAB> <TAB> if self. mode == "in def" : <TAB> <TAB> <TAB> self. text += " " + line. strip ( ) <TAB> <TAB> <TAB> if line. strip ( ). endswith ( ":" ) : <TAB> <TAB> <TAB> <TAB> if self. definition ( self. text ) : <TAB> <TAB> <TAB> <TAB> <TAB> self. text = "" <TAB> <TAB> <TAB> <TAB> <TAB> self. mode = "in func" <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> self. text = "" <TAB> <TAB> <TAB> <TAB> <TAB> self. mode = "normal" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if '"""' in line : <TAB> <TAB> <TAB> <TAB> self. text += line. strip ( ). strip ( '"' ) <TAB> <TAB> <TAB> <TAB> self. mode = "in doc" <TAB> <TAB> <TAB> <TAB> if line. count ( '"""' ) == 2 : <TAB> <TAB> <TAB> <TAB> <TAB> self. mode = "normal" <TAB> <TAB> <TAB> <TAB> <TAB> self. docstring ( self. text ) <TAB> <TAB> <TAB> <TAB> <TAB> self. text = "" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. mode = "normal" <TAB> <TAB> elif self. mode == "in doc" : <TAB> <TAB> <TAB> self. text += " " + line <TAB> <TAB> <TAB> if '"""' in line : <TAB> <TAB> <TAB> <TAB> self. mode = "normal" <TAB> <TAB> <TAB> <TAB> self. docstring ( self. text. strip ( ). strip ( '"' ) ) <TAB> <TAB> <TAB> <TAB> self. text = "" <TAB> <TAB> | False | self.mode == 'in func' | self.mode == 'in doc' | 0.6566042900085449 |
104 | 102 | def _convert_upsample ( inexpr, keras_layer, etab ) : <TAB> _check_data_format ( keras_layer ) <TAB> upsample_type = type ( keras_layer ). __name__ <TAB> params = { } <TAB> if upsample_type == "UpSampling1D" : <TAB> <TAB> h = keras_layer. size <TAB> <TAB> params [ "scale_h" ] = h <TAB> elif upsample_type == "UpSampling2D" : <TAB> <TAB> h, w = keras_layer. size <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise tvm. error. OpAttributeInvalid ( <TAB> <TAB> <TAB> <TAB> "Height must equal width for operator Upsample." <TAB> <TAB> <TAB> ) <TAB> <TAB> params [ "scale_h" ] = h <TAB> <TAB> params [ "scale_w" ] = h <TAB> <TAB> if hasattr ( keras_layer, "interpolation" ) : <TAB> <TAB> <TAB> interpolation = keras_layer. interpolation <TAB> <TAB> <TAB> if interpolation == "nearest" : <TAB> <TAB> <TAB> <TAB> params [ "method" ] = "nearest_neighbor" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> params [ "method" ] = "bilinear" <TAB> else : <TAB> <TAB> raise tvm. error. OpNotImplemented ( <TAB> <TAB> <TAB> "Operator {} is not supported for frontend Keras.". format ( upsample_type ) <TAB> <TAB> ) <TAB> params [ "layout" ] = etab. data_layout <TAB> out = _op. nn. upsampling ( inexpr, ** params ) <TAB> return out | True | h != w | h != w | 0.6931537985801697 |
105 | 103 | def apply_transformation ( self, cli, document, lineno, source_to_display, tokens ) : <TAB> <TAB> key = ( cli. render_counter, document. text, document. cursor_position ) <TAB> positions = self. _positions_cache. get ( <TAB> <TAB> key, lambda : self. _get_positions_to_highlight ( document ) <TAB> ) <TAB> <TAB> if positions : <TAB> <TAB> for row, col in positions : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> col = source_to_display ( col ) <TAB> <TAB> <TAB> <TAB> tokens = explode_tokens ( tokens ) <TAB> <TAB> <TAB> <TAB> token, text = tokens [ col ] <TAB> <TAB> <TAB> <TAB> if col == document. cursor_position_col : <TAB> <TAB> <TAB> <TAB> <TAB> token += ( ":", ) + Token. MatchingBracket. Cursor <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> token += ( ":", ) + Token. MatchingBracket. Other <TAB> <TAB> <TAB> <TAB> tokens [ col ] = ( token, text ) <TAB> return Transformation ( tokens ) | False | row == lineno | source_to_display and col != -1 | 0.6775771379470825 |
106 | 104 | def download ( self, * args, ** kwargs ) : <TAB> fmt = self. query. get ( "format", "spec" ) <TAB> version = self. query. get ( "version", None ) <TAB> branch = self. query. get ( "branch", None ) <TAB> selector = self. query. get ( "selector" ) or "css" <TAB> spider_id = self. kwargs. get ( "spider_id", None ) <TAB> spiders = [ spider_id ] if spider_id is not None else None <TAB> try : <TAB> <TAB> self. project <TAB> except InvalidFilename as e : <TAB> <TAB> raise JsonApiNotFoundError ( str ( e ) ) <TAB> if hasattr ( self. storage, "checkout" ) and ( version or branch ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> version = self. commit_from_short_sha ( version ). id <TAB> <TAB> <TAB> self. storage. checkout ( version, branch ) <TAB> <TAB> except IOError : <TAB> <TAB> <TAB> pass <TAB> <TAB> except ValueError as e : <TAB> <TAB> <TAB> raise JsonApiNotFoundError ( str ( e ) ) <TAB> archiver = CodeProjectArchiver if fmt == u"code" else ProjectArchiver <TAB> try : <TAB> <TAB> content = archiver ( self. storage ). archive ( spiders, selector = selector ) <TAB> except IOError as e : <TAB> <TAB> raise JsonApiNotFoundError ( str ( e ) ) <TAB> try : <TAB> <TAB> name = u"{}.zip". format ( self. project. name ) <TAB> except UnicodeEncodeError : <TAB> <TAB> name = str ( self. project. id ) <TAB> return FileResponse ( name, content, status = HTTP_200_OK ) | False | version and len(version) < 40 | version | 0.653167724609375 |
107 | 105 | def check_smtp_login ( self ) : <TAB> if self. urlwatch_config. smtp_login : <TAB> <TAB> config = self. urlwatcher. config_storage. config [ "report" ] [ "email" ] <TAB> <TAB> smtp_config = config [ "smtp" ] <TAB> <TAB> success = True <TAB> <TAB> if not config [ "enabled" ] : <TAB> <TAB> <TAB> print ( "Please enable e-mail reporting in the config first." ) <TAB> <TAB> <TAB> success = False <TAB> <TAB> if config [ "method" ]!= "smtp" : <TAB> <TAB> <TAB> print ( "Please set the method to SMTP for the e-mail reporter." ) <TAB> <TAB> <TAB> success = False <TAB> <TAB> if not smtp_config. get ( "auth", smtp_config. get ( "keyring", False ) ) : <TAB> <TAB> <TAB> print ( "Authentication must be enabled for SMTP." ) <TAB> <TAB> <TAB> success = False <TAB> <TAB> smtp_hostname = smtp_config [ "host" ] <TAB> <TAB> if not smtp_hostname : <TAB> <TAB> <TAB> print ( "Please configure the SMTP hostname in the config first." ) <TAB> <TAB> <TAB> success = False <TAB> <TAB> smtp_username = smtp_config. get ( "user", None ) or config [ "from" ] <TAB> <TAB> if not smtp_username : <TAB> <TAB> <TAB> print ( "Please configure the SMTP user in the config first." ) <TAB> <TAB> <TAB> success = False <TAB> <TAB> if not success : <TAB> <TAB> <TAB> sys. exit ( 1 ) <TAB> <TAB> if "insecure_password" in smtp_config : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> 'The password is already set in the config (key "insecure_password").' <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> sys. exit ( 0 ) <TAB> <TAB> if<mask> : < | False | have_password(smtp_hostname, smtp_username) | not success | 0.6479407548904419 |
108 | 106 | def reverse_url ( self, name : str, * args : Any ) -> Optional [ str ] : <TAB> if name in self. named_rules : <TAB> <TAB> return self. named_rules [ name ]. matcher. reverse ( * args ) <TAB> for rule in self. rules : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> reversed_url = rule. target. reverse_url ( name, * args ) <TAB> <TAB> <TAB> if reversed_url is not None : <TAB> <TAB> <TAB> <TAB> return reversed_url <TAB> return None | False | isinstance(rule.target, ReversibleRouter) | rule.target | 0.6487054824829102 |
109 | 107 | def handle ( self, * args, ** options ) : <TAB> if not settings. ST_BASE_DIR. endswith ( "spirit" ) : <TAB> <TAB> raise CommandError ( <TAB> <TAB> <TAB> "settings.ST_BASE_DIR is not the spirit root folder, are you overriding it?" <TAB> <TAB> ) <TAB> for root, dirs, files in os. walk ( settings. ST_BASE_DIR ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> with utils. pushd ( root ) : <TAB> <TAB> <TAB> call_command ( <TAB> <TAB> <TAB> <TAB> "makemessages", stdout = self. stdout, stderr = self. stderr, ** options <TAB> <TAB> <TAB> ) <TAB> self. stdout. write ( "ok" ) | False | 'locale' not in dirs | not files | 0.6600162982940674 |
110 | 108 | def _declare ( self, name, obj, included = False, quals = 0 ) : <TAB> if name in self. _declarations : <TAB> <TAB> prevobj, prevquals = self. _declarations [ name ] <TAB> <TAB> if prevobj is obj and prevquals == quals : <TAB> <TAB> <TAB> return <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise api. FFIError ( <TAB> <TAB> <TAB> <TAB> "multiple declarations of %s (for interactive usage, " <TAB> <TAB> <TAB> <TAB> "try cdef(xx, override=True))" % ( name, ) <TAB> <TAB> <TAB> ) <TAB> assert "__dotdotdot__" not in name. split ( ) <TAB> self. _declarations [ name ] = ( obj, quals ) <TAB> if included : <TAB> <TAB> self. _included_declarations. add ( obj ) | False | not self._override | nexus.interactive and quals > 0 | 0.6699138879776001 |
111 | 109 | def EnumerateUsersFromClient ( args ) : <TAB> """Enumerates all the users on this system.""" <TAB> del args <TAB> users = _ParseWtmp ( ) <TAB> for user, last_login in users. items ( ) : <TAB> <TAB> <TAB> <TAB> username, _ = user. split ( b"\x00", 1 ) <TAB> <TAB> username = username. decode ( "utf-8" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if last_login < 0 : <TAB> <TAB> <TAB> <TAB> last_login = 0 <TAB> <TAB> <TAB> result = rdf_client. User ( username = username, last_logon = last_login * 1000000 ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> pwdict = pwd. getpwnam ( username ) <TAB> <TAB> <TAB> <TAB> result. homedir = utils. SmartUnicode ( pwdict. pw_dir ) <TAB> <TAB> <TAB> <TAB> result. full_name = utils. SmartUnicode ( pwdict. pw_gecos ) <TAB> <TAB> <TAB> <TAB> result. uid = pwdict. pw_uid <TAB> <TAB> <TAB> <TAB> result. gid = pwdict. pw_gid <TAB> <TAB> <TAB> <TAB> result. shell = utils. SmartUnicode ( pwdict. pw_shell ) <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> yield result | True | username | username | 0.6927834153175354 |
112 | 110 | def _get_vif_port ( self, name ) : <TAB> external_ids = self. db_get_map ( "Interface", name, "external_ids" ) <TAB> if "iface-id" in external_ids and "attached-mac" in external_ids : <TAB> <TAB> return self. _vifport ( name, external_ids ) <TAB> elif "xs-vif-uuid" in external_ids and "attached-mac" in external_ids : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ofport = self. db_get_val ( "Interface", name, "ofport" ) <TAB> <TAB><mask> : <TAB> <TAB> return VifPort ( name, ofport, iface_id, external_ids [ "attached-mac" ], self ) | False | iface_id = self.get_xapi_iface_id(external_ids['xs-vif-uuid']) | ofport is not None | 0.6441446542739868 |
113 | 111 | def checkpoint ( vd ) : <TAB> vd. undoPids. append ( os. getpid ( ) ) <TAB> pid = os. fork ( ) <TAB> if pid > 0 : <TAB> <TAB> before = time. time ( ) <TAB> <TAB> pid, st = os. wait ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> vd. scr. clear ( ) <TAB> <TAB> <TAB> vd. undoPids. remove ( os. getpid ( ) ) <TAB> <TAB> <TAB> raise Exception ( "undid %ss" % int ( time. time ( ) - before ) ) | False | st == 42 | pid > 0 | 0.66758131980896 |
114 | 112 | def prune ( self, study : "optuna.study.Study", trial : "optuna.trial.FrozenTrial" ) -> bool : <TAB> step = trial. last_step <TAB> if step is None : <TAB> <TAB> return False <TAB> rung = _get_current_rung ( trial ) <TAB> value = trial. intermediate_values [ step ] <TAB> trials : Optional [ List [ "optuna.trial.FrozenTrial" ] ] = None <TAB> while True : <TAB> <TAB> if self. _min_resource is None : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> trials = study. get_trials ( deepcopy = False ) <TAB> <TAB> <TAB> self. _min_resource = _estimate_min_resource ( trials ) <TAB> <TAB> <TAB> if self. _min_resource is None : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> assert self. _min_resource is not None <TAB> <TAB> rung_promotion_step = self. _min_resource * ( <TAB> <TAB> <TAB> self. _reduction_factor ** ( self. _min_early_stopping_rate + rung ) <TAB> <TAB> ) <TAB> <TAB> if step < rung_promotion_step : <TAB> <TAB> <TAB> return False <TAB> <TAB> if math. isnan ( value ) : <TAB> <TAB> <TAB> return True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> trials = study. get_trials ( deepcopy = False ) <TAB> <TAB> rung_key = _completed_rung_key ( rung ) <TAB> <TAB> study. _storage. set_trial_system_attr ( trial. _trial_id, rung_key, value ) <TAB> <TAB> competing = _get_competing_values ( trials, value, rung_key ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( competing ) <= self. _bootstrap_count | False | trials is None | study.has_trials() | 0.6724114418029785 |
115 | 113 | def __call__ ( self, loss, sess ) : <TAB> if self. sign * loss > self. sign * self. best : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tf. logging. info ( "Previous best %s: %.4f.", self. label, self. best ) <TAB> <TAB> <TAB> tf. gfile. MakeDirs ( os. path. dirname ( self. save_path ) ) <TAB> <TAB> <TAB> self. saver. save ( sess, self. save_path ) <TAB> <TAB> <TAB> tf. logging. info ( <TAB> <TAB> <TAB> <TAB> "Storing best model so far with loss %.4f at %s." <TAB> <TAB> <TAB> <TAB> % ( loss, self. save_path ) <TAB> <TAB> <TAB> ) <TAB> <TAB> self. best = loss <TAB> <TAB> self. age = 0 <TAB> <TAB> self. true_age = 0 <TAB> else : <TAB> <TAB> self. age += 1 <TAB> <TAB> self. true_age += 1 <TAB> <TAB> if self. age > self. patience : <TAB> <TAB> <TAB> sess. run ( [ self. decay_op ] ) <TAB> <TAB> <TAB> self. age = 0 | False | FLAGS.log_progress | self.save_path and (not self.save_path.exists()) | 0.6573533415794373 |
116 | 114 | def filter ( <TAB> self, <TAB> projects = None, <TAB> tags = None, <TAB> ignore_projects = None, <TAB> ignore_tags = None, <TAB> span = None, <TAB> include_partial_frames = False, ) : <TAB> for frame in self. _rows : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if ignore_projects is not None and frame. project in ignore_projects : <TAB> <TAB> <TAB> continue <TAB> <TAB> if tags is not None and not any ( tag in frame. tags for tag in tags ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if ignore_tags is not None and any ( tag in frame. tags for tag in ignore_tags ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if span is None : <TAB> <TAB> <TAB> yield frame <TAB> <TAB> elif frame in span : <TAB> <TAB> <TAB> yield frame <TAB> <TAB> elif include_partial_frames and span. overlaps ( frame ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> start = span. start if frame. start < span. start else frame. start <TAB> <TAB> <TAB> stop = span. stop if frame. stop > span. stop else frame. stop <TAB> <TAB> <TAB> yield frame. _replace ( start = start, stop = stop ) | False | projects is not None and frame.project not in projects | projects is None | 0.6588723659515381 |
117 | 115 | def parse ( wb ) : <TAB> rst, key = [ ], { } <TAB> for ws in wb. worksheets : <TAB> <TAB> rst. append ( ( ws. title, [ ] ) ) <TAB> <TAB> for row in ws. rows : <TAB> <TAB> <TAB> for cell in row : <TAB> <TAB> <TAB> <TAB> if not isinstance ( cell. value, str ) : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> cont = cell. value [ 1 : - 1 ]. strip ( ) <TAB> <TAB> <TAB> <TAB> tp = cont. split ( " " ) [ 0 ] <TAB> <TAB> <TAB> <TAB> cont = cont [ len ( tp ) : ]. strip ( ) <TAB> <TAB> <TAB> <TAB> note, value = "no description", None <TAB> <TAB> <TAB> <TAB> if "#" in cont : <TAB> <TAB> <TAB> <TAB> <TAB> note = cont. split ( "#" ) [ - 1 ]. strip ( ) <TAB> <TAB> <TAB> <TAB> <TAB> cont = cont [ : cont. index ( "#" ) ]. strip ( ) <TAB> <TAB> <TAB> <TAB> if "=" in cont : <TAB> <TAB> <TAB> <TAB> <TAB> value = cont. split ( "=" ) [ 1 ]. strip ( ) <TAB> <TAB> <TAB> <TAB> <TAB> name = cont [ : cont. index ( "=" ) ]. strip ( ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> name = cont <TAB> <TAB> <TAB> <TAB> rst [ - 1 ] [ - 1 ]. append ( ( ( cell. row, cell. col_idx ), [ tp, name, value, note ] ) ) <TAB> <TAB> <TAB> <TAB> key [ name ] = [ tp, name, value, note ] <TAB> | False | cell.value[0] + cell.value[-1] != '{}' | cont.col_idx > len(cont) | 0.6567429900169373 |
118 | 116 | def parse_flash_log ( self, logf ) : <TAB> """parse flash logs""" <TAB> data = OrderedDict ( ) <TAB> samplelogs = self. split_log ( logf [ "f" ] ) <TAB> for slog in samplelogs : <TAB> <TAB> try : <TAB> <TAB> <TAB> sample = dict ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> s_name = self. clean_pe_name ( slog, logf [ "root" ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> sample [ "s_name" ] = s_name <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sample [ "totalpairs" ] = self. get_field ( "Total pairs", slog ) <TAB> <TAB> <TAB> sample [ "discardpairs" ] = self. get_field ( "Discarded pairs", slog ) <TAB> <TAB> <TAB> sample [ "percdiscard" ] = self. get_field ( "Percent Discarded", slog, fl = True ) <TAB> <TAB> <TAB> sample [ "combopairs" ] = self. get_field ( "Combined pairs", slog ) <TAB> <TAB> <TAB> sample [ "inniepairs" ] = self. get_field ( "Innie pairs", slog ) <TAB> <TAB> <TAB> sample [ "outiepairs" ] = self. get_field ( "Outie pairs", slog ) <TAB> <TAB> <TAB> sample [ "uncombopairs" ] = self. get_field ( "Uncombined pairs", slog ) <TAB> <TAB> <TAB> sample [ "perccombo" ] = self. get_field ( "Percent combined", slog, fl = True ) <TAB> <TAB> <TAB> data [ s_name ] = sample <TAB> <TAB> except Exception as err : <TAB> <TAB> <TAB> log. warning ( "Error parsing record in {}. {}". format ( logf [ "fn" ] | True | s_name is None | s_name is None | 0.6595491170883179 |
119 | 117 | def import_refs ( <TAB> self, <TAB> base, <TAB> other, <TAB> committer = None, <TAB> timestamp = None, <TAB> timezone = None, <TAB> message = None, <TAB> prune = False, ) : <TAB> if prune : <TAB> <TAB> to_delete = set ( self. subkeys ( base ) ) <TAB> else : <TAB> <TAB> to_delete = set ( ) <TAB> for name, value in other. items ( ) : <TAB> <TAB> if value is None : <TAB> <TAB> <TAB> to_delete. add ( name ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. set_if_equals ( b"/". join ( ( base, name ) ), None, value, message = message ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> to_delete. remove ( name ) <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> pass <TAB> for ref in to_delete : <TAB> <TAB> self. remove_if_equals ( b"/". join ( ( base, ref ) ), None, message = message ) | False | to_delete | len(to_delete) > 0 | 0.6647946238517761 |
120 | 118 | def remove ( self, values ) : <TAB> if not isinstance ( values, ( list, tuple, set ) ) : <TAB> <TAB> values = [ values ] <TAB> for v in values : <TAB> <TAB> v = str ( v ) <TAB> <TAB> if isinstance ( self. _definition, dict ) : <TAB> <TAB> <TAB> self. _definition. pop ( v, None ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if v == "ANY" : <TAB> <TAB> <TAB> <TAB> self. _definition = [ ] <TAB> <TAB> elif v in self. _definition : <TAB> <TAB> <TAB> self. _definition. remove ( v ) <TAB> if ( <TAB> <TAB> self. _value is not None <TAB> <TAB> and self. _value not in self. _definition <TAB> <TAB> and self. _not_any ( ) <TAB> ) : <TAB> <TAB> raise ConanException ( bad_value_msg ( self. _name, self. _value, self. values_range ) ) | False | self._definition == 'ANY' | isinstance(self._definition, dict) | 0.6586019992828369 |
121 | 119 | def taiga ( request, trigger_id, key ) : <TAB> signature = request. META. get ( "HTTP_X_TAIGA_WEBHOOK_SIGNATURE" ) <TAB> <TAB> if verify_signature ( request. _request. body, key, signature ) : <TAB> <TAB> data = data_filter ( trigger_id, ** request. data ) <TAB> <TAB> status = save_data ( trigger_id, data ) <TAB> <TAB> return ( <TAB> <TAB> <TAB> Response ( { "message" : "Success" } ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else Response ( { "message" : "Failed!" } ) <TAB> <TAB> ) <TAB> Response ( { "message" : "Bad request" } ) | True | status | status | 0.6869302988052368 |
122 | 120 | def genLoopPackets ( self ) : <TAB> while True : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. mode == "simulator" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. real_time : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sleep_time = self. the_time + self. loop_interval - time. time ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> time. sleep ( sleep_time ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> time. sleep ( self. loop_interval ) <TAB> <TAB> <TAB> <TAB> self. the_time += self. loop_interval <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> avg_time = self. the_time - self. loop_interval / 2.0 <TAB> <TAB> _packet = { "dateTime" : int ( self. the_time + 0.5 ), "usUnits" : weewx. US } <TAB> <TAB> for obs_type in self. observations : <TAB> <TAB> <TAB> _packet [ obs_type ] = self. observations [ obs_type ]. value_at ( avg_time ) <TAB> <TAB> yield _packet | False | sleep_time > 0 | self.sleep_time | 0.6646113991737366 |
123 | 121 | def input_str ( <TAB> self, <TAB> s, <TAB> default_value = None, <TAB> valid_list = None, <TAB> show_default_value = True, <TAB> help_message = None, ) : <TAB> if show_default_value and default_value is not None : <TAB> <TAB> s = f"[{default_value}] {s}" <TAB> if valid_list is not None or help_message is not None : <TAB> <TAB> s += " (" <TAB> if valid_list is not None : <TAB> <TAB> s += " " + "/". join ( valid_list ) <TAB> if help_message is not None : <TAB> <TAB> s += "?:help" <TAB> if valid_list is not None or help_message is not None : <TAB> <TAB> s += " )" <TAB> s += " : " <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> inp = input ( s ) <TAB> <TAB> <TAB> if len ( inp ) == 0 : <TAB> <TAB> <TAB> <TAB> if default_value is None : <TAB> <TAB> <TAB> <TAB> <TAB> print ( "" ) <TAB> <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> <TAB> result = default_value <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if help_message is not None and inp == "?" : <TAB> <TAB> <TAB> <TAB> print ( help_message ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if valid_list is not None : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> result = inp. lower ( ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> if inp in valid_list : <TAB> <TAB> <TAB> <TAB> <TAB> result = inp <TAB> <TAB> <TAB> <TAB | False | inp.lower() in valid_list | inp in show_default_value | 0.658090353012085 |
124 | 122 | def split_version_and_name ( <TAB> major = None, <TAB> minor = None, <TAB> patch = None, <TAB> name = None, ) : <TAB> <TAB> if isinstance ( major, six. string_types ) and not minor and not patch : <TAB> <TAB> <TAB> <TAB> if major. isdigit ( ) or ( major. count ( "." ) > 0 and major [ 0 ]. isdigit ( ) ) : <TAB> <TAB> <TAB> version = major. split ( ".", 2 ) <TAB> <TAB> <TAB> if isinstance ( version, ( tuple, list ) ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> major, minor, patch, _ = version <TAB> <TAB> <TAB> <TAB> elif len ( version ) == 3 : <TAB> <TAB> <TAB> <TAB> <TAB> major, minor, patch = version <TAB> <TAB> <TAB> <TAB> elif len ( version ) == 2 : <TAB> <TAB> <TAB> <TAB> <TAB> major, minor = version <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> major = major [ 0 ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> major = major <TAB> <TAB> <TAB> <TAB> name = None <TAB> <TAB> else : <TAB> <TAB> <TAB> name = "{0!s}". format ( major ) <TAB> <TAB> <TAB> major = None <TAB> return ( major, minor, patch, name ) | False | len(version) > 3 | len(version) == 1 | 0.6591365337371826 |
125 | 123 | def parse_workflow_directory ( workflow_directory ) : <TAB> parsed = { <TAB> <TAB> "versions" : [ ], <TAB> } <TAB> <TAB> if not os. path. exists ( workflow_directory ) : <TAB> <TAB> raise WorkflowError ( "Workflow directory does not exist." ) <TAB> <TAB> workflow_files = os. listdir ( workflow_directory ) <TAB> if "workflow.json" not in workflow_files : <TAB> <TAB> raise WorkflowError ( 'No "workflow.json" manifest file found.' ) <TAB> with open ( os. path. join ( workflow_directory, "workflow.json" ), "r" ) as f : <TAB> <TAB> parsed [ "workflow" ] = json. load ( f ) <TAB> <TAB> workflow_subdirs = [ <TAB> <TAB> os. path. join ( workflow_directory, workflow_file ) <TAB> <TAB> for workflow_file in workflow_files <TAB> <TAB> if os. path. isdir ( os. path. join ( workflow_directory, workflow_file ) ) <TAB> ] <TAB> for version_directory in workflow_subdirs : <TAB> <TAB> version_files = os. listdir ( version_directory ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> with open ( os. path. join ( version_directory, "version.json" ), "r" ) as f : <TAB> <TAB> <TAB> parsed [ "versions" ]. append ( json. load ( f ) ) <TAB> <TAB> if len ( parsed [ "versions" ] ) == 0 : <TAB> <TAB> raise WorkflowError ( <TAB> <TAB> <TAB> "Workflow directory {} does not contain any " <TAB> <TAB> <TAB> "versions". format ( workflow_directory ) <TAB> <TAB> ) <TAB> return parsed | False | 'version.json' not in version_files | len(version_files) > 0 | 0.6484920978546143 |
126 | 124 | def not_modssl_ifmodule ( self, path ) : <TAB> """Checks if the provided Augeas path has argument!mod_ssl""" <TAB> if "ifmodule" not in path. lower ( ) : <TAB> <TAB> return False <TAB> <TAB> workpath = path. lower ( ) <TAB> while workpath : <TAB> <TAB> <TAB> <TAB> parts = workpath. rpartition ( "ifmodule" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> ifmod_path = parts [ 0 ] + parts [ 1 ] <TAB> <TAB> <TAB> <TAB> if parts [ 2 ]. startswith ( "[" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ifmod_path += parts [ 2 ]. partition ( "/" ) [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ifmod_real_path = path [ 0 : len ( ifmod_path ) ] <TAB> <TAB> if "!mod_ssl.c" in self. get_all_args ( ifmod_real_path ) : <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> workpath = parts [ 0 ] <TAB> return False | False | not parts[0] | len(parts) == 0 | 0.6571704745292664 |
127 | 125 | def read_config_file ( args ) : <TAB> if os. path. isfile ( args. config_file ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> with open ( args. config_file ) as f : <TAB> <TAB> <TAB> <TAB> config = json. load ( f ) <TAB> <TAB> <TAB> <TAB> for key, elem in config. items ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yellow ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> "{} has an unknown key: {} : {}". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> args. config_file, key, elem <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> if getattr ( args, key ) == defaults_flag_in_config [ key ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> setattr ( args, key, elem ) <TAB> <TAB> except json. decoder. JSONDecodeError as e : <TAB> <TAB> <TAB> logger. error ( <TAB> <TAB> <TAB> <TAB> red ( <TAB> <TAB> <TAB> <TAB> <TAB> "Impossible to read {}, please check the file {}". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> args. config_file, e <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB | True | key not in defaults_flag_in_config | key not in defaults_flag_in_config | 0.6513499021530151 |
128 | 126 | def consume ( self, data : Dict [ str, Any ] ) -> None : <TAB> <TAB> user_profile = get_user_profile_by_id ( data [ "user_id" ] ) <TAB> logging. info ( <TAB> <TAB> "Processing signup for user %s in realm %s", <TAB> <TAB> user_profile. id, <TAB> <TAB> user_profile. realm. string_id, <TAB> ) <TAB> if settings. MAILCHIMP_API_KEY and settings. PRODUCTION : <TAB> <TAB> endpoint = "https://{}.api.mailchimp.com/3.0/lists/{}/members". format ( <TAB> <TAB> <TAB> settings. MAILCHIMP_API_KEY. split ( "-" ) [ 1 ], <TAB> <TAB> <TAB> settings. ZULIP_FRIENDS_LIST_ID, <TAB> <TAB> ) <TAB> <TAB> params = dict ( data ) <TAB> <TAB> del params [ "user_id" ] <TAB> <TAB> params [ "list_id" ] = settings. ZULIP_FRIENDS_LIST_ID <TAB> <TAB> params [ "status" ] = "subscribed" <TAB> <TAB> r = requests. post ( <TAB> <TAB> <TAB> endpoint, <TAB> <TAB> <TAB> auth = ( "apikey", settings. MAILCHIMP_API_KEY ), <TAB> <TAB> <TAB> json = params, <TAB> <TAB> <TAB> timeout = 10, <TAB> <TAB> ) <TAB> <TAB> if r. status_code == 400 and orjson. loads ( r. content ) [ "title" ] == "Member Exists" : <TAB> <TAB> <TAB> logging. warning ( <TAB> <TAB> <TAB> <TAB> "Attempted to sign up already existing email to list: %s", <TAB> <TAB> <TAB> <TAB> data [ "email_address" ], <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> retry_event ( self. queue_name, data, lambda e | False | r.status_code == 400 | r.status_code == 200 | 0.6552725434303284 |
129 | 127 | def _read_model_arguments ( argv, use_argparse = False ) : <TAB> if use_argparse : <TAB> <TAB> parser = argparse. ArgumentParser ( ) <TAB> <TAB> parser. add_argument ( <TAB> <TAB> <TAB> "database", <TAB> <TAB> <TAB> metavar = "DATABASE", <TAB> <TAB> <TAB> type = str, <TAB> <TAB> <TAB> default = "galaxy", <TAB> <TAB> <TAB> nargs = "?", <TAB> <TAB> <TAB> help = "database to target (galaxy, tool_shed, install)", <TAB> <TAB> ) <TAB> <TAB> populate_config_args ( parser ) <TAB> <TAB> args = parser. parse_args ( argv [ 1 : ] if argv else [ ] ) <TAB> <TAB> return args. config_file, args. config_section, args. database <TAB> else : <TAB> <TAB> config_file = None <TAB> <TAB> for arg in [ "-c", "--config", "--config-file" ] : <TAB> <TAB> <TAB> if arg in argv : <TAB> <TAB> <TAB> <TAB> pos = argv. index ( arg ) <TAB> <TAB> <TAB> <TAB> argv. pop ( pos ) <TAB> <TAB> <TAB> <TAB> config_file = argv. pop ( pos ) <TAB> <TAB> config_section = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pos = argv. index ( "--config-section" ) <TAB> <TAB> <TAB> argv. pop ( pos ) <TAB> <TAB> <TAB> config_section = argv. pop ( pos ) <TAB> <TAB> if argv and ( argv [ - 1 ] in DATABASE ) : <TAB> <TAB> <TAB> database = argv. pop ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> database = "galaxy" <TAB> <TAB> return config_file, config_section, database | False | '--config-section' in argv | argv and argv[--config - section] in CONFIG_FILE | 0.653885006904602 |
130 | 128 | def seen_add ( options ) : <TAB> seen_name = options. add_value <TAB> if is_imdb_url ( seen_name ) : <TAB> <TAB> console ( "IMDB url detected, try to parse ID" ) <TAB> <TAB> imdb_id = extract_id ( seen_name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> seen_name = imdb_id <TAB> <TAB> else : <TAB> <TAB> <TAB> console ( "Could not parse IMDB ID" ) <TAB> db. add ( seen_name, "cli_add", { "cli_add" : seen_name } ) <TAB> console ( "Added %s as seen. This will affect all tasks." % seen_name ) | True | imdb_id | imdb_id | 0.6628228425979614 |
131 | 129 | def translate_apply ( self, exp ) : <TAB> pre = [ ] <TAB> callable_pre, callable_value = self. translate ( exp [ 0 ], False ) <TAB> pre. extend ( callable_pre ) <TAB> args = [ ] <TAB> keyword_args = [ ] <TAB> keyword_arg_exps = [ ] <TAB> arg_exps = exp [ 1 : ] <TAB> for i, argexp in enumerate ( arg_exps ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> keyword_arg_exps = arg_exps [ i : ] <TAB> <TAB> <TAB> arg_exps = arg_exps [ : i ] <TAB> <TAB> <TAB> break <TAB> for argexp in arg_exps : <TAB> <TAB> arg_pre, arg_value = self. translate ( argexp, False ) <TAB> <TAB> pre. extend ( arg_pre ) <TAB> <TAB> args. append ( arg_value ) <TAB> for argKey, argExp in chunks ( keyword_arg_exps, 2 ) : <TAB> <TAB> if type ( argKey ) is not Keyword : <TAB> <TAB> <TAB> raise MochiSyntaxError ( argKey, self. filename ) <TAB> <TAB> arg_pre, arg_value = self. translate ( argExp, False ) <TAB> <TAB> pre. extend ( arg_pre ) <TAB> <TAB> keyword_args. append ( ast. keyword ( arg = argKey. name, value = arg_value ) ) <TAB> value = ast. Call ( <TAB> <TAB> func = callable_value, <TAB> <TAB> args = args, <TAB> <TAB> keywords = keyword_args, <TAB> <TAB> starargs = None, <TAB> <TAB> kwargs = None, <TAB> <TAB> lineno = callable_value. lineno, <TAB> <TAB> col_offset = 0, <TAB> ) <TAB> return pre, value | True | type(argexp) is Keyword | type(argexp) is Keyword | 0.6585877537727356 |
132 | 130 | def parse_shoutcast1 ( url, timeout = 5 ) : <TAB> """A Shoutcast object of raises ParseError""" <TAB> root = get_root ( url ) <TAB> shoutcast1_status = root + "/7.html" <TAB> headers = { "User-Agent" : "Mozilla/4.0" } <TAB> try : <TAB> <TAB> r = requests. get ( <TAB> <TAB> <TAB> shoutcast1_status, headers = headers, timeout = timeout, stream = True <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ParseError <TAB> <TAB> r. content <TAB> except ( RequestException, socket. timeout ) : <TAB> <TAB> raise ParseError <TAB> if r. status_code!= 200 : <TAB> <TAB> raise ParseError <TAB> soup = BeautifulSoup ( r. content ) <TAB> body = soup. find ( "body" ) <TAB> if not body : <TAB> <TAB> raise ParseError <TAB> status_line = body. string <TAB> if status_line is None : <TAB> <TAB> raise ParseError <TAB> try : <TAB> <TAB> current, status, peak, max_, unique, bitrate, songtitle = status_line. split ( <TAB> <TAB> <TAB> ",", 6 <TAB> <TAB> ) <TAB> except ValueError : <TAB> <TAB> raise ParseError <TAB> try : <TAB> <TAB> peak = str ( int ( peak ) ) <TAB> <TAB> current = str ( int ( current ) ) <TAB> except ValueError : <TAB> <TAB> raise ParseError <TAB> return Stream ( root, current, peak ) | False | 'text' not in r.headers.get('content-type', '') | r.status_code == 404 | 0.6462410688400269 |
133 | 131 | def reconnect_user ( self, user_id, host_id, server_id ) : <TAB> if host_id == settings. local. host_id : <TAB> <TAB> return <TAB> if server_id and self. server. id!= server_id : <TAB> <TAB> return <TAB> for client in self. clients. find ( { "user_id" : user_id } ) : <TAB> <TAB> self. clients. update_id ( <TAB> <TAB> <TAB> client [ "id" ], <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> "ignore_routes" : True, <TAB> <TAB> <TAB> }, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. instance. disconnect_wg ( client [ "id" ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. instance_com. client_kill ( client [ "id" ] ) | False | len(client['id']) > 32 | self.instance_com is None | 0.6541067361831665 |
134 | 132 | def __init__ ( self, * args, ** decimals ) : <TAB> self. amounts = OrderedDict ( <TAB> <TAB> ( currency, decimals. get ( currency, Money. ZEROS [ currency ]. amount ) ) <TAB> <TAB> for currency in CURRENCIES <TAB> ) <TAB> for arg in args : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. amounts [ arg. currency ] += arg. amount <TAB> <TAB> else : <TAB> <TAB> <TAB> for m in arg : <TAB> <TAB> <TAB> <TAB> self. amounts [ m. currency ] += m. amount | True | isinstance(arg, Money) | isinstance(arg, Money) | 0.6594305038452148 |
135 | 133 | def _mask_forward_test ( self, stage, x, bboxes, semantic_feat = None ) : <TAB> """Mask head forward function for testing.""" <TAB> mask_roi_extractor = self. mask_roi_extractor [ stage ] <TAB> mask_head = self. mask_head [ stage ] <TAB> mask_rois = bbox2roi ( [ bboxes ] ) <TAB> mask_feats = mask_roi_extractor ( <TAB> <TAB> x [ : len ( mask_roi_extractor. featmap_strides ) ], mask_rois <TAB> ) <TAB> if self. with_semantic and "mask" in self. semantic_fusion : <TAB> <TAB> mask_semantic_feat = self. semantic_roi_extractor ( [ semantic_feat ], mask_rois ) <TAB> <TAB> if mask_semantic_feat. shape [ - 2 : ]!= mask_feats. shape [ - 2 : ] : <TAB> <TAB> <TAB> mask_semantic_feat = F. adaptive_avg_pool2d ( <TAB> <TAB> <TAB> <TAB> mask_semantic_feat, mask_feats. shape [ - 2 : ] <TAB> <TAB> <TAB> ) <TAB> <TAB> mask_feats += mask_semantic_feat <TAB> if self. mask_info_flow : <TAB> <TAB> last_feat = None <TAB> <TAB> last_pred = None <TAB> <TAB> for i in range ( stage ) : <TAB> <TAB> <TAB> mask_pred, last_feat = self. mask_head [ i ] ( mask_feats, last_feat ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> mask_pred = mask_pred + last_pred <TAB> <TAB> <TAB> last_pred = mask_pred <TAB> <TAB> mask_pred = mask_head ( mask_feats, last_feat, return_feat = False ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> mask_pred = mask_pred + last_pred <TAB> else : <TAB> <TAB> mask_pred | False | last_pred is not None | self.mask_info_flow | 0.6654256582260132 |
136 | 134 | def on_completed2 ( ) : <TAB> doner [ 0 ] = True <TAB> if not qr : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> observer. on_next ( False ) <TAB> <TAB> <TAB> observer. on_completed ( ) <TAB> <TAB> elif donel [ 0 ] : <TAB> <TAB> <TAB> observer. on_next ( True ) <TAB> <TAB> <TAB> observer. on_completed ( ) | False | len(ql) > 0 | der[0] | 0.6593277454376221 |
137 | 135 | def modify_vpc_attribute ( self ) : <TAB> vpc_id = self. _get_param ( "VpcId" ) <TAB> for attribute in ( "EnableDnsSupport", "EnableDnsHostnames" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> attr_name = camelcase_to_underscores ( attribute ) <TAB> <TAB> <TAB> attr_value = self. querystring. get ( "%s.Value" % attribute ) [ 0 ] <TAB> <TAB> <TAB> self. ec2_backend. modify_vpc_attribute ( vpc_id, attr_name, attr_value ) <TAB> <TAB> <TAB> return MODIFY_VPC_ATTRIBUTE_RESPONSE | False | self.querystring.get('%s.Value' % attribute) | attribute in self.params | 0.6549067497253418 |
138 | 136 | def TryMerge ( self, d ) : <TAB> while d. avail ( ) > 0 : <TAB> <TAB> tt = d. getVarInt32 ( ) <TAB> <TAB> if tt == 10 : <TAB> <TAB> <TAB> self. set_socket_descriptor ( d. getPrefixedString ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 26 : <TAB> <TAB> <TAB> length = d. getVarInt32 ( ) <TAB> <TAB> <TAB> tmp = ProtocolBuffer. Decoder ( d. buffer ( ), d. pos ( ), d. pos ( ) + length ) <TAB> <TAB> <TAB> d. skip ( length ) <TAB> <TAB> <TAB> self. mutable_server_address ( ). TryMerge ( tmp ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> length = d. getVarInt32 ( ) <TAB> <TAB> <TAB> tmp = ProtocolBuffer. Decoder ( d. buffer ( ), d. pos ( ), d. pos ( ) + length ) <TAB> <TAB> <TAB> d. skip ( length ) <TAB> <TAB> <TAB> self. mutable_proxy_external_ip ( ). TryMerge ( tmp ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 0 : <TAB> <TAB> <TAB> raise ProtocolBuffer. ProtocolBufferDecodeError <TAB> <TAB> d. skipData ( tt ) | False | tt == 34 | tt == 33554432 | 0.681266725063324 |
139 | 137 | def is_accepted_drag_event ( self, event ) : <TAB> if event. source ( ) == self. table : <TAB> <TAB> return True <TAB> mime = event. mimeData ( ) <TAB> if mime. hasUrls ( ) : <TAB> <TAB> for url in mime. urls ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> filename = url. toLocalFile ( ) <TAB> <TAB> <TAB> extension = os. path. splitext ( filename ) [ 1 ]. lower ( ) [ 1 : ] <TAB> <TAB> <TAB> if extension not in _dictionary_formats ( ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> return True <TAB> return False | False | not url.isLocalFile() | url.hasLocalFile() | 0.654245138168335 |
140 | 138 | def clean_new_hostname ( self ) : <TAB> old_ip = self. cleaned_data. get ( "address" ) <TAB> new_hostname = self. cleaned_data [ "new_hostname" ] <TAB> if not is_valid_hostname ( new_hostname ) : <TAB> <TAB> raise forms. ValidationError ( "Invalid hostname" ) <TAB> try : <TAB> <TAB> get_domain ( new_hostname ) <TAB> except Domain. DoesNotExist : <TAB> <TAB> raise forms. ValidationError ( "Invalid domain" ) <TAB> try : <TAB> <TAB> ipaddress = IPAddress. objects. get ( hostname = new_hostname ) <TAB> except IPAddress. DoesNotExist : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise forms. ValidationError ( "Hostname already in DNS." ) <TAB> else : <TAB> <TAB> if ipaddress. device and not ipaddress. device. deleted : <TAB> <TAB> <TAB> if not old_ip : <TAB> <TAB> <TAB> <TAB> raise forms. ValidationError ( "Hostname in use." ) <TAB> <TAB> <TAB> device = Device. objects. get ( ipaddress__address = old_ip ) <TAB> <TAB> <TAB> if ipaddress. device. id!= device. id : <TAB> <TAB> <TAB> <TAB> raise forms. ValidationError ( <TAB> <TAB> <TAB> <TAB> <TAB> "Hostname used by %s" % device, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> elif Record. objects. filter ( name = new_hostname ). exists ( ) : <TAB> <TAB> <TAB> raise forms. ValidationError ( "Hostname already in DNS." ) <TAB> return new_hostname | False | find_addresses_for_hostname(new_hostname) | ipaddress.hostname in ipaddress | 0.6452183127403259 |
141 | 139 | def __getattr__ ( self, name ) : <TAB> <TAB> <TAB> if name. startswith ( "__" ) : <TAB> <TAB> raise AttributeError ( <TAB> <TAB> <TAB> "'{}' does not exist on <Machine@{}>". format ( name, id ( self ) ) <TAB> <TAB> ) <TAB> <TAB> callback_type, target = self. _identify_callback ( name ) <TAB> if callback_type is not None : <TAB> <TAB> if callback_type in self. transition_cls. dynamic_methods : <TAB> <TAB> <TAB> if target not in self. events : <TAB> <TAB> <TAB> <TAB> raise AttributeError ( <TAB> <TAB> <TAB> <TAB> <TAB> "event '{}' is not registered on <Machine@{}>". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> target, id ( self ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return partial ( self. events [ target ]. add_callback, callback_type ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> state = self. get_state ( target ) <TAB> <TAB> <TAB> return partial ( state. add_callback, callback_type [ 3 : ] ) <TAB> try : <TAB> <TAB> return self. __getattribute__ ( name ) <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> raise AttributeError ( <TAB> <TAB> <TAB> "'{}' does not exist on <Machine@{}>". format ( name, id ( self ) ) <TAB> <TAB> ) | False | callback_type in self.state_cls.dynamic_methods | target > self.state | 0.651080846786499 |
142 | 140 | def delete_user ( self, uid ) : <TAB> """Delete a user""" <TAB> if not self. __user_exists ( uid ) : <TAB> <TAB> raise exception. LDAPUserNotFound ( user_id = uid ) <TAB> self. __remove_from_all ( uid ) <TAB> if FLAGS. ldap_user_modify_only : <TAB> <TAB> <TAB> <TAB> attr = [ ] <TAB> <TAB> <TAB> <TAB> user = self. __get_ldap_user ( uid ) <TAB> <TAB> if "secretKey" in user. keys ( ) : <TAB> <TAB> <TAB> attr. append ( ( self. ldap. MOD_DELETE, "secretKey", user [ "secretKey" ] ) ) <TAB> <TAB> if "accessKey" in user. keys ( ) : <TAB> <TAB> <TAB> attr. append ( ( self. ldap. MOD_DELETE, "accessKey", user [ "accessKey" ] ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> attr. append ( <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> self. ldap. MOD_DELETE, <TAB> <TAB> <TAB> <TAB> <TAB> LdapDriver. isadmin_attribute, <TAB> <TAB> <TAB> <TAB> <TAB> user [ LdapDriver. isadmin_attribute ], <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> self. conn. modify_s ( self. __uid_to_dn ( uid ), attr ) <TAB> else : <TAB> <TAB> <TAB> <TAB> self. conn. delete_s ( self. __uid_to_dn ( uid ) ) | False | LdapDriver.isadmin_attribute in user.keys() | ldap.isadmin_attribute | 0.6551808714866638 |
143 | 141 | def setLabel ( self, label ) : <TAB> if label is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. label. scene ( ). removeItem ( self. label ) <TAB> <TAB> <TAB> self. label = None <TAB> else : <TAB> <TAB> if self. label is None : <TAB> <TAB> <TAB> self. label = TextItem ( ) <TAB> <TAB> <TAB> self. label. setParentItem ( self ) <TAB> <TAB> self. label. setText ( label ) <TAB> <TAB> self. _updateLabel ( ) | True | self.label is not None | self.label is not None | 0.6567447185516357 |
144 | 142 | def dispatch_return ( self, frame, arg ) : <TAB> if self. stop_here ( frame ) or frame == self. returnframe : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. trace_dispatch <TAB> <TAB> try : <TAB> <TAB> <TAB> self. frame_returning = frame <TAB> <TAB> <TAB> self. user_return ( frame, arg ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> self. frame_returning = None <TAB> <TAB> if self. quitting : <TAB> <TAB> <TAB> raise BdbQuit <TAB> <TAB> <TAB> <TAB> if self. stopframe is frame and self. stoplineno!= - 1 : <TAB> <TAB> <TAB> self. _set_stopinfo ( None, None ) <TAB> return self. trace_dispatch | False | self.stopframe and frame.f_code.co_flags & CO_GENERATOR | self.trace_dispatch is None | 0.6477848887443542 |
145 | 143 | def allow_hide_post ( user_acl, target ) : <TAB> if user_acl [ "is_anonymous" ] : <TAB> <TAB> raise PermissionDenied ( _ ( "You have to sign in to hide posts." ) ) <TAB> category_acl = user_acl [ "categories" ]. get ( <TAB> <TAB> target. category_id, { "can_hide_posts" : 0, "can_hide_own_posts" : 0 } <TAB> ) <TAB> if not category_acl [ "can_hide_posts" ] : <TAB> <TAB> if not category_acl [ "can_hide_own_posts" ] : <TAB> <TAB> <TAB> raise PermissionDenied ( _ ( "You can't hide posts in this category." ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise PermissionDenied ( <TAB> <TAB> <TAB> <TAB> _ ( "You can't hide other users posts in this category." ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if target. is_protected and not category_acl [ "can_protect_posts" ] : <TAB> <TAB> <TAB> raise PermissionDenied ( _ ( "This post is protected. You can't hide it." ) ) <TAB> <TAB> if not has_time_to_edit_post ( user_acl, target ) : <TAB> <TAB> <TAB> message = ngettext ( <TAB> <TAB> <TAB> <TAB> "You can't hide posts that are older than %(minutes)s minute.", <TAB> <TAB> <TAB> <TAB> "You can't hide posts that are older than %(minutes)s minutes.", <TAB> <TAB> <TAB> <TAB> category_acl [ "post_edit_time" ], <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise PermissionDenied ( <TAB> <TAB> <TAB> <TAB> message % { "minutes" : category_acl [ "post_edit_time" ] } <TAB> <TAB> <TAB> ) <TAB> if target. is_first_post : <TAB> <TAB> raise PermissionDenied ( _ ( "You can't hide | False | user_acl['user_id'] != target.poster_id | target.is_user_post and (not category_acl[ "can_hide_other_post_time_exceeded']) | 0.6479650139808655 |
146 | 144 | def test_dayoffsets ( self ) : <TAB> start = datetime. datetime ( self. yr, self. mth, self. dy, 9 ) <TAB> for date_string, expected_day_offset in [ <TAB> <TAB> ( "Aujourd'hui", 0 ), <TAB> <TAB> ( "aujourd'hui", 0 ), <TAB> <TAB> ( "Demain", 1 ), <TAB> <TAB> ( "demain", 1 ), <TAB> <TAB> ( "Hier", - 1 ), <TAB> <TAB> ( "hier", - 1 ), <TAB> <TAB> ( "au jour de hui", None ), <TAB> ] : <TAB> <TAB> got_dt, rc = self. cal. parseDT ( date_string, start ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( rc, 1 ) <TAB> <TAB> <TAB> target = start + datetime. timedelta ( days = expected_day_offset ) <TAB> <TAB> <TAB> self. assertEqual ( got_dt, target ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. assertEqual ( rc, 0 ) | True | expected_day_offset is not None | expected_day_offset is not None | 0.6547766923904419 |
147 | 145 | def send_messages ( self, messages ) : <TAB> sent_messages = 0 <TAB> for m in messages : <TAB> <TAB> payload = { } <TAB> <TAB> for opt, optval in { <TAB> <TAB> <TAB> "mattermost_icon_url" : "icon_url", <TAB> <TAB> <TAB> "mattermost_channel" : "channel", <TAB> <TAB> <TAB> "mattermost_username" : "username", <TAB> <TAB> }. items ( ) : <TAB> <TAB> <TAB> optvalue = getattr ( self, opt ) <TAB> <TAB> <TAB> if optvalue is not None : <TAB> <TAB> <TAB> <TAB> payload [ optval ] = optvalue. strip ( ) <TAB> <TAB> payload [ "text" ] = m. subject <TAB> <TAB> r = requests. post ( <TAB> <TAB> <TAB> "{}". format ( m. recipients ( ) [ 0 ] ), <TAB> <TAB> <TAB> data = json. dumps ( payload ), <TAB> <TAB> <TAB> verify = ( not self. mattermost_no_verify_ssl ), <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. error ( <TAB> <TAB> <TAB> <TAB> smart_text ( <TAB> <TAB> <TAB> <TAB> <TAB> _ ( "Error sending notification mattermost: {}" ). format ( r. text ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if not self. fail_silently : <TAB> <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> <TAB> smart_text ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _ ( "Error sending notification mattermost: {}" ). format ( r. text ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> sent_messages | False | r.status_code >= 400 | verify | 0.6575757265090942 |
148 | 146 | def get_top_level_stats ( self ) : <TAB> for func, ( cc, nc, tt, ct, callers ) in self. stats. items ( ) : <TAB> <TAB> self. total_calls += nc <TAB> <TAB> self. prim_calls += cc <TAB> <TAB> self. total_tt += tt <TAB> <TAB> if ( "jprofile", 0, "profiler" ) in callers : <TAB> <TAB> <TAB> self. top_level [ func ] = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. max_name_len = len ( func_std_string ( func ) ) | False | len(func_std_string(func)) > self.max_name_len | func | 0.6513847708702087 |
149 | 147 | def read ( self, iprot ) : <TAB> if ( <TAB> <TAB> iprot. _fast_decode is not None <TAB> <TAB> and isinstance ( iprot. trans, TTransport. CReadableTransport ) <TAB> <TAB> and self. thrift_spec is not None <TAB> ) : <TAB> <TAB> iprot. _fast_decode ( self, iprot, ( self. __class__, self. thrift_spec ) ) <TAB> <TAB> return <TAB> iprot. readStructBegin ( ) <TAB> while True : <TAB> <TAB> ( fname, ftype, fid ) = iprot. readFieldBegin ( ) <TAB> <TAB> if ftype == TType. STOP : <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. status = TStatus ( ) <TAB> <TAB> <TAB> <TAB> self. status. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. schema = TTableSchema ( ) <TAB> <TAB> <TAB> <TAB> self. schema. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> else : <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> iprot. readFieldEnd ( ) <TAB> iprot. readStructEnd ( ) | True | fid == 1 | fid == 1 | 0.675361156463623 |
150 | 148 | def __init__ ( self, cga, * args ) -> None : <TAB> super ( ). __init__ ( cga ) <TAB> self. einf = self. cga. einf <TAB> if len ( args ) == 0 : <TAB> <TAB> <TAB> <TAB> nulls = [ self. cga. null_vector ( ) for k in range ( self. layout. dims - 2 ) ] <TAB> <TAB> self. mv = reduce ( op, nulls + [ self. einf ] ) <TAB> elif len ( args ) == 1 : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. mv = args [ 0 ] <TAB> <TAB> <TAB> <TAB> elif isinstance ( args [ 0 ], int ) : <TAB> <TAB> <TAB> dim = args [ 0 ] <TAB> <TAB> <TAB> points = [ self. cga. base_vector ( ) for k in range ( dim + 1 ) ] <TAB> <TAB> <TAB> points = list ( map ( self. cga. up, points ) ) <TAB> <TAB> <TAB> self. mv = reduce ( op, points + [ self. einf ] ) <TAB> <TAB> else : <TAB> <TAB> nulls = map ( self. cga. null_vector, args ) <TAB> <TAB> if self. einf not in nulls : <TAB> <TAB> <TAB> nulls = list ( nulls ) + [ self. einf ] <TAB> <TAB> self. mv = reduce ( op, nulls ) <TAB> self. mv = self. mv. normal ( ) | False | isinstance(args[0], MultiVector) | isinstance(args[0], float) | 0.6587437391281128 |
151 | 149 | def get_final_results ( log_json_path, iter_num ) : <TAB> result_dict = dict ( ) <TAB> with open ( log_json_path, "r" ) as f : <TAB> <TAB> for line in f. readlines ( ) : <TAB> <TAB> <TAB> log_line = json. loads ( line ) <TAB> <TAB> <TAB> if "mode" not in log_line. keys ( ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> result_dict [ "memory" ] = log_line [ "memory" ] <TAB> <TAB> <TAB> if log_line [ "iter" ] == iter_num : <TAB> <TAB> <TAB> <TAB> result_dict. update ( <TAB> <TAB> <TAB> <TAB> <TAB> { key : log_line [ key ] for key in RESULTS_LUT if key in log_line } <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> return result_dict | False | log_line['mode'] == 'train' and log_line['iter'] == iter_num | log_line[0] == 0 | 0.6507238149642944 |
152 | 150 | def argument_action ( self, text, loc, arg ) : <TAB> """Code executed after recognising each of function's arguments""" <TAB> exshared. setpos ( loc, text ) <TAB> if DEBUG > 0 : <TAB> <TAB> print ( "ARGUMENT:", arg. exp ) <TAB> <TAB> if DEBUG == 2 : <TAB> <TAB> <TAB> self. symtab. display ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> arg_ordinal = len ( self. function_arguments ) <TAB> <TAB> if not self. symtab. same_type_as_argument ( <TAB> <TAB> arg. exp, self. function_call_index, arg_ordinal <TAB> ) : <TAB> <TAB> raise SemanticException ( <TAB> <TAB> <TAB> "Incompatible type for argument %d in '%s'" <TAB> <TAB> <TAB> % ( arg_ordinal + 1, self. symtab. get_name ( self. function_call_index ) ) <TAB> <TAB> ) <TAB> self. function_arguments. append ( arg. exp ) | False | DEBUG > 2 | self.function_arguments is None | 0.6751142144203186 |
153 | 151 | def reload ( self ) : <TAB> """Parse bindings and mangle into an appropriate form""" <TAB> self. _lookup = { } <TAB> self. _masks = 0 <TAB> for action, bindings in self. keys. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> bindings = ( bindings, ) <TAB> <TAB> for binding in bindings : <TAB> <TAB> <TAB> if not binding or binding == "None" : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> keyval, mask = self. _parsebinding ( binding ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> except KeymapError as e : <TAB> <TAB> <TAB> <TAB> err ( <TAB> <TAB> <TAB> <TAB> <TAB> "keybindings.reload failed to parse binding '%s': %s" % ( binding, e ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if mask & Gdk. ModifierType. SHIFT_MASK : <TAB> <TAB> <TAB> <TAB> <TAB> if keyval == Gdk. KEY_Tab : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> keyval = Gdk. KEY_ISO_Left_Tab <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> mask &= ~ Gdk. ModifierType. SHIFT_MASK <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> keyvals = Gdk. keyval_convert_case ( keyval ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if keyvals [ 0 ]!= keyvals [ 1 ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> keyval = keyvals [ 1 ] <TAB> <TAB> <TAB> <TAB> < | False | not isinstance(bindings, tuple) | self._parse_bindings | 0.6541509628295898 |
154 | 152 | def write ( self ) : <TAB> """Make a copy of the stored config and write it to the configured file""" <TAB> new_config = ConfigObj ( encoding = "UTF-8" ) <TAB> new_config. filename = self. _config_file <TAB> <TAB> <TAB> for key, subkeys in self. _config. items ( ) : <TAB> <TAB> if key not in new_config : <TAB> <TAB> <TAB> new_config [ key ] = { } <TAB> <TAB> for subkey, value in subkeys. items ( ) : <TAB> <TAB> <TAB> new_config [ key ] [ subkey ] = value <TAB> <TAB> for key in _CONFIG_DEFINITIONS. keys ( ) : <TAB> <TAB> key, definition_type, section, ini_key, default = self. _define ( key ) <TAB> <TAB> self. check_setting ( key ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> new_config [ section ] = { } <TAB> <TAB> new_config [ section ] [ ini_key ] = self. _config [ section ] [ ini_key ] <TAB> <TAB> headphones. logger. info ( "Writing configuration to file" ) <TAB> try : <TAB> <TAB> new_config. write ( ) <TAB> except IOError as e : <TAB> <TAB> headphones. logger. error ( "Error writing configuration file: %s", e ) | True | section not in new_config | section not in new_config | 0.6571708917617798 |
155 | 153 | def __init__ ( <TAB> self, endpoint : str, credential : MetricsAdvisorKeyCredential, ** kwargs : Any ) -> None : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> endpoint = "https://" + endpoint <TAB> except AttributeError : <TAB> <TAB> raise ValueError ( "Base URL must be a string." ) <TAB> if not credential : <TAB> <TAB> raise ValueError ( "Missing credential" ) <TAB> self. _endpoint = endpoint <TAB> if isinstance ( credential, MetricsAdvisorKeyCredential ) : <TAB> <TAB> self. _client = _ClientAsync ( <TAB> <TAB> <TAB> endpoint = endpoint, <TAB> <TAB> <TAB> sdk_moniker = SDK_MONIKER, <TAB> <TAB> <TAB> authentication_policy = MetricsAdvisorKeyCredentialPolicy ( credential ), <TAB> <TAB> <TAB> ** kwargs <TAB> <TAB> ) <TAB> else : <TAB> <TAB> if hasattr ( credential, "get_token" ) : <TAB> <TAB> <TAB> credential_scopes = kwargs. pop ( <TAB> <TAB> <TAB> <TAB> "credential_scopes", [ "https://cognitiveservices.azure.com/.default" ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> credential_policy = AsyncBearerTokenCredentialPolicy ( <TAB> <TAB> <TAB> <TAB> credential, * credential_scopes <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> "Please provide an instance from azure-identity " <TAB> <TAB> <TAB> <TAB> "or a class that implement the 'get_token protocol" <TAB> <TAB> <TAB> ) <TAB> <TAB> self. _client = _ClientAsync ( <TAB> <TAB> <TAB> endpoint = endpoint, <TAB> <TAB> <TAB> sdk_moniker = SDK_MONIKER, <TAB> <TAB> <TAB> authentication_policy = credential_policy, <TAB> <TAB> <TAB> ** kwargs <TAB> <TAB> ) | False | not endpoint.lower().startswith('http') | isinstance(endpoint, str) | 0.6574206352233887 |
156 | 154 | def _build_blocks_by_usage ( <TAB> ids : Sequence [ FunctionID ], <TAB> *, <TAB> level : int = 0, <TAB> to : Optional [ FunctionID ] = None, <TAB> origin : float = 0, <TAB> visited : AbstractSet [ Call ] = frozenset ( ), <TAB> parent_width : float = 0, ) -> None : <TAB> factor = 1.0 <TAB> if ids and to is not None : <TAB> <TAB> calls_tottime = sum ( calls [ fid, to ] [ 3 ] for fid in ids ) <TAB> <TAB> if calls_tottime : <TAB> <TAB> <TAB> factor = parent_width / calls_tottime <TAB> for fid in sorted ( ids ) : <TAB> <TAB> call = fid, to <TAB> <TAB> if to is not None : <TAB> <TAB> <TAB> cc, nc, tt, tc = calls [ call ] <TAB> <TAB> <TAB> ttt = tc * factor <TAB> <TAB> else : <TAB> <TAB> <TAB> cc, nc, tt, tc = funcs [ fid ]. stat <TAB> <TAB> <TAB> ttt = tt * factor <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> origin += ttt <TAB> <TAB> <TAB> continue <TAB> <TAB> tooltip = TOOLTIP. format ( tt / maxw, cc, nc, tt, tc ) <TAB> <TAB> block = Block ( <TAB> <TAB> <TAB> func = fid, <TAB> <TAB> <TAB> call_stack = ( ), <TAB> <TAB> <TAB> color = 2 if level > 0 else not funcs [ fid ]. calls, <TAB> <TAB> <TAB> level = level, <TAB> <TAB> <TAB> tooltip = tooltip, <TAB> <TAB> <TAB> w = ttt, <TAB> <TAB> <TAB> x = origin, <TAB> <TAB> ) <TAB> <TAB> usage_blocks. append ( block ) <TAB> <TAB> if call not in visited : <TAB> <TAB> <TAB> _build_blocks_by_usage ( <TAB | False | ttt / maxw < threshold | level > 0 | 0.6720158457756042 |
157 | 155 | def _map_saslprep ( s ) : <TAB> """Map stringprep table B.1 to nothing and C.1.2 to ASCII space""" <TAB> r = [ ] <TAB> for c in s : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r. append ( " " ) <TAB> <TAB> elif not stringprep. in_table_b1 ( c ) : <TAB> <TAB> <TAB> r. append ( c ) <TAB> return "". join ( r ) | False | stringprep.in_table_c12(c) | c.lower() == c.lower() or c.lower() == c.lower() | 0.6584839820861816 |
158 | 156 | def _del_port ( self, ctx, br_name = None, target = None, must_exist = False, with_iface = False ) : <TAB> assert target is not None <TAB> ctx. populate_cache ( ) <TAB> if not with_iface : <TAB> <TAB> vsctl_port = ctx. find_port ( target, must_exist ) <TAB> else : <TAB> <TAB> vsctl_port = ctx. find_port ( target, False ) <TAB> <TAB> if not vsctl_port : <TAB> <TAB> <TAB> vsctl_iface = ctx. find_iface ( target, False ) <TAB> <TAB> <TAB> if vsctl_iface : <TAB> <TAB> <TAB> <TAB> vsctl_port = vsctl_iface. port ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> vsctl_fatal ( "no port or interface named %s" % target ) <TAB> if not vsctl_port : <TAB> <TAB> return <TAB> if not br_name : <TAB> <TAB> vsctl_bridge = ctx. find_bridge ( br_name, True ) <TAB> <TAB> if vsctl_port. bridge ( )!= vsctl_bridge : <TAB> <TAB> <TAB> if vsctl_port. bridge ( ). parent == vsctl_bridge : <TAB> <TAB> <TAB> <TAB> vsctl_fatal ( <TAB> <TAB> <TAB> <TAB> <TAB> "bridge %s does not have a port %s (although " <TAB> <TAB> <TAB> <TAB> <TAB> "its parent bridge %s does)" <TAB> <TAB> <TAB> <TAB> <TAB> % ( br_name, target, vsctl_bridge. parent. name ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> vsctl_fatal ( "bridge %s does not have a port %s" % ( br_name, target ) ) <TAB> ctx. del_port ( vsctl_port ) | False | must_exist and (not vsctl_port) | not vsctl_port and must_exist | 0.650446891784668 |
159 | 157 | def reset ( self ) : <TAB> if self. _on_memory : <TAB> <TAB> self. _generation += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _order = list ( self. _rng. permutation ( self. _size ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _order = list ( range ( self. _size ) ) <TAB> <TAB> if self. _position == 0 : <TAB> <TAB> <TAB> self. _generation = - 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _data_source. _position = self. _position <TAB> <TAB> <TAB> self. _data_source. reset ( ) <TAB> else : <TAB> <TAB> self. _data_source. reset ( ) <TAB> <TAB> self. _generation = self. _data_source. _generation <TAB> <TAB> self. _position = self. _data_source. _position <TAB> super ( DataSourceWithMemoryCache, self ). reset ( ) | False | self._shuffle and self._generation > 0 | self._rng.random() < self._size | 0.6596124172210693 |
160 | 158 | def _format_arg ( self, name, trait_spec, value ) : <TAB> if name == "mask_file" : <TAB> <TAB> return "" <TAB> if name == "op_string" : <TAB> <TAB> if "-k %s" in self. inputs. op_string : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return self. inputs. op_string % self. inputs. mask_file <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise ValueError ( "-k %s option in op_string requires mask_file" ) <TAB> return super ( ImageStats, self ). _format_arg ( name, trait_spec, value ) | False | isdefined(self.inputs.mask_file) | -k %s' in self.inputs.mask_file | 0.6470727920532227 |
161 | 159 | def _prepare_subset ( <TAB> full_data : torch. Tensor, <TAB> full_targets : torch. Tensor, <TAB> num_samples : int, <TAB> digits : Sequence, ) : <TAB> classes = { d : 0 for d in digits } <TAB> indexes = [ ] <TAB> for idx, target in enumerate ( full_targets ) : <TAB> <TAB> label = target. item ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> indexes. append ( idx ) <TAB> <TAB> classes [ label ] += 1 <TAB> <TAB> if all ( classes [ k ] >= num_samples for k in classes ) : <TAB> <TAB> <TAB> break <TAB> data = full_data [ indexes ] <TAB> targets = full_targets [ indexes ] <TAB> return data, targets | False | classes.get(label, float('inf')) >= num_samples | label in empty_data | 0.6501825451850891 |
162 | 160 | def apply ( self, response ) : <TAB> updated_headers = self. update_headers ( response ) <TAB> if updated_headers : <TAB> <TAB> response. headers. update ( updated_headers ) <TAB> <TAB> warning_header_value = self. warning ( response ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> response. headers. update ( { "Warning" : warning_header_value } ) <TAB> return response | False | warning_header_value is not None | warning_header_value | 0.6577584743499756 |
163 | 161 | def dataset_to_stream ( dataset, input_name ) : <TAB> """Takes a tf.Dataset and creates a numpy stream of ready batches.""" <TAB> <TAB> for example in fastmath. dataset_as_numpy ( dataset ) : <TAB> <TAB> features = example [ 0 ] <TAB> <TAB> inp, out = features [ input_name ], example [ 1 ] <TAB> <TAB> mask = features [ "mask" ] if "mask" in features else None <TAB> <TAB> <TAB> <TAB> if isinstance ( inp, np. uint8 ) : <TAB> <TAB> <TAB> inp = inp. astype ( np. int32 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> out = out. astype ( np. int32 ) <TAB> <TAB> yield ( inp, out ) if mask is None else ( inp, out, mask ) | True | isinstance(out, np.uint8) | isinstance(out, np.uint8) | 0.6530542373657227 |
164 | 162 | def numexp_action ( self, text, loc, num ) : <TAB> """Code executed after recognising a numexp expression (something +|- something)""" <TAB> exshared. setpos ( loc, text ) <TAB> if DEBUG > 0 : <TAB> <TAB> print ( "NUM_EXP:", num ) <TAB> <TAB> if DEBUG == 2 : <TAB> <TAB> <TAB> self. symtab. display ( ) <TAB> <TAB> if DEBUG > 2 : <TAB> <TAB> <TAB> return <TAB> <TAB> n = list ( num ) <TAB> while len ( n ) > 1 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise SemanticException ( "Invalid opernads to binary '%s'" % n [ 1 ] ) <TAB> <TAB> reg = self. codegen. arithmetic ( n [ 1 ], n [ 0 ], n [ 2 ] ) <TAB> <TAB> <TAB> <TAB> n [ 0 : 3 ] = [ reg ] <TAB> return n [ 0 ] | False | not self.symtab.same_types(n[0], n[2]) | n[1] not in self.code_space | 0.6545137166976929 |
165 | 163 | def _analyze_callsite ( <TAB> self, caller_block_addr : int, rda : ReachingDefinitionsModel ) -> CallSiteFact : <TAB> fact = CallSiteFact ( <TAB> <TAB> True, <TAB> ) <TAB> state = rda. observed_results [ ( "node", caller_block_addr, 1 ) ] <TAB> all_uses : "Uses" = rda. all_uses <TAB> default_cc_cls = DefaultCC. get ( self. project. arch. name, None ) <TAB> if default_cc_cls is not None : <TAB> <TAB> default_cc : SimCC = default_cc_cls ( self. project. arch ) <TAB> <TAB> all_defs : Set [ "Definition" ] = state. register_definitions. get_all_variables ( ) <TAB> <TAB> return_val = default_cc. RETURN_VAL <TAB> <TAB> if return_val is not None and isinstance ( return_val, SimRegArg ) : <TAB> <TAB> <TAB> return_reg_offset, _ = self. project. arch. registers [ return_val. reg_name ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> return_def = next ( <TAB> <TAB> <TAB> <TAB> <TAB> iter ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> d <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for d in all_defs <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( d. atom, Register ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> and d. atom. reg_offset == return_reg_offset <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> <TAB> return_def = None <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB | True | return_def is not None | return_def is not None | 0.6559402942657471 |
166 | 164 | def handle_noargs ( self, ** options ) : <TAB> global gdata_service <TAB> try : <TAB> <TAB> from gdata import service <TAB> <TAB> gdata_service = service <TAB> except ImportError : <TAB> <TAB> raise CommandError ( <TAB> <TAB> <TAB> "You need to install the gdata " "module to run this command." <TAB> <TAB> ) <TAB> self. verbosity = int ( options. get ( "verbosity", 1 ) ) <TAB> self. blogger_username = options. get ( "blogger_username" ) <TAB> self. category_title = options. get ( "category_title" ) <TAB> self. blogger_blog_id = options. get ( "blogger_blog_id" ) <TAB> self. write_out ( <TAB> <TAB> self. style. TITLE ( "Starting migration from Blogger to Zinnia %s\n" % __version__ ) <TAB> ) <TAB> if<mask> : <TAB> <TAB> self. blogger_username = raw_input ( "Blogger username: " ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise CommandError ( "Invalid Blogger username" ) <TAB> self. blogger_password = getpass ( "Blogger password: " ) <TAB> try : <TAB> <TAB> self. blogger_manager = BloggerManager ( <TAB> <TAB> <TAB> self. blogger_username, self. blogger_password <TAB> <TAB> ) <TAB> except gdata_service. BadAuthentication : <TAB> <TAB> raise CommandError ( "Incorrect Blogger username or password" ) <TAB> default_author = options. get ( "author" ) <TAB> if default_author : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. default_author = User. objects. get ( username = default_author ) <TAB> <TAB> except User. DoesNotExist : <TAB> <TAB> <TAB> raise CommandError ( <TAB> <TAB> <TAB> <TAB> 'Invalid Zinnia username for default author "%s"' % default_author <TAB> <TAB> <TAB> ) < | True | not self.blogger_username | not self.blogger_username | 0.6542549133300781 |
167 | 165 | def nodes ( self ) : <TAB> if not self. _nodes : <TAB> <TAB> nodes = self. cluster_group. instances ( ) <TAB> <TAB> self. _nodes = [ ] <TAB> <TAB> master = self. master_node <TAB> <TAB> nodeid = 1 <TAB> <TAB> for node in nodes : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if node. id == master. id : <TAB> <TAB> <TAB> <TAB> self. _nodes. insert ( 0, master ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> self. _nodes. append ( Node ( node, self. key_location, "node%.3d" % nodeid ) ) <TAB> <TAB> <TAB> nodeid += 1 <TAB> else : <TAB> <TAB> for node in self. _nodes : <TAB> <TAB> <TAB> log. debug ( "refreshing instance %s" % node. id ) <TAB> <TAB> <TAB> node. update ( ) <TAB> return self. _nodes | False | node.state not in ['pending', 'running'] | node.id < 0 | 0.6543914079666138 |
168 | 166 | def set_ok_port ( self, cookie, request ) : <TAB> if cookie. port_specified : <TAB> <TAB> req_port = request_port ( request ) <TAB> <TAB> if req_port is None : <TAB> <TAB> <TAB> req_port = "80" <TAB> <TAB> else : <TAB> <TAB> <TAB> req_port = str ( req_port ) <TAB> <TAB> for p in cookie. port. split ( "," ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> int ( p ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> debug ( " bad port %s (not numeric)", p ) <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> debug ( " request port (%s) not found in %s", req_port, cookie. port ) <TAB> <TAB> <TAB> return False <TAB> return True | False | p == req_port | req_port == cookie.req_port | 0.6740789413452148 |
169 | 167 | def _test_kneighbors_regressor ( <TAB> self, <TAB> n_neighbors = 5, <TAB> algorithm = "brute", <TAB> weights = "uniform", <TAB> metric = "minkowski", <TAB> metric_params = { "p" : 2 }, <TAB> score_w_train_data = False, ) : <TAB> for data in [ datasets. load_boston ( ), datasets. load_diabetes ( ) ] : <TAB> <TAB> X, y = data. data, data. target <TAB> <TAB> X = X. astype ( np. float32 ) <TAB> <TAB> if metric == "wminkowski" : <TAB> <TAB> <TAB> metric_params [ "w" ] = np. random. rand ( X. shape [ 1 ] ) <TAB> <TAB> elif metric == "seuclidean" : <TAB> <TAB> <TAB> metric_params [ "V" ] = np. random. rand ( X. shape [ 1 ] ) <TAB> <TAB> elif metric == "mahalanobis" : <TAB> <TAB> <TAB> V = np. cov ( X. T ) <TAB> <TAB> <TAB> metric_params [ "VI" ] = np. linalg. inv ( V ) <TAB> <TAB> model = KNeighborsRegressor ( <TAB> <TAB> <TAB> n_neighbors = n_neighbors, <TAB> <TAB> <TAB> algorithm = algorithm, <TAB> <TAB> <TAB> weights = weights, <TAB> <TAB> <TAB> metric = metric, <TAB> <TAB> <TAB> metric_params = metric_params, <TAB> <TAB> ) <TAB> <TAB> n_train_rows = int ( X. shape [ 0 ] * 0.6 ) <TAB> <TAB> model. fit ( X [ : n_train_rows, : ], y [ : n_train_rows ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> X = X [ n_train_rows :, : ] <TAB> <TAB> extra_config = { <TAB> <TAB> <TAB> humming | False | not score_w_train_data | n_neighbors > 5 | 0.655362606048584 |
170 | 168 | def __call__ ( <TAB> self, engine : Engine, logger : ClearMLLogger, event_name : Union [ str, Events ] ) -> None : <TAB> if not isinstance ( logger, ClearMLLogger ) : <TAB> <TAB> raise RuntimeError ( "Handler 'GradsHistHandler' works only with ClearMLLogger" ) <TAB> global_step = engine. state. get_event_attrib_value ( event_name ) <TAB> tag_prefix = f"{self.tag}/" if self. tag else "" <TAB> for name, p in self. model. named_parameters ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> title_name, _, series_name = name. partition ( "." ) <TAB> <TAB> logger. grad_helper. add_histogram ( <TAB> <TAB> <TAB> title = f"{tag_prefix}grads_{title_name}", <TAB> <TAB> <TAB> series = series_name, <TAB> <TAB> <TAB> step = global_step, <TAB> <TAB> <TAB> hist_data = p. grad. detach ( ). cpu ( ). numpy ( ), <TAB> <TAB> ) | False | p.grad is None | not p.grad | 0.658847451210022 |
171 | 169 | def extract ( self ) : <TAB> try : <TAB> <TAB> c = self. db. cursor ( ) <TAB> <TAB> c. execute ( """show global variables like'max_connections';""" ) <TAB> <TAB> max = c. fetchone ( ) <TAB> <TAB> c. execute ( """show global status like 'Threads_connected';""" ) <TAB> <TAB> thread = c. fetchone ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set2 [ thread [ 0 ] ] = float ( thread [ 1 ] ) <TAB> <TAB> <TAB> self. set2 [ "Threads" ] = float ( thread [ 1 ] ) / float ( max [ 1 ] ) * 100.0 <TAB> <TAB> for name in self. vars : <TAB> <TAB> <TAB> self. val [ name ] = self. set2 [ name ] * 1.0 / elapsed <TAB> <TAB> if step == op. delay : <TAB> <TAB> <TAB> self. set1. update ( self. set2 ) <TAB> except Exception as e : <TAB> <TAB> for name in self. vars : <TAB> <TAB> <TAB> self. val [ name ] = - 1 | False | thread[0] in self.vars | thread != None | 0.6545277833938599 |
172 | 170 | def _setUpClass ( cls ) : <TAB> global solver <TAB> import pyomo. environ <TAB> from pyomo. solvers. tests. io. writer_test_cases import testCases <TAB> for test_case in testCases : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> solver [ ( test_case. name, test_case. io ) ] = True | False | (test_case.name, test_case.io) in solver and test_case.available | test_case.name in environ | 0.6479943990707397 |
173 | 171 | def test_timestamp_overflow ( self ) : <TAB> <TAB> <TAB> sys. path. insert ( 0, os. curdir ) <TAB> try : <TAB> <TAB> source = TESTFN + ".py" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> compiled = TESTFN + "$py.class" <TAB> <TAB> else : <TAB> <TAB> <TAB> compiled = source + ( "c" if __debug__ else "o" ) <TAB> <TAB> with open ( source, "w" ) as f : <TAB> <TAB> <TAB> pass <TAB> <TAB> try : <TAB> <TAB> <TAB> os. utime ( source, ( 2 ** 33 - 5, 2 ** 33 - 5 ) ) <TAB> <TAB> except OverflowError : <TAB> <TAB> <TAB> self. skipTest ( "cannot set modification time to large integer" ) <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> if e. errno!= getattr ( errno, "EOVERFLOW", None ) : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> self. skipTest ( <TAB> <TAB> <TAB> <TAB> "cannot set modification time to large integer ({})". format ( e ) <TAB> <TAB> <TAB> ) <TAB> <TAB> __import__ ( TESTFN ) <TAB> <TAB> <TAB> <TAB> os. stat ( compiled ) <TAB> finally : <TAB> <TAB> del sys. path [ 0 ] <TAB> <TAB> remove_files ( TESTFN ) | False | is_jython | __debug__ | 0.6686463356018066 |
174 | 172 | def to_representation ( self, value ) : <TAB> old_social_string_fields = [ "twitter", "github", "linkedIn" ] <TAB> request = self. context. get ( "request" ) <TAB> show_old_format = ( <TAB> <TAB> request <TAB> <TAB> and is_deprecated ( request. version, self. min_version ) <TAB> <TAB> and request. method == "GET" <TAB> ) <TAB> if show_old_format : <TAB> <TAB> social = value. copy ( ) <TAB> <TAB> for key in old_social_string_fields : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> social [ key ] = value [ key ] [ 0 ] <TAB> <TAB> <TAB> elif social. get ( key ) == [ ] : <TAB> <TAB> <TAB> <TAB> social [ key ] = "" <TAB> <TAB> value = social <TAB> return super ( SocialField, self ). to_representation ( value ) | False | social.get(key) | key in value | 0.6571549773216248 |
175 | 173 | def contribute ( self, converter, model, form_class, inline_model ) : <TAB> <TAB> reverse_field = None <TAB> info = self. get_info ( inline_model ) <TAB> for field in get_meta_fields ( info. model ) : <TAB> <TAB> field_type = type ( field ) <TAB> <TAB> if field_type == ForeignKeyField : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> reverse_field = field <TAB> <TAB> <TAB> <TAB> break <TAB> else : <TAB> <TAB> raise Exception ( "Cannot find reverse relation for model %s" % info. model ) <TAB> <TAB> ignore = [ reverse_field. name ] <TAB> if info. form_excluded_columns : <TAB> <TAB> exclude = ignore + info. form_excluded_columns <TAB> else : <TAB> <TAB> exclude = ignore <TAB> <TAB> child_form = info. get_form ( ) <TAB> if child_form is None : <TAB> <TAB> child_form = model_form ( <TAB> <TAB> <TAB> info. model, <TAB> <TAB> <TAB> base_class = form. BaseForm, <TAB> <TAB> <TAB> only = info. form_columns, <TAB> <TAB> <TAB> exclude = exclude, <TAB> <TAB> <TAB> field_args = info. form_args, <TAB> <TAB> <TAB> allow_pk = True, <TAB> <TAB> <TAB> converter = converter, <TAB> <TAB> ) <TAB> try : <TAB> <TAB> prop_name = reverse_field. related_name <TAB> except AttributeError : <TAB> <TAB> prop_name = reverse_field. backref <TAB> label = self. get_label ( info, prop_name ) <TAB> setattr ( <TAB> <TAB> form_class, <TAB> <TAB> prop_name, <TAB> <TAB> self. inline_field_list_type ( <TAB> <TAB> <TAB> child_form, <TAB> <TAB> <TAB> info. model, <TAB> <TAB> < | False | field.rel_model == model | reverse_field is None | 0.6588976383209229 |
176 | 174 | def get_aa_from_codonre ( re_aa ) : <TAB> aas = [ ] <TAB> m = 0 <TAB> for i in re_aa : <TAB> <TAB> if i == "[" : <TAB> <TAB> <TAB> m = - 1 <TAB> <TAB> <TAB> aas. append ( "" ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> m = 0 <TAB> <TAB> <TAB> continue <TAB> <TAB> elif m == - 1 : <TAB> <TAB> <TAB> aas [ - 1 ] = aas [ - 1 ] + i <TAB> <TAB> elif m == 0 : <TAB> <TAB> <TAB> aas. append ( i ) <TAB> return aas | False | i == ']' | m == 0 | 0.6804044246673584 |
177 | 175 | def _do_db_notes ( self, params ) : <TAB> """Adds notes to rows in the database""" <TAB> table, params = self. _parse_params ( params ) <TAB> if not table : <TAB> <TAB> self. _help_db_notes ( ) <TAB> <TAB> return <TAB> if table in self. get_tables ( ) : <TAB> <TAB> <TAB> <TAB> if params : <TAB> <TAB> <TAB> arg, note = self. _parse_params ( params ) <TAB> <TAB> <TAB> rowids = self. _parse_rowids ( arg ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> params = input ( "rowid(s) (INT): " ) <TAB> <TAB> <TAB> <TAB> rowids = self. _parse_rowids ( params ) <TAB> <TAB> <TAB> <TAB> note = input ( "note (TXT): " ) <TAB> <TAB> <TAB> except KeyboardInterrupt : <TAB> <TAB> <TAB> <TAB> print ( "" ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> finally : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> print ( f"{params}" ) <TAB> <TAB> <TAB> <TAB> count = 0 <TAB> <TAB> for rowid in rowids : <TAB> <TAB> <TAB> count += self. query ( <TAB> <TAB> <TAB> <TAB> f"UPDATE `{table}` SET notes=? WHERE ROWID IS?", ( note, rowid ) <TAB> <TAB> <TAB> ) <TAB> <TAB> self. output ( f"{count} rows affected." ) <TAB> else : <TAB> <TAB> self. output ( "Invalid table name." ) | False | Framework._script | params | 0.6727245450019836 |
178 | 176 | def start_workunit ( self, workunit ) : <TAB> """Implementation of Reporter callback.""" <TAB> if self. is_under_background_root ( workunit ) : <TAB> <TAB> return <TAB> label_format = self. _get_label_format ( workunit ) <TAB> if label_format == LabelFormat. FULL : <TAB> <TAB> if not WorkUnitLabel. SUPPRESS_LABEL in workunit. labels : <TAB> <TAB> <TAB> self. _emit_indented_workunit_label ( workunit ) <TAB> <TAB> <TAB> <TAB> tool_output_format = self. _get_tool_output_format ( workunit ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. emit ( self. _prefix ( workunit, "\n" ) ) <TAB> <TAB> elif tool_output_format == ToolOutputFormat. UNINDENTED : <TAB> <TAB> <TAB> self. emit ( "\n" ) <TAB> elif label_format == LabelFormat. DOT : <TAB> <TAB> self. emit ( "." ) <TAB> self. flush ( ) | False | tool_output_format == ToolOutputFormat.INDENT | tool_output_format == ToolOutputFormat.INDENTED | 0.6523141264915466 |
179 | 177 | def strip_dirs ( self ) : <TAB> oldstats = self. stats <TAB> self. stats = newstats = { } <TAB> max_name_len = 0 <TAB> for func, ( cc, nc, tt, ct, callers ) in oldstats. items ( ) : <TAB> <TAB> newfunc = func_strip_path ( func ) <TAB> <TAB> if len ( func_std_string ( newfunc ) ) > max_name_len : <TAB> <TAB> <TAB> max_name_len = len ( func_std_string ( newfunc ) ) <TAB> <TAB> newcallers = { } <TAB> <TAB> for func2, caller in callers. items ( ) : <TAB> <TAB> <TAB> newcallers [ func_strip_path ( func2 ) ] = caller <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> newstats [ newfunc ] = add_func_stats ( <TAB> <TAB> <TAB> <TAB> newstats [ newfunc ], ( cc, nc, tt, ct, newcallers ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> newstats [ newfunc ] = ( cc, nc, tt, ct, newcallers ) <TAB> old_top = self. top_level <TAB> self. top_level = new_top = set ( ) <TAB> for func in old_top : <TAB> <TAB> new_top. add ( func_strip_path ( func ) ) <TAB> self. max_name_len = max_name_len <TAB> self. fcn_list = None <TAB> self. all_callees = None <TAB> return self | False | newfunc in newstats | len(newcallers) > 0 | 0.6734169721603394 |
180 | 178 | def _maybe_run_close_callback ( self ) : <TAB> <TAB> <TAB> if self. closed ( ) and self. _pending_callbacks == 0 : <TAB> <TAB> futures = [ ] <TAB> <TAB> if self. _read_future is not None : <TAB> <TAB> <TAB> futures. append ( self. _read_future ) <TAB> <TAB> <TAB> self. _read_future = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> futures. append ( self. _write_future ) <TAB> <TAB> <TAB> self. _write_future = None <TAB> <TAB> if self. _connect_future is not None : <TAB> <TAB> <TAB> futures. append ( self. _connect_future ) <TAB> <TAB> <TAB> self. _connect_future = None <TAB> <TAB> if self. _ssl_connect_future is not None : <TAB> <TAB> <TAB> futures. append ( self. _ssl_connect_future ) <TAB> <TAB> <TAB> self. _ssl_connect_future = None <TAB> <TAB> for future in futures : <TAB> <TAB> <TAB> future. set_exception ( StreamClosedError ( real_error = self. error ) ) <TAB> <TAB> if self. _close_callback is not None : <TAB> <TAB> <TAB> cb = self. _close_callback <TAB> <TAB> <TAB> self. _close_callback = None <TAB> <TAB> <TAB> self. _run_callback ( cb ) <TAB> <TAB> <TAB> <TAB> self. _read_callback = self. _write_callback = None <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _write_buffer = None | True | self._write_future is not None | self._write_future is not None | 0.6580326557159424 |
181 | 179 | def route ( tokeniser ) : <TAB> ipmask = prefix ( tokeniser ) <TAB> if "rd" in tokeniser. tokens or "route-distinguisher" in tokeniser. tokens : <TAB> <TAB> nlri = IPVPN ( IP. toafi ( ipmask. top ( ) ), SAFI. mpls_vpn, OUT. ANNOUNCE ) <TAB> elif "label" in tokeniser. tokens : <TAB> <TAB> nlri = Label ( IP. toafi ( ipmask. top ( ) ), SAFI. nlri_mpls, OUT. ANNOUNCE ) <TAB> else : <TAB> <TAB> nlri = INET ( IP. toafi ( ipmask. top ( ) ), IP. tosafi ( ipmask. top ( ) ), OUT. ANNOUNCE ) <TAB> nlri. cidr = CIDR ( ipmask. pack ( ), ipmask. mask ) <TAB> change = Change ( nlri, Attributes ( ) ) <TAB> while True : <TAB> <TAB> command = tokeniser ( ) <TAB> <TAB> if not command : <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> nlri. labels = label ( tokeniser ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if command == "rd" or command == "route-distinguisher" : <TAB> <TAB> <TAB> nlri. rd = route_distinguisher ( tokeniser ) <TAB> <TAB> <TAB> continue <TAB> <TAB> action = ParseStatic. action. get ( command, "" ) <TAB> <TAB> if action == "attribute-add" : <TAB> <TAB> <TAB> change. attributes. add ( ParseStatic. known [ command ] ( tokeniser ) ) <TAB> <TAB> elif action == "nlri-set" : <TAB> <TAB> <TAB> change. nlri. assign ( <TAB> <TAB> <TAB> <TAB> ParseStatic. assign [ command ], ParseStatic. known [ command ] ( tokeniser ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif action == "nexthop-and-attribute" | False | command == 'label' | label is not None | 0.662468433380127 |
182 | 180 | def _get_match_location ( self, node, name = None ) : <TAB> loc = source. Location ( node. lineno, node. col_offset ) <TAB> if not name : <TAB> <TAB> return loc <TAB> if isinstance ( node, ( self. _ast. Import, self. _ast. ImportFrom ) ) : <TAB> <TAB> <TAB> <TAB> m = re. search ( "[,]" + name + r"\b", self. source. line ( node. lineno ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> c, _ = m. span ( ) <TAB> <TAB> <TAB> return source. Location ( node. lineno, c + 1 ) <TAB> elif isinstance ( node, self. _ast. Attribute ) : <TAB> <TAB> attr_loc, _ = self. source. get_attr_location ( name, loc ) <TAB> <TAB> return attr_loc <TAB> return loc | False | m is not None | m | 0.659475564956665 |
183 | 181 | def create_columns ( self, treeview ) : <TAB> <TAB> column = Gtk. TreeViewColumn ( "" ) <TAB> row_data_index = 1 <TAB> for i, f in enumerate ( self. fields ) : <TAB> <TAB> if f == IconTextRendererColumns. ICON : <TAB> <TAB> <TAB> iconcell = Gtk. CellRendererPixbuf ( ) <TAB> <TAB> <TAB> iconcell. set_property ( "width", self. icon_size ( ) + 10 ) <TAB> <TAB> <TAB> column. set_cell_data_func ( iconcell, self. icon, i ) <TAB> <TAB> <TAB> column. pack_start ( iconcell, False ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> namecell = Gtk. CellRendererText ( ) <TAB> <TAB> <TAB> namecell. set_property ( "ellipsize", Pango. EllipsizeMode. END ) <TAB> <TAB> <TAB> column. pack_start ( namecell, True ) <TAB> <TAB> <TAB> column. add_attribute ( namecell, "text", row_data_index ) <TAB> <TAB> elif f == IconTextRendererColumns. TITLE_SUBTITLE : <TAB> <TAB> <TAB> namecell = Gtk. CellRendererText ( ) <TAB> <TAB> <TAB> namecell. set_property ( "ellipsize", Pango. EllipsizeMode. END ) <TAB> <TAB> <TAB> column. set_cell_data_func ( namecell, self. markup, i ) <TAB> <TAB> <TAB> column. pack_start ( namecell, True ) <TAB> <TAB> row_data_index += 1 <TAB> treeview. append_column ( column ) | False | f == IconTextRendererColumns.TITLE | f == IconTextRendererColumns.TITLE_SUBTITLE | 0.6661038994789124 |
184 | 182 | def _create_tiny_git_repo ( self, *, copy_files : Optional [ Sequence [ Path ] ] = None ) : <TAB> with temporary_dir ( ) as gitdir, temporary_dir ( ) as worktree : <TAB> <TAB> <TAB> <TAB> Path ( worktree, "README" ). touch ( ) <TAB> <TAB> <TAB> <TAB> with initialize_repo ( worktree, gitdir = gitdir ) as git : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> for fp in copy_files : <TAB> <TAB> <TAB> <TAB> <TAB> new_fp = Path ( worktree, fp ) <TAB> <TAB> <TAB> <TAB> <TAB> safe_mkdir_for ( str ( new_fp ) ) <TAB> <TAB> <TAB> <TAB> <TAB> shutil. copy ( fp, new_fp ) <TAB> <TAB> <TAB> yield git, worktree, gitdir | True | copy_files is not None | copy_files is not None | 0.656037449836731 |
185 | 183 | def click_outside ( event ) : <TAB> if event not in d : <TAB> <TAB> x, y, z = self. blockFaceUnderCursor [ 0 ] <TAB> <TAB> if y == 0 : <TAB> <TAB> <TAB> y = 64 <TAB> <TAB> y += 3 <TAB> <TAB> gotoPanel. X, gotoPanel. Y, gotoPanel. Z = x, y, z <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> d. dismiss ( "Goto" ) | False | event.num_clicks == 2 | x == 0 and z == 64 | 0.6589517593383789 |
186 | 184 | def get_doc_object ( obj, what = None, doc = None, config = { } ) : <TAB> if what is None : <TAB> <TAB> if inspect. isclass ( obj ) : <TAB> <TAB> <TAB> what = "class" <TAB> <TAB> elif inspect. ismodule ( obj ) : <TAB> <TAB> <TAB> what = "module" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> what = "function" <TAB> <TAB> else : <TAB> <TAB> <TAB> what = "object" <TAB> if what == "class" : <TAB> <TAB> return SphinxClassDoc ( obj, func_doc = SphinxFunctionDoc, doc = doc, config = config ) <TAB> elif what in ( "function", "method" ) : <TAB> <TAB> return SphinxFunctionDoc ( obj, doc = doc, config = config ) <TAB> else : <TAB> <TAB> if doc is None : <TAB> <TAB> <TAB> doc = pydoc. getdoc ( obj ) <TAB> <TAB> return SphinxObjDoc ( obj, doc, config = config ) | False | callable(obj) | what == 'function' | 0.6599302291870117 |
187 | 185 | def _attempt_proof_app ( self, current, context, agenda, accessible_vars, atoms, debug ) : <TAB> f, args = current. uncurry ( ) <TAB> for i, arg in enumerate ( args ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ctx = f <TAB> <TAB> <TAB> nv = Variable ( "X%s" % _counter. get ( ) ) <TAB> <TAB> <TAB> for j, a in enumerate ( args ) : <TAB> <TAB> <TAB> <TAB> ctx = ctx ( VariableExpression ( nv ) ) if i == j else ctx ( a ) <TAB> <TAB> <TAB> if context : <TAB> <TAB> <TAB> <TAB> ctx = context ( ctx ). simplify ( ) <TAB> <TAB> <TAB> ctx = LambdaExpression ( nv, ctx ) <TAB> <TAB> <TAB> agenda. put ( arg, ctx ) <TAB> <TAB> <TAB> return self. _attempt_proof ( agenda, accessible_vars, atoms, debug + 1 ) <TAB> raise Exception ( "If this method is called, there must be a non-atomic argument" ) | False | not TableauProver.is_atom(arg) | f | 0.647758960723877 |
188 | 186 | def background_size ( tokens ) : <TAB> """Validation for ``background-size``.""" <TAB> if len ( tokens ) == 1 : <TAB> <TAB> token = tokens [ 0 ] <TAB> <TAB> keyword = get_keyword ( token ) <TAB> <TAB> if keyword in ( "contain", "cover" ) : <TAB> <TAB> <TAB> return keyword <TAB> <TAB> if keyword == "auto" : <TAB> <TAB> <TAB> return ( "auto", "auto" ) <TAB> <TAB> length = get_length ( token, negative = False, percentage = True ) <TAB> <TAB> if length : <TAB> <TAB> <TAB> return ( length, "auto" ) <TAB> elif len ( tokens ) == 2 : <TAB> <TAB> values = [ ] <TAB> <TAB> for token in tokens : <TAB> <TAB> <TAB> length = get_length ( token, negative = False, percentage = True ) <TAB> <TAB> <TAB> if length : <TAB> <TAB> <TAB> <TAB> values. append ( length ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> values. append ( "auto" ) <TAB> <TAB> if len ( values ) == 2 : <TAB> <TAB> <TAB> return tuple ( values ) | False | get_keyword(token) == 'auto' | auto | 0.649667501449585 |
189 | 187 | def _extract_subtitles ( url, subtitle_url ) : <TAB> subtitles = { } <TAB> if subtitle_url and isinstance ( subtitle_url, compat_str ) : <TAB> <TAB> subtitle_url = urljoin ( url, subtitle_url ) <TAB> <TAB> STL_EXT = ".stl" <TAB> <TAB> SRT_EXT = ".srt" <TAB> <TAB> subtitles [ "it" ] = [ <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> "ext" : "stl", <TAB> <TAB> <TAB> <TAB> "url" : subtitle_url, <TAB> <TAB> <TAB> } <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> srt_url = subtitle_url [ : - len ( STL_EXT ) ] + SRT_EXT <TAB> <TAB> <TAB> subtitles [ "it" ]. append ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> "ext" : "srt", <TAB> <TAB> <TAB> <TAB> <TAB> "url" : srt_url, <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> ) <TAB> return subtitles | False | subtitle_url.endswith(STL_EXT) | subtitle_url and subtitle_url.endswith(STL_EXT) | 0.6486467719078064 |
190 | 188 | def do_status ( self, directory, path ) : <TAB> if path : <TAB> <TAB> try : <TAB> <TAB> <TAB> return next ( <TAB> <TAB> <TAB> <TAB> self. _gitcmd ( <TAB> <TAB> <TAB> <TAB> <TAB> directory, "status", "--porcelain", "--ignored", "--", path <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) [ : 2 ] <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> return None <TAB> else : <TAB> <TAB> wt_column = " " <TAB> <TAB> index_column = " " <TAB> <TAB> untracked_column = " " <TAB> <TAB> for line in self. _gitcmd ( directory, "status", "--porcelain" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> untracked_column = "U" <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> elif line [ 0 ] == "!" : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if line [ 0 ]!= " " : <TAB> <TAB> <TAB> <TAB> index_column = "I" <TAB> <TAB> <TAB> if line [ 1 ]!= " " : <TAB> <TAB> <TAB> <TAB> wt_column = "D" <TAB> <TAB> r = wt_column + index_column + untracked_column <TAB> <TAB> return r if r!= " " else None | False | line[0] == '?' | line[0] == '!' | 0.6660847663879395 |
191 | 189 | def save ( self, filename = None, ignore_discard = False, ignore_expires = False ) : <TAB> if filename is None : <TAB> <TAB> if self. filename is not None : <TAB> <TAB> <TAB> filename = self. filename <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( MISSING_FILENAME_TEXT ) <TAB> f = open ( filename, "w" ) <TAB> try : <TAB> <TAB> f. write ( self. header ) <TAB> <TAB> now = time. time ( ) <TAB> <TAB> for cookie in self : <TAB> <TAB> <TAB> if not ignore_discard and cookie. discard : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if not ignore_expires and cookie. is_expired ( now ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if cookie. secure : <TAB> <TAB> <TAB> <TAB> secure = "TRUE" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> secure = "FALSE" <TAB> <TAB> <TAB> if cookie. domain. startswith ( "." ) : <TAB> <TAB> <TAB> <TAB> initial_dot = "TRUE" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> initial_dot = "FALSE" <TAB> <TAB> <TAB> if cookie. expires is not None : <TAB> <TAB> <TAB> <TAB> expires = str ( cookie. expires ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> expires = "" <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> name = "" <TAB> <TAB> <TAB> <TAB> value = cookie. name <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> name = cookie. name <TAB> | False | cookie.value is None | len(cookie.name) | 0.660980761051178 |
192 | 190 | def check_metadata_equal ( df1, df2 ) : <TAB> <TAB> for attr in df1. _metadata : <TAB> <TAB> if attr == "_recommendation" : <TAB> <TAB> <TAB> x = df1. _recommendation <TAB> <TAB> <TAB> y = df2. _recommendation <TAB> <TAB> <TAB> for key in x : <TAB> <TAB> <TAB> <TAB> if key in y : <TAB> <TAB> <TAB> <TAB> <TAB> assert len ( x [ key ] ) == len ( y [ key ] ) <TAB> <TAB> <TAB> <TAB> <TAB> for i in range ( len ( x [ key ] ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> vis1 = x [ key ] [ i ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> vis2 = y [ key ] [ i ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> compare_vis ( vis1, vis2 ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> x = df1. _rec_info <TAB> <TAB> <TAB> y = df2. _rec_info <TAB> <TAB> <TAB> assert len ( x ) == len ( y ) <TAB> <TAB> <TAB> for i in range ( len ( x ) ) : <TAB> <TAB> <TAB> <TAB> x_info, y_info = x [ i ], y [ i ] <TAB> <TAB> <TAB> <TAB> for key in x_info : <TAB> <TAB> <TAB> <TAB> <TAB> if key in y_info and key == "collection" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> assert len ( x_info [ key ] ) == len ( y_info [ key ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for i in range ( len ( x_info [ key ] ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> vis1 = x_ | False | attr == '_rec_info' | attr == 'collection' | 0.6667472124099731 |
193 | 191 | def compute_most_posted ( server, message ) : <TAB> module, num, keyword, paste_date = message. split ( ";" ) <TAB> redis_progression_name_set = "top_" + module + "_set_" + paste_date <TAB> <TAB> server. hincrby ( paste_date, module + "-" + keyword, int ( num ) ) <TAB> <TAB> date = get_date_range ( 0 ) [ 0 ] <TAB> <TAB> keyword_total_sum = 0 <TAB> curr_value = server. hget ( date, module + "-" + keyword ) <TAB> keyword_total_sum += int ( curr_value ) if curr_value is not None else 0 <TAB> if server. zcard ( redis_progression_name_set ) < max_set_cardinality : <TAB> <TAB> server. zadd ( redis_progression_name_set, float ( keyword_total_sum ), keyword ) <TAB> else : <TAB> <TAB> member_set = server. zrangebyscore ( <TAB> <TAB> <TAB> redis_progression_name_set, "-inf", "+inf", withscores = True, start = 0, num = 1 <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> module <TAB> <TAB> <TAB> <TAB> + ": adding " <TAB> <TAB> <TAB> <TAB> + keyword <TAB> <TAB> <TAB> <TAB> + "(" <TAB> <TAB> <TAB> <TAB> + str ( keyword_total_sum ) <TAB> <TAB> <TAB> <TAB> + ") in set and removing " <TAB> <TAB> <TAB> <TAB> + member_set [ 0 ] [ 0 ] <TAB> <TAB> <TAB> <TAB> + "(" <TAB> <TAB> <TAB> <TAB> + str ( member_set [ 0 ] [ 1 ] ) <TAB> <TAB> <TAB> <TAB> + ")" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB | False | int(member_set[0][1]) < keyword_total_sum | num > 0 | 0.6516745090484619 |
194 | 192 | def _split_bitstream ( buf : bytes ) -> Iterator [ bytes ] : <TAB> <TAB> <TAB> i = 0 <TAB> while True : <TAB> <TAB> while ( buf [ i ]!= 0 or buf [ i + 1 ]!= 0 or buf [ i + 2 ]!= 0x01 ) and ( <TAB> <TAB> <TAB> buf [ i ]!= 0 or buf [ i + 1 ]!= 0 or buf [ i + 2 ]!= 0 or buf [ i + 3 ]!= 0x01 <TAB> <TAB> ) : <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> <TAB> if i + 4 >= len ( buf ) : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> i += 3 <TAB> <TAB> nal_start = i <TAB> <TAB> while ( buf [ i ]!= 0 or buf [ i + 1 ]!= 0 or buf [ i + 2 ]!= 0 ) and ( <TAB> <TAB> <TAB> buf [ i ]!= 0 or buf [ i + 1 ]!= 0 or buf [ i + 2 ]!= 0x01 <TAB> <TAB> ) : <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if i + 3 >= len ( buf ) : <TAB> <TAB> <TAB> <TAB> nal_end = len ( buf ) <TAB> <TAB> <TAB> <TAB> yield buf [ nal_start : nal_end ] <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> nal_end = i <TAB> <TAB> yield buf [ nal_start : nal_end ] | False | buf[i] != 0 or buf[i + 1] != 0 or buf[i + 2] != 1 | i + 4 >= len(buf) | 0.6563775539398193 |
195 | 193 | def __init__ ( self, fmt = None, * args ) : <TAB> if not isinstance ( fmt, BaseException ) : <TAB> <TAB> Error. __init__ ( self, fmt, * args ) <TAB> else : <TAB> <TAB> e = fmt <TAB> <TAB> cls = e. __class__ <TAB> <TAB> fmt = "%s.%s: %s" % ( cls. __module__, cls. __name__, e ) <TAB> <TAB> tb = sys. exc_info ( ) [ 2 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fmt += "\n" <TAB> <TAB> <TAB> fmt += "". join ( traceback. format_tb ( tb ) ) <TAB> <TAB> Error. __init__ ( self, fmt ) | True | tb | tb | 0.7045260667800903 |
196 | 194 | def collect_textmate_scheme ( self, scheme_tree ) : <TAB> scheme = { } <TAB> for style in scheme_tree. findall ( ".//dict[key='scope']" ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> cur_style = { } <TAB> <TAB> <TAB> cur_tag = None <TAB> <TAB> <TAB> for elem in style. iter ( ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> cur_tag = elem. text <TAB> <TAB> <TAB> <TAB> elif elem. tag == "string" and cur_tag is not None : <TAB> <TAB> <TAB> <TAB> <TAB> cur_style [ cur_tag ] = elem. text <TAB> <TAB> <TAB> <TAB> <TAB> cur_tag = None <TAB> <TAB> <TAB> if "scope" in cur_style : <TAB> <TAB> <TAB> <TAB> scheme [ cur_style [ "scope" ] ] = cur_style <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> pass <TAB> return scheme | False | elem.tag == 'key' | elem.tag == 'string' | 0.6555716395378113 |
197 | 195 | def get_ending ( lines, begin, end, begin_line, begin_char, type ) : <TAB> <TAB> <TAB> end_line = begin_line <TAB> end_char = 0 <TAB> if type == MULT : <TAB> <TAB> while end_line < len ( lines ) : <TAB> <TAB> <TAB> start = 0 <TAB> <TAB> <TAB> if end_line == begin_line : <TAB> <TAB> <TAB> <TAB> start = begin_char + len ( begin ) <TAB> <TAB> <TAB> end_char = lines [ end_line ]. find ( end, start ) <TAB> <TAB> <TAB> if end_char >= 0 : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> end_line += 1 <TAB> <TAB> end_line += 1 <TAB> elif type == IN : <TAB> <TAB> while end_line < len ( lines ) : <TAB> <TAB> <TAB> start = 0 <TAB> <TAB> <TAB> if end_line == begin_line : <TAB> <TAB> <TAB> <TAB> start = lines [ end_line ]. index ( begin ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> end_line += 1 <TAB> return end_line, end_char | False | not lines[end_line][start:].strip().startswith(begin) | start == 0 | 0.6547279357910156 |
198 | 196 | def pauseAllDownloads ( self, menu ) : <TAB> <TAB> active_gids = download. activeDownloads ( ) <TAB> <TAB> f = Open ( download_list_file_active ) <TAB> download_list_file_active_lines = f. readlines ( ) <TAB> f. close ( ) <TAB> for i in range ( len ( download_list_file_active_lines ) ) : <TAB> <TAB> download_list_file_active_lines [ i ] = download_list_file_active_lines [ i ]. strip ( ) <TAB> for gid in active_gids : <TAB> <TAB> if gid in download_list_file_active_lines : <TAB> <TAB> <TAB> answer = download. downloadPause ( gid ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> notifySend ( "Aria2 did not respond!", "Try agian!", 10000, "critical" ) <TAB> <TAB> <TAB> sleep ( 0.3 ) | False | answer == 'None' | answer == 'Successfully created' | 0.657417893409729 |
199 | 197 | def _get_requested_databases ( self ) : <TAB> """Returns a list of databases requested, not including ignored dbs""" <TAB> requested_databases = [ ] <TAB> if ( self. _requested_namespaces is not None ) and ( self. _requested_namespaces!= [ ] ) : <TAB> <TAB> for requested_namespace in self. _requested_namespaces : <TAB> <TAB> <TAB> if requested_namespace [ 0 ] is "*" : <TAB> <TAB> <TAB> <TAB> return [ ] <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> requested_databases. append ( requested_namespace [ 0 ] ) <TAB> return requested_databases | False | requested_namespace[0] not in IGNORE_DBS | requested_namespace[0] not in requested_databases | 0.6561185717582703 |
200 | 198 | def read_work_titles ( fields ) : <TAB> found = [ ] <TAB> if "240" in fields : <TAB> <TAB> for line in fields [ "240" ] : <TAB> <TAB> <TAB> title = join_subfield_values ( line, [ "a", "m", "n", "p", "r" ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> found. append ( title ) <TAB> if "130" in fields : <TAB> <TAB> for line in fields [ "130" ] : <TAB> <TAB> <TAB> title = " ". join ( get_lower_subfields ( line ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> found. append ( title ) <TAB> return { "work_titles" : found } if found else { } | False | title not in found | title | 0.671471118927002 |
201 | 199 | def generic_tag_compiler ( params, defaults, name, node_class, parser, token ) : <TAB> "Returns a template.Node subclass." <TAB> bits = token. split_contents ( ) [ 1 : ] <TAB> bmax = len ( params ) <TAB> def_len = defaults and len ( defaults ) or 0 <TAB> bmin = bmax - def_len <TAB> if len ( bits ) < bmin or len ( bits ) > bmax : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> message = "%s takes %s arguments" % ( name, bmin ) <TAB> <TAB> else : <TAB> <TAB> <TAB> message = "%s takes between %s and %s arguments" % ( name, bmin, bmax ) <TAB> <TAB> raise TemplateSyntaxError ( message ) <TAB> return node_class ( bits ) | False | bmin == bmax | bmin > bmax | 0.6748461723327637 |
202 | 200 | def _handle_control_flow_operator ( self, operator, values ) : <TAB> if operator == "$switch" : <TAB> <TAB> if not isinstance ( values, dict ) : <TAB> <TAB> <TAB> raise OperationFailure ( <TAB> <TAB> <TAB> <TAB> "$switch requires an object as an argument, " "found: %s" % type ( values ) <TAB> <TAB> <TAB> ) <TAB> <TAB> branches = values. get ( "branches", [ ] ) <TAB> <TAB> if not isinstance ( branches, ( list, tuple ) ) : <TAB> <TAB> <TAB> raise OperationFailure ( <TAB> <TAB> <TAB> <TAB> "$switch expected an array for 'branches', " <TAB> <TAB> <TAB> <TAB> "found: %s" % type ( branches ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if not branches : <TAB> <TAB> <TAB> raise OperationFailure ( "$switch requires at least one branch." ) <TAB> <TAB> for branch in branches : <TAB> <TAB> <TAB> if not isinstance ( branch, dict ) : <TAB> <TAB> <TAB> <TAB> raise OperationFailure ( <TAB> <TAB> <TAB> <TAB> <TAB> "$switch expected each branch to be an object, " <TAB> <TAB> <TAB> <TAB> <TAB> "found: %s" % type ( branch ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise OperationFailure ( <TAB> <TAB> <TAB> <TAB> <TAB> "$switch requires each branch have a 'case' expression" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if "then" not in branch : <TAB> <TAB> <TAB> <TAB> raise OperationFailure ( <TAB> <TAB> <TAB> <TAB> <TAB> "$switch requires each branch have a 'then' expression." <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> for branch in branches : <TAB> <TAB> <TAB> if self. | False | 'case' not in branch | 'case' in branch and (not 'then' in branch) | 0.6548657417297363 |
203 | 201 | def load_stack ( self, stack, index = None ) : <TAB> self. stack = stack <TAB> self. clear ( ) <TAB> for i in range ( len ( stack ) ) : <TAB> <TAB> frame, lineno = stack [ i ] <TAB> <TAB> try : <TAB> <TAB> <TAB> modname = frame. f_globals [ "__name__" ] <TAB> <TAB> except : <TAB> <TAB> <TAB> modname = "?" <TAB> <TAB> code = frame. f_code <TAB> <TAB> filename = code. co_filename <TAB> <TAB> funcname = code. co_name <TAB> <TAB> import linecache <TAB> <TAB> sourceline = linecache. getline ( filename, lineno ) <TAB> <TAB> import string <TAB> <TAB> sourceline = string. strip ( sourceline ) <TAB> <TAB> if funcname in ( "?", "", None ) : <TAB> <TAB> <TAB> item = "%s, line %d: %s" % ( modname, lineno, sourceline ) <TAB> <TAB> else : <TAB> <TAB> <TAB> item = "%s.%s(), line %d: %s" % ( modname, funcname, lineno, sourceline ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> item = "> " + item <TAB> <TAB> self. append ( item ) <TAB> if index is not None : <TAB> <TAB> self. select ( index ) | False | i == index | item is not None | 0.6747851371765137 |
204 | 202 | def can_read_or_exception ( <TAB> self, user, doc_class, doc_id, exception_class = PopupException ) : <TAB> if doc_id is None : <TAB> <TAB> return <TAB> try : <TAB> <TAB> ct = ContentType. objects. get_for_model ( doc_class ) <TAB> <TAB> doc = Document. objects. get ( object_id = doc_id, content_type = ct ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return doc <TAB> <TAB> else : <TAB> <TAB> <TAB> message = _ ( <TAB> <TAB> <TAB> <TAB> "Permission denied. %(username)s does not have the permissions required to access document %(id)s" <TAB> <TAB> <TAB> ) % { "username" : user. username, "id" : doc. id } <TAB> <TAB> <TAB> raise exception_class ( message ) <TAB> except Document. DoesNotExist : <TAB> <TAB> raise exception_class ( _ ( "Document %(id)s does not exist" ) % { "id" : doc_id } ) | False | doc.can_read(user) | user.username == doc.id | 0.6482595205307007 |
205 | 203 | def _defuse_padding ( self, IR_node ) : <TAB> auto_pad = IR_node. get_attr ( "auto_pad" ) <TAB> if auto_pad : <TAB> <TAB> input_node = self. parent_variable_name ( IR_node ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> padding = False <TAB> <TAB> elif auto_pad. startswith ( "SAME" ) : <TAB> <TAB> <TAB> padding = True <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( "Unknown padding type [{}].". format ( auto_pad ) ) <TAB> <TAB> return input_node, padding <TAB> else : <TAB> <TAB> padding = IR_node. get_attr ( "pads" ) <TAB> <TAB> if not is_valid_padding ( padding ) : <TAB> <TAB> <TAB> dim = len ( padding ) // 2 <TAB> <TAB> <TAB> padding_str = list ( ) <TAB> <TAB> <TAB> for i in xrange ( 1, dim ) : <TAB> <TAB> <TAB> <TAB> padding_str. append ( ( padding [ i ], padding [ i + dim ] ) ) <TAB> <TAB> <TAB> input_node = IR_node. variable_name + "_pad" <TAB> <TAB> <TAB> self. add_body ( <TAB> <TAB> <TAB> <TAB> 1, <TAB> <TAB> <TAB> <TAB> "{:<15} = cntk.pad({}, pattern={})". format ( <TAB> <TAB> <TAB> <TAB> <TAB> input_node, self. parent_variable_name ( IR_node ), padding_str <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> input_node = self. parent_variable_name ( IR_node ) <TAB> <TAB> return input_node, False | False | auto_pad == 'VALID' | input_node.is_const() | 0.6594029664993286 |
206 | 204 | def append_chunk ( self, source, chunk ) : <TAB> try : <TAB> <TAB> data = json. loads ( chunk ) <TAB> except ValueError : <TAB> <TAB> logger. error ( "unable to decode chunk %s", chunk, exc_info = True ) <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> ts = data [ "timestamp" ] <TAB> <TAB> <TAB> self. results. setdefault ( ts, { } ) <TAB> <TAB> <TAB> for key, value in data [ "fields" ]. iteritems ( ) : <TAB> <TAB> <TAB> <TAB> if data [ "name" ] == "diskio" : <TAB> <TAB> <TAB> <TAB> <TAB> data [ "name" ] = "{metric_name}-{disk_id}". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> metric_name = data [ "name" ], disk_id = data [ "tags" ] [ "name" ] <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> elif data [ "name" ] == "net" : <TAB> <TAB> <TAB> <TAB> <TAB> data [ "name" ] = "{metric_name}-{interface}". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> metric_name = data [ "name" ], interface = data [ "tags" ] [ "interface" ] <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> elif data [ "name" ] == "cpu" : <TAB> <TAB> <TAB> <TAB> <TAB> data [ "name" ] = "{metric_name}-{cpu_id}". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> metric_name = data [ "name" ], cpu_id = data [ "tags" ] [ "cpu" ] <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> key = data [ "name" ] | False | key.endswith('_exec_value') | data['fields'] | 0.6448678970336914 |
207 | 205 | def CastClass ( c, graph = None ) : <TAB> graph = graph is None and c. factoryGraph or graph <TAB> for kind in graph. objects ( subject = classOrIdentifier ( c ), predicate = RDF. type ) : <TAB> <TAB> if kind == OWL_NS. Restriction : <TAB> <TAB> <TAB> kwArgs = { "identifier" : classOrIdentifier ( c ), "graph" : graph } <TAB> <TAB> <TAB> for s, p, o in graph. triples ( ( classOrIdentifier ( c ), None, None ) ) : <TAB> <TAB> <TAB> <TAB> if p!= RDF. type : <TAB> <TAB> <TAB> <TAB> <TAB> if p == OWL_NS. onProperty : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> kwArgs [ "onProperty" ] = o <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> kwArgs [ str ( p. split ( OWL_NS ) [ - 1 ] ) ] = o <TAB> <TAB> <TAB> if not set ( <TAB> <TAB> <TAB> <TAB> [ str ( i. split ( OWL_NS ) [ - 1 ] ) for i in Restriction. restrictionKinds ] <TAB> <TAB> <TAB> ). intersection ( kwArgs ) : <TAB> <TAB> <TAB> <TAB> raise MalformedClass ( "Malformed owl:Restriction" ) <TAB> <TAB> <TAB> return Restriction ( ** kwArgs ) <TAB> <TAB> else : <TAB> <TAB> <TAB> for s, p, o in graph. triples_choices ( <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> classOrIdentifier ( c ), <TAB> <TAB> <TAB> <TAB> <TAB> [ OWL_NS. intersectionOf, OWL_NS. unionOf, OWL_NS | False | p not in Restriction.restrictionKinds | s == OWL_NS.queryByC | 0.6659875512123108 |
208 | 206 | def get_unique_attribute ( self, name : str ) : <TAB> feat = None <TAB> for f in self. features : <TAB> <TAB> if self. _return_feature ( f ) and hasattr ( f, name ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( "The attribute was not unique." ) <TAB> <TAB> <TAB> feat = f <TAB> if feat is None : <TAB> <TAB> raise RuntimeError ( "The attribute did not exist" ) <TAB> return getattr ( feat, name ) | False | feat is not None | f.unique() | 0.6638916730880737 |
209 | 207 | def _patch ( ) : <TAB> """Monkey-patch pyopengl to fix a bug in glBufferSubData.""" <TAB> import sys <TAB> from OpenGL import GL <TAB> if sys. version_info > ( 3, ) : <TAB> <TAB> buffersubdatafunc = GL. glBufferSubData <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> buffersubdatafunc = buffersubdatafunc. wrapperFunction <TAB> <TAB> _m = sys. modules [ buffersubdatafunc. __module__ ] <TAB> <TAB> _m. long = int <TAB> <TAB> try : <TAB> <TAB> from OpenGL. GL. VERSION import GL_2_0 <TAB> <TAB> GL_2_0. GL_OBJECT_SHADER_SOURCE_LENGTH = GL_2_0. GL_SHADER_SOURCE_LENGTH <TAB> except Exception : <TAB> <TAB> pass | False | hasattr(buffersubdatafunc, 'wrapperFunction') | buffersubdatafunc.wrapperFunction is not None | 0.6605888605117798 |
210 | 208 | def formatmonthname ( self, theyear, themonth, withyear = True ) : <TAB> with TimeEncoding ( self. locale ) as encoding : <TAB> <TAB> s = month_name [ themonth ] <TAB> <TAB> if encoding is not None : <TAB> <TAB> <TAB> s = s. decode ( encoding ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> s = "%s %s" % ( s, theyear ) <TAB> <TAB> return '<tr><th colspan="7" class="month">%s</th></tr>' % s | False | withyear | withyear is True | 0.6964929103851318 |
211 | 209 | def _write_summaries ( self, summary_dict, relative_path = "" ) : <TAB> for name, value in summary_dict. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _write_summaries ( <TAB> <TAB> <TAB> <TAB> value, relative_path = os. path. join ( relative_path, name ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> with self. summary_writer ( relative_path ). as_default ( ) : <TAB> <TAB> <TAB> <TAB> self. _summary_fn ( name, value, step = self. _global_step ) | False | isinstance(value, dict) | relative_path | 0.6482176780700684 |
212 | 210 | def execute_many ( self, query : str, values : list ) -> None : <TAB> async with self. acquire_connection ( ) as connection : <TAB> <TAB> self. log. debug ( "%s: %s", query, values ) <TAB> <TAB> async with connection. cursor ( ) as cursor : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> await connection. begin ( ) <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> await cursor. executemany ( query, values ) <TAB> <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> await connection. rollback ( ) <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> await connection. commit ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> await cursor. executemany ( query, values ) | False | self.capabilities.supports_transactions | self.enable_multi_tab | 0.6564269065856934 |
213 | 211 | def read ( self, iprot ) : <TAB> if ( <TAB> <TAB> iprot. __class__ == TBinaryProtocol. TBinaryProtocolAccelerated <TAB> <TAB> and isinstance ( iprot. trans, TTransport. CReadableTransport ) <TAB> <TAB> and self. thrift_spec is not None <TAB> <TAB> and fastbinary is not None <TAB> ) : <TAB> <TAB> fastbinary. decode_binary ( self, iprot. trans, ( self. __class__, self. thrift_spec ) ) <TAB> <TAB> return <TAB> iprot. readStructBegin ( ) <TAB> while True : <TAB> <TAB> ( fname, ftype, fid ) = iprot. readFieldBegin ( ) <TAB> <TAB> if ftype == TType. STOP : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 1 : <TAB> <TAB> <TAB> if ftype == TType. I32 : <TAB> <TAB> <TAB> <TAB> self. protocol_version = iprot. readI32 ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. propertyName = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 3 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. defaultValue = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> else : <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> iprot. readFieldEnd ( ) <TAB> iprot. readStructEnd ( ) | True | fid == 2 | fid == 2 | 0.675895094871521 |
214 | 212 | def _iter_ns_range ( self ) : <TAB> """Iterates over self._ns_range, delegating to self._iter_key_range().""" <TAB> while True : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> query = self. _ns_range. make_datastore_query ( ) <TAB> <TAB> <TAB> namespace_result = query. Get ( 1 ) <TAB> <TAB> <TAB> if not namespace_result : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> namespace = namespace_result [ 0 ]. name ( ) or "" <TAB> <TAB> <TAB> self. _current_key_range = key_range. KeyRange ( <TAB> <TAB> <TAB> <TAB> namespace = namespace, _app = self. _ns_range. app <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> yield ALLOW_CHECKPOINT <TAB> <TAB> for key, o in self. _iter_key_range ( copy. deepcopy ( self. _current_key_range ) ) : <TAB> <TAB> <TAB> self. _current_key_range. advance ( key ) <TAB> <TAB> <TAB> yield o <TAB> <TAB> if ( <TAB> <TAB> <TAB> self. _ns_range. is_single_namespace <TAB> <TAB> <TAB> or self. _current_key_range. namespace == self. _ns_range. namespace_end <TAB> <TAB> ) : <TAB> <TAB> <TAB> break <TAB> <TAB> self. _ns_range = self. _ns_range. with_start_after ( <TAB> <TAB> <TAB> self. _current_key_range. namespace <TAB> <TAB> ) <TAB> <TAB> self. _current_key_range = None | False | self._current_key_range is None | self._current_key_range | 0.6533119678497314 |
215 | 213 | def __init__ ( self, artifact = None, pad = None ) : <TAB> if pad is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> "Either artifact or pad is needed to " "construct a context." <TAB> <TAB> <TAB> ) <TAB> <TAB> pad = artifact. build_state. pad <TAB> if artifact is not None : <TAB> <TAB> self. artifact = artifact <TAB> <TAB> self. source = artifact. source_obj <TAB> <TAB> self. build_state = self. artifact. build_state <TAB> else : <TAB> <TAB> self. artifact = None <TAB> <TAB> self. source = None <TAB> <TAB> self. build_state = None <TAB> self. exc_info = None <TAB> self. pad = pad <TAB> <TAB> self. referenced_dependencies = set ( ) <TAB> self. referenced_virtual_dependencies = { } <TAB> self. sub_artifacts = [ ] <TAB> self. flow_block_render_stack = [ ] <TAB> self. _forced_base_url = None <TAB> <TAB> <TAB> self. cache = { } <TAB> self. _dependency_collectors = [ ] | True | artifact is None | artifact is None | 0.6947907209396362 |
216 | 214 | def _fix_default ( self, action ) : <TAB> if ( <TAB> <TAB> hasattr ( action, "default" ) <TAB> <TAB> and hasattr ( action, "dest" ) <TAB> <TAB> and action. default!= SUPPRESS <TAB> ) : <TAB> <TAB> as_type = get_type ( action ) <TAB> <TAB> names = OrderedDict ( <TAB> <TAB> <TAB> ( i. lstrip ( "-" ). replace ( "-", "_" ), None ) for i in action. option_strings <TAB> <TAB> ) <TAB> <TAB> outcome = None <TAB> <TAB> for name in names : <TAB> <TAB> <TAB> outcome = get_env_var ( name, as_type, self. env ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if outcome is None and self. file_config : <TAB> <TAB> <TAB> for name in names : <TAB> <TAB> <TAB> <TAB> outcome = self. file_config. get ( name, as_type ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> action. default, action. default_source = outcome <TAB> <TAB> else : <TAB> <TAB> <TAB> outcome = action. default, "default" <TAB> <TAB> self. options. set_src ( action. dest, * outcome ) | True | outcome is not None | outcome is not None | 0.6617662906646729 |
217 | 215 | def disassemble ( self, byte_parser, histogram = False ) : <TAB> """Disassemble code, for ad-hoc experimenting.""" <TAB> for bp in byte_parser. child_parsers ( ) : <TAB> <TAB> if bp. text : <TAB> <TAB> <TAB> srclines = bp. text. splitlines ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> srclines = None <TAB> <TAB> print ( "\n%s: " % bp. code ) <TAB> <TAB> upto = None <TAB> <TAB> for disline in disgen. disgen ( bp. code ) : <TAB> <TAB> <TAB> if histogram : <TAB> <TAB> <TAB> <TAB> opcode_counts [ disline. opcode ] += 1 <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if srclines : <TAB> <TAB> <TAB> <TAB> <TAB> upto = upto or disline. lineno - 1 <TAB> <TAB> <TAB> <TAB> <TAB> while upto <= disline. lineno - 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( "%100s%s" % ( "", srclines [ upto ] ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> upto += 1 <TAB> <TAB> <TAB> <TAB> elif disline. offset > 0 : <TAB> <TAB> <TAB> <TAB> <TAB> print ( "" ) <TAB> <TAB> <TAB> line = disgen. format_dis_line ( disline ) <TAB> <TAB> <TAB> print ( "%-70s" % ( line, ) ) <TAB> print ( "" ) | False | disline.first | not upto | 0.6575723886489868 |
218 | 216 | def send_request ( self, request_method, * args, ** kwargs ) : <TAB> request_func = getattr ( self. client, request_method ) <TAB> status_code = None <TAB> if "content_type" not in kwargs and request_method!= "get" : <TAB> <TAB> kwargs [ "content_type" ] = "application/json" <TAB> if ( <TAB> <TAB> "data" in kwargs <TAB> <TAB> and request_method!= "get" <TAB> <TAB> and kwargs [ "content_type" ] == "application/json" <TAB> ) : <TAB> <TAB> data = kwargs. get ( "data", "" ) <TAB> <TAB> kwargs [ "data" ] = json. dumps ( data ) <TAB> if "status_code" in kwargs : <TAB> <TAB> status_code = kwargs. pop ( "status_code" ) <TAB> <TAB> if hasattr ( self, "token" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kwargs [ "HTTP_AUTHORIZATION" ] = "JWT %s" % self. token <TAB> <TAB> else : <TAB> <TAB> <TAB> kwargs [ "HTTP_AUTHORIZATION" ] = "Token %s" % self. token <TAB> self. response = request_func ( * args, ** kwargs ) <TAB> is_json = bool ( [ x for x in self. response. _headers [ "content-type" ] if "json" in x ] ) <TAB> self. response. json = { } <TAB> if is_json and self. response. content : <TAB> <TAB> self. response. json = json. loads ( force_text ( self. response. content ) ) <TAB> if status_code : <TAB> <TAB> self. assertEqual ( self. response. status_code, status_code ) <TAB> return self. response | False | getattr(settings, 'REST_USE_JWT', False) | self.token | 0.6538990139961243 |
219 | 217 | def _wait_for_bot_presense ( self, online ) : <TAB> for _ in range ( 10 ) : <TAB> <TAB> time. sleep ( 2 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> if not online and not self. _is_testbot_online ( ) : <TAB> <TAB> <TAB> break <TAB> else : <TAB> <TAB> raise AssertionError ( <TAB> <TAB> <TAB> "test bot is still {}". format ( "offline" if online else "online" ) <TAB> <TAB> ) | False | online and self._is_testbot_online() | online and self._is_offline() | 0.6514002084732056 |
220 | 218 | def set_logging ( self, showOnCmd = True, loggingFile = None, loggingLevel = logging. INFO ) : <TAB> if showOnCmd!= self. showOnCmd : <TAB> <TAB> if showOnCmd : <TAB> <TAB> <TAB> self. logger. addHandler ( self. cmdHandler ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. logger. removeHandler ( self. cmdHandler ) <TAB> <TAB> self. showOnCmd = showOnCmd <TAB> if loggingFile!= self. loggingFile : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. logger. removeHandler ( self. fileHandler ) <TAB> <TAB> <TAB> self. fileHandler. close ( ) <TAB> <TAB> if loggingFile is not None : <TAB> <TAB> <TAB> self. fileHandler = logging. FileHandler ( loggingFile ) <TAB> <TAB> <TAB> self. logger. addHandler ( self. fileHandler ) <TAB> <TAB> self. loggingFile = loggingFile <TAB> if loggingLevel!= self. loggingLevel : <TAB> <TAB> self. logger. setLevel ( loggingLevel ) <TAB> <TAB> self. loggingLevel = loggingLevel | False | self.loggingFile is not None | self.fileHandler is not None | 0.6544582843780518 |
221 | 219 | def render ( self, mcanv, op, idx ) : <TAB> value = self. imm <TAB> hint = mcanv. syms. getSymHint ( op. va, idx ) <TAB> if hint is not None : <TAB> <TAB> if mcanv. mem. isValidPointer ( value ) : <TAB> <TAB> <TAB> mcanv. addVaText ( hint, value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> mcanv. addNameText ( hint ) <TAB> elif mcanv. mem. isValidPointer ( value ) : <TAB> <TAB> name = addrToName ( mcanv, value ) <TAB> <TAB> mcanv. addVaText ( name, value ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> mcanv. addNameText ( "0x%.4x:0x%.8x" % ( value >> 32, value & 0xFFFFFFFF ) ) <TAB> <TAB> elif self. imm >= 4096 : <TAB> <TAB> <TAB> mcanv. addNameText ( "0x%.8x" % value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> mcanv. addNameText ( str ( value ) ) | False | self.tsize == 6 | self.imm >= 512 | 0.6593555212020874 |
222 | 220 | def _guardAgainstUnicode ( self, data ) : <TAB> <TAB> <TAB> if _pythonMajorVersion < 3 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> data = data. encode ( "utf8" ) <TAB> else : <TAB> <TAB> if isinstance ( data, str ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> return data. encode ( "ascii" ) <TAB> <TAB> <TAB> except UnicodeEncodeError : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> raise ValueError ( "pyDes can only work with encoded strings, not Unicode." ) <TAB> return data | True | isinstance(data, unicode) | isinstance(data, unicode) | 0.6502571105957031 |
223 | 221 | def get ( self, block = True, timeout = None ) : <TAB> if block and timeout is None : <TAB> <TAB> self. _rlock. acquire ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> res = self. _recv ( ) <TAB> <TAB> <TAB> self. _sem. release ( ) <TAB> <TAB> <TAB> return res <TAB> <TAB> finally : <TAB> <TAB> <TAB> self. _rlock. release ( ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> deadline = time. time ( ) + timeout <TAB> <TAB> if not self. _rlock. acquire ( block, timeout ) : <TAB> <TAB> <TAB> raise Empty <TAB> <TAB> try : <TAB> <TAB> <TAB> if not self. _poll ( block and ( deadline - time. time ( ) ) or 0.0 ) : <TAB> <TAB> <TAB> <TAB> raise Empty <TAB> <TAB> <TAB> res = self. _recv ( ) <TAB> <TAB> <TAB> self. _sem. release ( ) <TAB> <TAB> <TAB> return res <TAB> <TAB> finally : <TAB> <TAB> <TAB> self. _rlock. release ( ) | False | block | timeout is not None | 0.6791608333587646 |
224 | 222 | def __init__ ( self, name, lines ) : <TAB> self. name = name <TAB> self. flds = [ ] <TAB> self. parms = { } <TAB> self. recfmt = None <TAB> <TAB> <TAB> line_pat = re. compile ( r"(\w+) = (.*)", re. VERBOSE ) <TAB> for lne in lines : <TAB> <TAB> mtch = line_pat. match ( lne ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. parms [ mtch. group ( 1 ) ] = mtch. group ( 2 ) <TAB> self. fileext = self. parms. get ( "fileext", None ) <TAB> <TAB> <TAB> if "n_fields" in self. parms : <TAB> <TAB> self. get_fields ( ) <TAB> <TAB> self. recfmt = self. get_recfmt ( ) <TAB> <TAB> self. nam2fld = { } <TAB> <TAB> self. nam2idx = { } <TAB> <TAB> self. recflds = [ ] <TAB> <TAB> j = 0 <TAB> <TAB> for fld in enumerate ( self. flds ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> nam = fld [ 1 ]. name <TAB> <TAB> <TAB> self. nam2fld [ nam ] = fld <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if fld [ 1 ]. size!= 0 : <TAB> <TAB> <TAB> <TAB> self. nam2idx [ nam ] = j <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. recflds. append ( fld [ 1 ] ) <TAB> <TAB> <TAB> <TAB> j += 1 | True | mtch | mtch | 0.7154645919799805 |
225 | 223 | def __getitem__ ( self, key ) : <TAB> arch = self. _project. arch <TAB> if key in arch. registers : <TAB> <TAB> <TAB> <TAB> reg_offset, size = arch. registers [ key ] <TAB> <TAB> <TAB> <TAB> cfg_node = self. _cfg. model. get_any_node ( self. _insn_addr, anyaddr = True ) <TAB> <TAB> if cfg_node is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise KeyError ( <TAB> <TAB> <TAB> <TAB> "CFGNode for instruction %#x is not found." % self. _insn_addr <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> vex_block = self. _project. factory. block ( <TAB> <TAB> <TAB> cfg_node. addr, size = cfg_node. size, opt_level = self. _cfg. _iropt_level <TAB> <TAB> ). vex <TAB> <TAB> stmt_idx = None <TAB> <TAB> insn_addr = cfg_node. addr <TAB> <TAB> for i, stmt in enumerate ( vex_block. statements ) : <TAB> <TAB> <TAB> if isinstance ( stmt, pyvex. IRStmt. IMark ) : <TAB> <TAB> <TAB> <TAB> insn_addr = stmt. addr + stmt. delta <TAB> <TAB> <TAB> elif insn_addr == self. _insn_addr : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> stmt_idx = i <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> elif insn_addr > self. _insn_addr : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if stmt_idx is None : <TAB> <TAB> <TAB> raise KeyError ( "Cannot find the statement." ) <TAB> <TAB> <TAB> <TAB> variable = SimRegisterVariable ( reg_offset, size ) <TAB> <TAB | False | isinstance(stmt, pyvex.IRStmt.Put) and stmt.offset == reg_offset | i is None | 0.6516926288604736 |
226 | 224 | def _get_dependency_manager ( dependency_manager, runtime ) : <TAB> if not dependency_manager : <TAB> <TAB> valid_dep_managers = RUNTIME_TO_DEPENDENCY_MANAGERS. get ( runtime ) <TAB> <TAB> if valid_dep_managers is None : <TAB> <TAB> <TAB> dependency_manager = None <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> dependency_manager = valid_dep_managers [ 0 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> choices = list ( map ( str, range ( 1, len ( valid_dep_managers ) + 1 ) ) ) <TAB> <TAB> <TAB> choice_num = 1 <TAB> <TAB> <TAB> click. echo ( "\nWhich dependency manager would you like to use?" ) <TAB> <TAB> <TAB> for dm in valid_dep_managers : <TAB> <TAB> <TAB> <TAB> msg = "\t" + str ( choice_num ) + " - " + dm <TAB> <TAB> <TAB> <TAB> click. echo ( msg ) <TAB> <TAB> <TAB> <TAB> choice_num = choice_num + 1 <TAB> <TAB> <TAB> choice = click. prompt ( <TAB> <TAB> <TAB> <TAB> "Dependency manager", type = click. Choice ( choices ), show_choices = False <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> dependency_manager = valid_dep_managers [ int ( choice ) - 1 ] <TAB> return dependency_manager | True | len(valid_dep_managers) == 1 | len(valid_dep_managers) == 1 | 0.6554791331291199 |
227 | 225 | def compare ( self, first, second, scope_bracket = False ) : <TAB> """Compare brackets. This function allows bracket plugins to add additional logic.""" <TAB> if<mask> : <TAB> <TAB> match = first is not None and second is not None <TAB> else : <TAB> <TAB> match = first. type == second. type <TAB> if not self. rules. check_compare : <TAB> <TAB> return match <TAB> if match : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> bracket = self. rules. scopes [ first. scope ] [ "brackets" ] [ first. type ] <TAB> <TAB> else : <TAB> <TAB> <TAB> bracket = self. rules. brackets [ first. type ] <TAB> <TAB> try : <TAB> <TAB> <TAB> if bracket. compare is not None and match : <TAB> <TAB> <TAB> <TAB> match = bracket. compare ( <TAB> <TAB> <TAB> <TAB> <TAB> bracket. name, <TAB> <TAB> <TAB> <TAB> <TAB> bh_plugin. BracketRegion ( first. begin, first. end ), <TAB> <TAB> <TAB> <TAB> <TAB> bh_plugin. BracketRegion ( second. begin, second. end ), <TAB> <TAB> <TAB> <TAB> <TAB> self. search. get_buffer ( ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> log ( "Plugin Compare Error:\n%s" % str ( traceback. format_exc ( ) ) ) <TAB> return match | True | scope_bracket | scope_bracket | 0.6667361259460449 |
228 | 226 | def _to_record ( self, data, zone ) : <TAB> records = [ ] <TAB> rrset_values = data [ "rrset_values" ] <TAB> multiple_value_record = len ( rrset_values ) > 1 <TAB> for index, rrset_value in enumerate ( rrset_values ) : <TAB> <TAB> record = self. _to_record_sub ( data, zone, rrset_value ) <TAB> <TAB> record. extra [ "_multi_value" ] = multiple_value_record <TAB> <TAB> if multiple_value_record : <TAB> <TAB> <TAB> record. extra [ "_other_records" ] = [ ] <TAB> <TAB> records. append ( record ) <TAB> if multiple_value_record : <TAB> <TAB> for index in range ( 0, len ( records ) ) : <TAB> <TAB> <TAB> record = records [ index ] <TAB> <TAB> <TAB> for other_index, other_record in enumerate ( records ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> extra = copy. deepcopy ( other_record. extra ) <TAB> <TAB> <TAB> <TAB> extra. pop ( "_multi_value" ) <TAB> <TAB> <TAB> <TAB> extra. pop ( "_other_records" ) <TAB> <TAB> <TAB> <TAB> item = { <TAB> <TAB> <TAB> <TAB> <TAB> "name" : other_record. name, <TAB> <TAB> <TAB> <TAB> <TAB> "data" : other_record. data, <TAB> <TAB> <TAB> <TAB> <TAB> "type" : other_record. type, <TAB> <TAB> <TAB> <TAB> <TAB> "extra" : extra, <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> record. extra [ "_other_records" ]. append ( item ) <TAB> return records | False | index == other_index | hasattr(other_record, '_other_records') | 0.656635046005249 |
229 | 227 | def decompress ( self, data ) : <TAB> if not data : <TAB> <TAB> return data <TAB> if not self. _first_try : <TAB> <TAB> return self. _obj. decompress ( data ) <TAB> self. _data += data <TAB> try : <TAB> <TAB> decompressed = self. _obj. decompress ( data ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _first_try = False <TAB> <TAB> <TAB> self. _data = None <TAB> <TAB> return decompressed <TAB> except zlib. error : <TAB> <TAB> self. _first_try = False <TAB> <TAB> self. _obj = zlib. decompressobj ( - zlib. MAX_WBITS ) <TAB> <TAB> try : <TAB> <TAB> <TAB> return self. decompress ( self. _data ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> self. _data = None | True | decompressed | decompressed | 0.6855396032333374 |
230 | 228 | def CountButtons ( self ) : <TAB> """Returns the number of visible buttons in the docked pane.""" <TAB> n = 0 <TAB> if self. HasCaption ( ) or self. HasCaptionLeft ( ) : <TAB> <TAB> if isinstance ( wx. GetTopLevelParent ( self. window ), AuiFloatingFrame ) : <TAB> <TAB> <TAB> return 1 <TAB> <TAB> if self. HasCloseButton ( ) : <TAB> <TAB> <TAB> n += 1 <TAB> <TAB> if self. HasMaximizeButton ( ) : <TAB> <TAB> <TAB> n += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> n += 1 <TAB> <TAB> if self. HasPinButton ( ) : <TAB> <TAB> <TAB> n += 1 <TAB> return n | False | self.HasMinimizeButton() | self.HasPinButton() | 0.661885142326355 |
231 | 229 | def layer_op ( self, image ) : <TAB> if image. ndim == 3 : <TAB> <TAB> return self. __make_mask_3d ( image ) <TAB> if image. ndim == 5 : <TAB> <TAB> mod_to_mask = [ m for m in range ( image. shape [ 4 ] ) if np. any ( image [..., :, m ] ) ] <TAB> <TAB> mask = np. zeros_like ( image, dtype = bool ) <TAB> <TAB> mod_mask = None <TAB> <TAB> for mod in mod_to_mask : <TAB> <TAB> <TAB> for t in range ( image. shape [ 3 ] ) : <TAB> <TAB> <TAB> <TAB> mask [..., t, mod ] = self. __make_mask_3d ( image [..., t, mod ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if mod_mask is None : <TAB> <TAB> <TAB> <TAB> <TAB> mod_mask = np. zeros ( image. shape [ : 4 ], dtype = bool ) <TAB> <TAB> <TAB> <TAB> mod_mask = np. logical_or ( mod_mask, mask [..., mod ] ) <TAB> <TAB> <TAB> elif self. multimod_fusion == "and" : <TAB> <TAB> <TAB> <TAB> if mod_mask is None : <TAB> <TAB> <TAB> <TAB> <TAB> mod_mask = np. ones ( image. shape [ : 4 ], dtype = bool ) <TAB> <TAB> <TAB> <TAB> mod_mask = np. logical_and ( mod_mask, mask [..., mod ] ) <TAB> <TAB> for mod in mod_to_mask : <TAB> <TAB> <TAB> mask [..., mod ] = mod_mask <TAB> <TAB> return mask <TAB> else : <TAB> <TAB> raise ValueError ( "unknown input format" ) | True | self.multimod_fusion == 'or' | self.multimod_fusion == 'or' | 0.6509130597114563 |
232 | 230 | def process_resource ( self, resource, related ) : <TAB> related_ids = self. get_related_ids ( [ resource ] ) <TAB> model = self. manager. get_model ( ) <TAB> op = self. data. get ( "operator", "or" ) <TAB> found = [ ] <TAB> if self. data. get ( "match-resource" ) is True : <TAB> <TAB> self. data [ "value" ] = self. get_resource_value ( self. data [ "key" ], resource ) <TAB> if self. data. get ( "value_type" ) == "resource_count" : <TAB> <TAB> count_matches = OPERATORS [ self. data. get ( "op" ) ] ( <TAB> <TAB> <TAB> len ( related_ids ), self. data. get ( "value" ) <TAB> <TAB> ) <TAB> <TAB> if count_matches : <TAB> <TAB> <TAB> self. _add_annotations ( related_ids, resource ) <TAB> <TAB> return count_matches <TAB> for rid in related_ids : <TAB> <TAB> robj = related. get ( rid, None ) <TAB> <TAB> if robj is None : <TAB> <TAB> <TAB> self. log. warning ( <TAB> <TAB> <TAB> <TAB> "Resource %s:%s references non existant %s: %s", <TAB> <TAB> <TAB> <TAB> self. manager. type, <TAB> <TAB> <TAB> <TAB> resource [ model. id ], <TAB> <TAB> <TAB> <TAB> self. RelatedResource. rsplit ( ".", 1 ) [ - 1 ], <TAB> <TAB> <TAB> <TAB> rid, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> found. append ( rid ) <TAB> if found : <TAB> <TAB> self. _add_annotations ( found, resource ) <TAB> if op == "or" and found : <TAB> <TAB> return True <TAB> elif op == "and" and len ( found | False | self.match(robj) | rid in related_ids | 0.6497014760971069 |
233 | 231 | def write_custom_dns_config ( config, env ) : <TAB> <TAB> <TAB> from collections import OrderedDict <TAB> config = list ( config ) <TAB> dns = OrderedDict ( ) <TAB> seen_qnames = set ( ) <TAB> <TAB> for qname in [ rec [ 0 ] for rec in config ] : <TAB> <TAB> if qname in seen_qnames : <TAB> <TAB> <TAB> continue <TAB> <TAB> seen_qnames. add ( qname ) <TAB> <TAB> records = [ ( rec [ 1 ], rec [ 2 ] ) for rec in config if rec [ 0 ] == qname ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> dns [ qname ] = records [ 0 ] [ 1 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> dns [ qname ] = OrderedDict ( ) <TAB> <TAB> <TAB> seen_rtypes = set ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for rtype in [ rec [ 0 ] for rec in records ] : <TAB> <TAB> <TAB> <TAB> if rtype in seen_rtypes : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> seen_rtypes. add ( rtype ) <TAB> <TAB> <TAB> <TAB> values = [ rec [ 1 ] for rec in records if rec [ 0 ] == rtype ] <TAB> <TAB> <TAB> <TAB> if len ( values ) == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> values = values [ 0 ] <TAB> <TAB> <TAB> <TAB> dns [ qname ] [ rtype ] = values <TAB> <TAB> config_yaml = rtyaml. dump ( dns ) <TAB> with open ( os. path. join ( env [ "STORAGE_ROOT" ], "dns/custom.yaml" ), "w" ) as f : <TAB> <TAB> f. write ( config_yaml ) | False | len(records) == 1 and records[0][0] == 'A' | len(records) == 1 | 0.6518056988716125 |
234 | 232 | def translate ( self, line ) : <TAB> parsed = self. RE_LINE_PARSER. match ( line ) <TAB> if parsed : <TAB> <TAB> value = parsed. group ( 3 ) <TAB> <TAB> stage = parsed. group ( 1 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return "\n# HTTP Request:\n" + self. stripslashes ( value ) <TAB> <TAB> elif stage == "reply" : <TAB> <TAB> <TAB> return "\n\n# HTTP Response:\n" + self. stripslashes ( value ) <TAB> <TAB> elif stage == "header" : <TAB> <TAB> <TAB> return value + "\n" <TAB> <TAB> else : <TAB> <TAB> <TAB> return value <TAB> return line | False | stage == 'send' | stage == 'request' | 0.665850043296814 |
235 | 233 | def _encode_regex ( name, value, dummy0, dummy1 ) : <TAB> """Encode a python regex or bson.regex.Regex.""" <TAB> flags = value. flags <TAB> <TAB> if flags == 0 : <TAB> <TAB> return b"\x0B" + name + _make_c_string_check ( value. pattern ) + b"\x00" <TAB> <TAB> elif flags == re. UNICODE : <TAB> <TAB> return b"\x0B" + name + _make_c_string_check ( value. pattern ) + b"u\x00" <TAB> else : <TAB> <TAB> sflags = b"" <TAB> <TAB> if flags & re. IGNORECASE : <TAB> <TAB> <TAB> sflags += b"i" <TAB> <TAB> if flags & re. LOCALE : <TAB> <TAB> <TAB> sflags += b"l" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sflags += b"m" <TAB> <TAB> if flags & re. DOTALL : <TAB> <TAB> <TAB> sflags += b"s" <TAB> <TAB> if flags & re. UNICODE : <TAB> <TAB> <TAB> sflags += b"u" <TAB> <TAB> if flags & re. VERBOSE : <TAB> <TAB> <TAB> sflags += b"x" <TAB> <TAB> sflags += b"\x00" <TAB> <TAB> return b"\x0B" + name + _make_c_string_check ( value. pattern ) + sflags | False | flags & re.MULTILINE | flags & re.DOTALL | 0.6712432503700256 |
236 | 234 | def find_field_type_differ ( self, meta, table_description, table_name, func = None ) : <TAB> db_fields = dict ( [ ( row [ 0 ], row ) for row in table_description ] ) <TAB> for field in all_local_fields ( meta ) : <TAB> <TAB> if field. name not in db_fields : <TAB> <TAB> <TAB> continue <TAB> <TAB> description = db_fields [ field. name ] <TAB> <TAB> model_type = self. get_field_model_type ( field ) <TAB> <TAB> db_type = self. get_field_db_type ( description, field, table_name ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> model_type, db_type = func ( field, description, model_type, db_type ) <TAB> <TAB> if not self. strip_parameters ( db_type ) == self. strip_parameters ( model_type ) : <TAB> <TAB> <TAB> self. add_difference ( <TAB> <TAB> <TAB> <TAB> "field-type-differ", table_name, field. name, model_type, db_type <TAB> <TAB> <TAB> ) | False | func | func is not None | 0.6735049486160278 |
237 | 235 | def _activate_plugins_of_category ( self, category ) : <TAB> """Activate all the plugins of a given category and return them.""" <TAB> <TAB> plugins = [ ] <TAB> for plugin_info in self. plugin_manager. getPluginsOfCategory ( category ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. plugin_manager. removePluginFromCategory ( plugin_info, category ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. plugin_manager. activatePluginByName ( plugin_info. name ) <TAB> <TAB> <TAB> plugin_info. plugin_object. set_site ( self ) <TAB> <TAB> <TAB> plugins. append ( plugin_info ) <TAB> return plugins | False | plugin_info.name in self.config.get('DISABLED_PLUGINS') | plugin_info.plugin_object.get_site() == self | 0.6542697548866272 |
238 | 236 | def makeStaircaseCtrls ( self ) : <TAB> """Setup the controls for a StairHandler""" <TAB> panel = wx. Panel ( parent = self ) <TAB> panelSizer = wx. GridBagSizer ( 5, 5 ) <TAB> panel. SetSizer ( panelSizer ) <TAB> row = 0 <TAB> handler = self. stairHandler <TAB> <TAB> for fieldName in handler. params : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> label = handler. params [ fieldName ]. label <TAB> <TAB> <TAB> if not label : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> label = fieldName <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> label = fieldName <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if fieldName in self. globalCtrls : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ctrls = self. globalCtrls [ fieldName ] <TAB> <TAB> else : <TAB> <TAB> <TAB> ctrls = ParamCtrls ( <TAB> <TAB> <TAB> <TAB> dlg = self, <TAB> <TAB> <TAB> <TAB> parent = panel, <TAB> <TAB> <TAB> <TAB> label = label, <TAB> <TAB> <TAB> <TAB> fieldName = fieldName, <TAB> <TAB> <TAB> <TAB> param = handler. params [ fieldName ], <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> panelSizer. Add ( ctrls. nameCtrl, [ row, 0 ] ) <TAB> <TAB> <TAB> if hasattr ( ctrls. valueCtrl, "_szr" ) : <TAB> <TAB> <TAB> <TAB> panelSizer. Add ( ctrls. valueCtrl. _szr, [ row, 1 ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> panelSizer. Add ( ctrls. valueCtrl, [ row, 1 ] ) <TAB> <TAB> <TAB | False | fieldName == 'endPoints' | label and label and (label > self.label) | 0.6770456433296204 |
239 | 237 | def get_rules ( self, map ) : <TAB> for rulefactory in self. rules : <TAB> <TAB> for rule in rulefactory. get_rules ( map ) : <TAB> <TAB> <TAB> new_defaults = subdomain = None <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> new_defaults = { } <TAB> <TAB> <TAB> <TAB> for key, value in iteritems ( rule. defaults ) : <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( value, string_types ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> value = format_string ( value, self. context ) <TAB> <TAB> <TAB> <TAB> <TAB> new_defaults [ key ] = value <TAB> <TAB> <TAB> if rule. subdomain is not None : <TAB> <TAB> <TAB> <TAB> subdomain = format_string ( rule. subdomain, self. context ) <TAB> <TAB> <TAB> new_endpoint = rule. endpoint <TAB> <TAB> <TAB> if isinstance ( new_endpoint, string_types ) : <TAB> <TAB> <TAB> <TAB> new_endpoint = format_string ( new_endpoint, self. context ) <TAB> <TAB> <TAB> yield Rule ( <TAB> <TAB> <TAB> <TAB> format_string ( rule. rule, self. context ), <TAB> <TAB> <TAB> <TAB> new_defaults, <TAB> <TAB> <TAB> <TAB> subdomain, <TAB> <TAB> <TAB> <TAB> rule. methods, <TAB> <TAB> <TAB> <TAB> rule. build_only, <TAB> <TAB> <TAB> <TAB> new_endpoint, <TAB> <TAB> <TAB> <TAB> rule. strict_slashes, <TAB> <TAB> <TAB> ) | False | rule.defaults | rule.defaults is not None | 0.6711133718490601 |
240 | 238 | def cmd_exec_stdout ( self, command, errormsg = "", log = True ) : <TAB> """Run shell command from Python""" <TAB> try : <TAB> <TAB> log and Log. debug ( self, "Running command: {0}". format ( command ) ) <TAB> <TAB> with subprocess. Popen ( <TAB> <TAB> <TAB> [ command ], stdout = subprocess. PIPE, stderr = subprocess. PIPE, shell = True <TAB> <TAB> ) as proc : <TAB> <TAB> <TAB> ( cmd_stdout_bytes, cmd_stderr_bytes ) = proc. communicate ( ) <TAB> <TAB> <TAB> ( cmd_stdout, cmd_stderr ) = ( <TAB> <TAB> <TAB> <TAB> cmd_stdout_bytes. decode ( "utf-8", "replace" ), <TAB> <TAB> <TAB> <TAB> cmd_stderr_bytes. decode ( "utf-8", "replace" ), <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> Log. debug ( <TAB> <TAB> <TAB> <TAB> self, <TAB> <TAB> <TAB> <TAB> "Command Output: {0}, \nCommand Error: {1}". format ( <TAB> <TAB> <TAB> <TAB> <TAB> cmd_stdout, cmd_stderr <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return cmd_stdout <TAB> <TAB> else : <TAB> <TAB> <TAB> Log. debug ( <TAB> <TAB> <TAB> <TAB> self, <TAB> <TAB> <TAB> <TAB> "Command Output: {0}, \nCommand Error: {1}". format ( <TAB> <TAB> <TAB> <TAB> <TAB> cmd_stdout, cmd_stderr <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return cmd_stdout <TAB> except OSError as e : <TAB> <TAB> Log. debug ( self, str ( e ) ) <TAB> < | False | proc.returncode == 0 | log | 0.6539502739906311 |
241 | 239 | def getUnread ( self ) : <TAB> unreadMessages = 0 <TAB> unreadSubscriptions = 0 <TAB> queryreturn = sqlQuery ( <TAB> <TAB> """SELECT msgid, toaddress, read FROM inbox where folder='inbox' """ <TAB> ) <TAB> for row in queryreturn : <TAB> <TAB> msgid, toAddress, read = row <TAB> <TAB> try : <TAB> <TAB> <TAB> if toAddress == str_broadcast_subscribers : <TAB> <TAB> <TAB> <TAB> toLabel = str_broadcast_subscribers <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> toLabel = shared. config. get ( toAddress, "label" ) <TAB> <TAB> except : <TAB> <TAB> <TAB> toLabel = "" <TAB> <TAB> if toLabel == "" : <TAB> <TAB> <TAB> toLabel = toAddress <TAB> <TAB> if not read : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> unreadSubscriptions = unreadSubscriptions + 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> unreadMessages = unreadMessages + 1 <TAB> return unreadMessages, unreadSubscriptions | False | toLabel == str_broadcast_subscribers | toLabel != toLabel | 0.6621248722076416 |
242 | 240 | def populate_disk_bus_combo ( self, devtype, no_default ) : <TAB> buslist = self. widget ( "disk-bus-combo" ) <TAB> busmodel = buslist. get_model ( ) <TAB> busmodel. clear ( ) <TAB> buses = [ ] <TAB> if devtype == virtinst. VirtualDisk. DEVICE_FLOPPY : <TAB> <TAB> buses. append ( [ "fdc", "Floppy" ] ) <TAB> elif devtype == virtinst. VirtualDisk. DEVICE_CDROM : <TAB> <TAB> buses. append ( [ "ide", "IDE" ] ) <TAB> <TAB> if self. vm. rhel6_defaults ( ) : <TAB> <TAB> <TAB> buses. append ( [ "scsi", "SCSI" ] ) <TAB> else : <TAB> <TAB> if self. vm. is_hvm ( ) : <TAB> <TAB> <TAB> buses. append ( [ "ide", "IDE" ] ) <TAB> <TAB> <TAB> if self. vm. rhel6_defaults ( ) : <TAB> <TAB> <TAB> <TAB> buses. append ( [ "scsi", "SCSI" ] ) <TAB> <TAB> <TAB> <TAB> buses. append ( [ "usb", "USB" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> buses. append ( [ "sata", "SATA" ] ) <TAB> <TAB> <TAB> buses. append ( [ "virtio", "Virtio" ] ) <TAB> <TAB> if self. vm. conn. is_xen ( ) or self. vm. get_hv_type ( ) == "test" : <TAB> <TAB> <TAB> buses. append ( [ "xen", "Xen" ] ) <TAB> for row in buses : <TAB> <TAB> busmodel. append ( row ) <TAB> if not no_default : <TAB> <TAB> busmodel. append ( [ None, "default" ] ) | False | self.vm.get_hv_type() in ['kvm', 'test'] | self.vm.conn.is_sata() | 0.6479510068893433 |
243 | 241 | def _find_w9xpopen ( self ) : <TAB> """Find and return absolute path to w9xpopen.exe""" <TAB> <TAB> w9xpopen = os. path. join ( os. path. dirname ( GetModuleFileName ( 0 ) ), "w9xpopen.exe" ) <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> w9xpopen = os. path. join ( os. path. dirname ( sys. exec_prefix ), "w9xpopen.exe" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> "Cannot locate w9xpopen.exe, which is " <TAB> <TAB> <TAB> <TAB> "needed for Popen to work with your " <TAB> <TAB> <TAB> <TAB> "shell or platform." <TAB> <TAB> <TAB> ) <TAB> return w9xpopen | True | not os.path.exists(w9xpopen) | not os.path.exists(w9xpopen) | 0.6520127058029175 |
244 | 242 | def get_first_param_index ( self, group_id, param_group, partition_id ) : <TAB> for index, param in enumerate ( param_group ) : <TAB> <TAB> param_id = self. get_param_id ( param ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return index <TAB> return None | False | partition_id in self.param_to_partition_ids[group_id][param_id] | param_id == group_id and param_id == partition_id | 0.6472944617271423 |
245 | 243 | def parse_bash_set_output ( output ) : <TAB> """Parse Bash-like'set' output""" <TAB> if not sys. platform. startswith ( "win" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> output = output. replace ( "\\\n", "" ) <TAB> environ = { } <TAB> for line in output. splitlines ( 0 ) : <TAB> <TAB> line = line. rstrip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> item = _ParseBashEnvStr ( line ) <TAB> <TAB> if item : <TAB> <TAB> <TAB> environ [ item [ 0 ] ] = item [ 1 ] <TAB> return environ | True | not line | not line | 0.677064836025238 |
246 | 244 | def _convert_to_seconds ( value ) : <TAB> """Converts TTL strings into seconds""" <TAB> try : <TAB> <TAB> return int ( value ) <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> seconds = 0 <TAB> <TAB> ttl_string = value. lower ( ) <TAB> <TAB> for component in [ "w", "d", "h", "m", "s" ] : <TAB> <TAB> <TAB> regex = date_regex_dict [ component ] [ "regex" ] <TAB> <TAB> <TAB> match = regex. search ( ttl_string ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> match_string = match. group ( 0 ) <TAB> <TAB> <TAB> <TAB> ttl_string = ttl_string. replace ( match_string, "" ) <TAB> <TAB> <TAB> <TAB> match_value = int ( match_string. strip ( component ) ) <TAB> <TAB> <TAB> <TAB> seconds += match_value * date_regex_dict [ component ] [ "scale" ] <TAB> <TAB> <TAB> if not ttl_string : <TAB> <TAB> <TAB> <TAB> return seconds <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> seconds += int ( ttl_string ) <TAB> <TAB> <TAB> return seconds <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> raise InvalidArgumentValueError ( <TAB> <TAB> <TAB> <TAB> "Unable to convert value '{}' to seconds.". format ( value ) <TAB> <TAB> <TAB> ) | True | match | match | 0.6835880279541016 |
247 | 245 | def test_sin_values ( ) : <TAB> firstval = None <TAB> for i, v in zip ( range ( 1000 ), sin_values ( ) ) : <TAB> <TAB> assert - 1 <= v <= 1 <TAB> <TAB> assert isclose ( v, sin ( radians ( i ) ), abs_tol = 1e-9 ) <TAB> <TAB> if i == 0 : <TAB> <TAB> <TAB> firstval = v <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> assert v == firstval <TAB> for period in ( 360, 100 ) : <TAB> <TAB> firstval = None <TAB> <TAB> for i, v in zip ( range ( 1000 ), sin_values ( period ) ) : <TAB> <TAB> <TAB> assert - 1 <= v <= 1 <TAB> <TAB> <TAB> if i == 0 : <TAB> <TAB> <TAB> <TAB> firstval = v <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if i % period == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> assert v == firstval | False | i % 360 == 0 | i % period == 1 | 0.6792773008346558 |
248 | 246 | def wait_complete ( self ) : <TAB> """Wait for futures complete done.""" <TAB> for future in concurrent. futures. as_completed ( self. _futures. keys ( ) ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> error = future. exception ( ) <TAB> <TAB> except concurrent. futures. CancelledError : <TAB> <TAB> <TAB> break <TAB> <TAB> name = self. _futures [ future ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> err_msg = 'Extracting "{0}", got: {1}'. format ( name, error ) <TAB> <TAB> <TAB> logger. error ( err_msg ) | True | error is not None | error is not None | 0.6587857007980347 |
249 | 247 | def _wrapper ( self, * args, ** kwargs ) : <TAB> if self. rebuild is False : <TAB> <TAB> self. rebuild = True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> <TAB> "[Warning] Vocabulary has reached the max size {} when calling {} method. " <TAB> <TAB> <TAB> <TAB> "Adding more words may cause unexpected behaviour of Vocabulary. ". format ( <TAB> <TAB> <TAB> <TAB> <TAB> self. max_size, func. __name__ <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> return func ( self, * args, ** kwargs ) | False | self.max_size is not None and len(self.word_count) >= self.max_size | self.max_size is not None | 0.6538647413253784 |
250 | 248 | def formatted_addon ( self, obj ) : <TAB> if obj. version : <TAB> <TAB> return format_html ( <TAB> <TAB> <TAB> '<a href="{}">{}</a>' <TAB> <TAB> <TAB> "<br>" <TAB> <TAB> <TAB> "<table>" <TAB> <TAB> <TAB> " <tr><td>Version:</td><td>{}</td></tr>" <TAB> <TAB> <TAB> " <tr><td>Channel:</td><td>{}</td></tr>" <TAB> <TAB> <TAB> "</table>", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> urljoin ( <TAB> <TAB> <TAB> <TAB> settings. EXTERNAL_SITE_URL, <TAB> <TAB> <TAB> <TAB> reverse ( <TAB> <TAB> <TAB> <TAB> <TAB> "reviewers.review", <TAB> <TAB> <TAB> <TAB> <TAB> args = [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> "listed" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else "unlisted" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> obj. version. addon. id, <TAB> <TAB> <TAB> <TAB> <TAB> ], <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> obj. version. addon. name, <TAB> <TAB> <TAB> obj. version. version, <TAB> <TAB> <TAB> obj. version. get_channel_display ( ), <TAB> <TAB> ) <TAB> return "-" | False | obj.version.channel == amo.RELEASE_CHANNEL_LISTED | self.has_tab | 0.6566486358642578 |
251 | 249 | def home ( request ) : <TAB> from django. conf import settings <TAB> print ( settings. SOME_VALUE ) <TAB> subject = None <TAB> message = None <TAB> size = 0 <TAB> print ( request. META ) <TAB> if request. POST : <TAB> <TAB> form = MsgForm ( request. POST, request. FILES ) <TAB> <TAB> print ( request. FILES ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> subject = form. cleaned_data [ "subject" ] <TAB> <TAB> <TAB> message = form. cleaned_data [ "message" ] <TAB> <TAB> <TAB> f = request. FILES [ "f" ] <TAB> <TAB> <TAB> if not hasattr ( f, "fileno" ) : <TAB> <TAB> <TAB> <TAB> size = len ( f. read ( ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> size = int ( os. fstat ( f. fileno ( ) ) [ 6 ] ) <TAB> <TAB> <TAB> <TAB> except io. UnsupportedOperation : <TAB> <TAB> <TAB> <TAB> <TAB> size = len ( f. read ( ) ) <TAB> else : <TAB> <TAB> form = MsgForm ( ) <TAB> return render ( <TAB> <TAB> request, <TAB> <TAB> "home.html", <TAB> <TAB> { "form" : form, "subject" : subject, "message" : message, "size" : size }, <TAB> ) | True | form.is_valid() | form.is_valid() | 0.6509881019592285 |
252 | 250 | def backup_txs ( self, txs, is_unspendable ) : <TAB> undo_info = self. db. read_undo_info ( self. height ) <TAB> if undo_info is None : <TAB> <TAB> raise ChainError ( <TAB> <TAB> <TAB> "no undo information found for height {:,d}". format ( self. height ) <TAB> <TAB> ) <TAB> <TAB> put_utxo = self. utxo_cache. __setitem__ <TAB> spend_utxo = self. spend_utxo <TAB> add_touched = self. touched. add <TAB> undo_entry_len = 13 + HASHX_LEN <TAB> <TAB> <TAB> n = 0 <TAB> for tx, tx_hash in txs : <TAB> <TAB> for txin in tx. inputs : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> undo_item = undo_info [ n : n + undo_entry_len ] <TAB> <TAB> <TAB> put_utxo ( txin. prev_hash + pack_le_uint32 ( txin. prev_idx ), undo_item ) <TAB> <TAB> <TAB> add_touched ( undo_item [ : - 13 ] ) <TAB> <TAB> <TAB> n += undo_entry_len <TAB> assert n == len ( undo_info ) <TAB> <TAB> for tx, tx_hash in txs : <TAB> <TAB> for idx, txout in enumerate ( tx. outputs ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if is_unspendable ( txout. pk_script ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> cache_value = spend_utxo ( tx_hash, idx ) <TAB> <TAB> <TAB> add_touched ( cache_value [ : - 13 ] ) <TAB> self. tx_count -= len ( txs ) | False | txin.is_generation() | n >= len(undo_info) | 0.6525170207023621 |
253 | 251 | def __setitem__ ( self, key, value ) : <TAB> key = self. __fixkey__ ( key ) <TAB> checker = self. get_rule ( key ) [ self. RULE_CHECKER ] <TAB> if not checker is True : <TAB> <TAB> if checker is False : <TAB> <TAB> <TAB> if isinstance ( value, dict ) and isinstance ( self [ key ], dict ) : <TAB> <TAB> <TAB> <TAB> for k, v in value. iteritems ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> self [ key ] [ k ] = v <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> raise ConfigValueError ( <TAB> <TAB> <TAB> <TAB> _ ( "Modifying %s/%s is not " "allowed" ) % ( self. _name, key ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif isinstance ( checker, ( list, set, tuple ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise ConfigValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> _ ( "Invalid value for %s/%s: %s" ) % ( self. _name, key, value ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> elif isinstance ( checker, ( type, type ( RuledContainer ) ) ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if value is None : <TAB> <TAB> <TAB> <TAB> <TAB> value = checker ( ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> value = checker ( value ) <TAB> <TAB> <TAB> except ( ConfigValueError ) : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> except ( validators. IgnoreValue ) : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> except ( ValueError, TypeError ) : <TAB> <TAB> <TAB> <TAB> raise | False | value not in checker | value is not None and checker(value) | 0.668428361415863 |
254 | 252 | def _merge_dict ( stack, obj ) : <TAB> strategy = obj. pop ( "__", "merge-last" ) <TAB> if strategy not in strategies : <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> 'Unknown strategy "{0}", should be one of {1}'. format ( strategy, strategies ) <TAB> <TAB> ) <TAB> if strategy == "overwrite" : <TAB> <TAB> return _cleanup ( obj ) <TAB> else : <TAB> <TAB> for k, v in six. iteritems ( obj ) : <TAB> <TAB> <TAB> if strategy == "remove" : <TAB> <TAB> <TAB> <TAB> stack. pop ( k, None ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if k in stack : <TAB> <TAB> <TAB> <TAB> if strategy == "merge-first" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> stack_k = stack [ k ] <TAB> <TAB> <TAB> <TAB> <TAB> stack [ k ] = _cleanup ( v ) <TAB> <TAB> <TAB> <TAB> <TAB> v = stack_k <TAB> <TAB> <TAB> <TAB> if type ( stack [ k ] )!= type ( v ) : <TAB> <TAB> <TAB> <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> "Force overwrite, types differ: '%s'!= '%s'", stack [ k ], v <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> stack [ k ] = _cleanup ( v ) <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> stack [ k ] = _merge_dict ( stack [ k ], v ) <TAB> <TAB> <TAB> <TAB> elif isinstance ( v, list ) : <TAB> <TAB> < | False | isinstance(v, dict) | isinstance(stack[k], dict) | 0.6511378288269043 |
255 | 253 | def icyparser ( self, url : str ) -> Optional [ str ] : <TAB> try : <TAB> <TAB> async with self. session. get ( url, headers = { "Icy-MetaData" : "1" } ) as resp : <TAB> <TAB> <TAB> metaint = int ( resp. headers [ "icy-metaint" ] ) <TAB> <TAB> <TAB> for _ in range ( 5 ) : <TAB> <TAB> <TAB> <TAB> await resp. content. readexactly ( metaint ) <TAB> <TAB> <TAB> <TAB> metadata_length = ( <TAB> <TAB> <TAB> <TAB> <TAB> struct. unpack ( "B", await resp. content. readexactly ( 1 ) ) [ 0 ] * 16 <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> metadata = await resp. content. readexactly ( metadata_length ) <TAB> <TAB> <TAB> <TAB> m = re. search ( STREAM_TITLE, metadata. rstrip ( b"\0" ) ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> title = m. group ( 1 ) <TAB> <TAB> <TAB> <TAB> <TAB> if title : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> title = title. decode ( "utf-8", errors = "replace" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return title <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> return None <TAB> except ( KeyError, aiohttp. ClientConnectionError, aiohttp. ClientResponseError ) : <TAB> <TAB> return None | True | m | m | 0.6963084936141968 |
256 | 254 | def readTables ( self ) : <TAB> """Read tables section""" <TAB> while True : <TAB> <TAB> table = self. readTable ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> if table [ "type" ] == "LAYER" : <TAB> <TAB> <TAB> name = table. get ( "name" ) <TAB> <TAB> <TAB> if name is not None : <TAB> <TAB> <TAB> <TAB> self. layers [ name ] = Layer ( name, table ) | True | table is None | table is None | 0.6637412309646606 |
257 | 255 | def Handle ( self, args, context = None ) : <TAB> result = ApiListClientActionRequestsResult ( ) <TAB> request_cache = { } <TAB> for r in data_store. REL_DB. ReadAllClientActionRequests ( str ( args. client_id ) ) : <TAB> <TAB> stub = action_registry. ACTION_STUB_BY_ID [ r. action_identifier ] <TAB> <TAB> client_action = compatibility. GetName ( stub ) <TAB> <TAB> request = ApiClientActionRequest ( <TAB> <TAB> <TAB> leased_until = r. leased_until, <TAB> <TAB> <TAB> session_id = "%s/%s" % ( r. client_id, r. flow_id ), <TAB> <TAB> <TAB> client_action = client_action, <TAB> <TAB> ) <TAB> <TAB> result. items. append ( request ) <TAB> <TAB> if not args. fetch_responses : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> req_res = data_store. REL_DB. ReadAllFlowRequestsAndResponses ( <TAB> <TAB> <TAB> <TAB> str ( args. client_id ), r. flow_id <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> request_cache [ r. flow_id ] = req_res <TAB> <TAB> for req, responses in request_cache [ r. flow_id ] : <TAB> <TAB> <TAB> if req. request_id == r. request_id : <TAB> <TAB> <TAB> <TAB> res = [ ] <TAB> <TAB> <TAB> <TAB> for resp_id in sorted ( responses ) : <TAB> <TAB> <TAB> <TAB> <TAB> m = responses [ resp_id ]. AsLegacyGrrMessage ( ) <TAB> <TAB> <TAB> <TAB> <TAB> res. append ( m ) <TAB> <TAB> <TAB> <TAB> request. responses = res <TAB> return result | False | r.flow_id not in request_cache | args.client_id | 0.6535675525665283 |
258 | 256 | def _should_mark_node_dnr ( self, node, parent_nodes ) : <TAB> for p in parent_nodes : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pass <TAB> <TAB> elif p. job : <TAB> <TAB> <TAB> if p. job. status == "successful" : <TAB> <TAB> <TAB> <TAB> if node in ( <TAB> <TAB> <TAB> <TAB> <TAB> self. get_children ( p, "success_nodes" ) <TAB> <TAB> <TAB> <TAB> <TAB> + self. get_children ( p, "always_nodes" ) <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> elif p. job. status in [ "failed", "error", "canceled" ] : <TAB> <TAB> <TAB> <TAB> if node in ( <TAB> <TAB> <TAB> <TAB> <TAB> self. get_children ( p, "failure_nodes" ) <TAB> <TAB> <TAB> <TAB> <TAB> + self. get_children ( p, "always_nodes" ) <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> elif not p. do_not_run and p. unified_job_template is None : <TAB> <TAB> <TAB> if node in ( <TAB> <TAB> <TAB> <TAB> self. get_children ( p, "failure_nodes" ) <TAB> <TAB> <TAB> <TAB> + self. get_children ( p, "always_nodes" ) <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> else : <TAB> <TAB> <TAB> return False <TAB> return True | False | p.do_not_run is True | p.node_dnr == node | 0.6510770320892334 |
259 | 257 | def update_metadata ( self ) : <TAB> for attrname in dir ( self ) : <TAB> <TAB> if attrname. startswith ( "__" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> attrvalue = getattr ( self, attrname, None ) <TAB> <TAB> if attrvalue == 0 : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> attrname = "version" <TAB> <TAB> if hasattr ( self. metadata, "set_{0}". format ( attrname ) ) : <TAB> <TAB> <TAB> getattr ( self. metadata, "set_{0}". format ( attrname ) ) ( attrvalue ) <TAB> <TAB> elif hasattr ( self. metadata, attrname ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> setattr ( self. metadata, attrname, attrvalue ) <TAB> <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> pass | False | attrname == 'salt_version' | attrname == 'version' | 0.6533090472221375 |
260 | 258 | def _end_completion ( self, args ) : <TAB> value = args [ "completion_text" ] <TAB> paths = args [ "paths" ] <TAB> if args [ "forward_completion" ] : <TAB> <TAB> common_prefix = os. path. commonprefix ( paths ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. path_entry. set_text ( <TAB> <TAB> <TAB> <TAB> common_prefix, set_file_chooser_folder = True, trigger_event = True <TAB> <TAB> <TAB> ) <TAB> self. path_entry. text_entry. set_position ( len ( self. path_entry. get_text ( ) ) ) <TAB> self. completion_popup. set_values ( paths, preserve_selection = True ) <TAB> if self. use_popup and len ( paths ) > 1 : <TAB> <TAB> self. completion_popup. popup ( ) <TAB> elif self. completion_popup. is_popped_up ( ) and args [ "forward_completion" ] : <TAB> <TAB> self. completion_popup. popdown ( ) | False | len(common_prefix) > len(value) | not self.path_entry.is_empty() and common_prefix | 0.6451213359832764 |
261 | 259 | def R_op ( self, inputs, eval_points ) : <TAB> outs = self ( * inputs, ** dict ( return_list = True ) ) <TAB> rval = [ None for x in outs ] <TAB> <TAB> for idx, out in enumerate ( outs ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ograds = [ x. zeros_like ( ) for x in outs ] <TAB> <TAB> ograds [ idx ] = theano. tensor. ones_like ( out ) <TAB> <TAB> bgrads = self. _bgrad ( inputs, outs, ograds ) <TAB> <TAB> rop_out = None <TAB> <TAB> for jdx, ( inp, eval_point ) in enumerate ( izip ( inputs, eval_points ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if bgrads [ jdx ] is None or isinstance ( bgrads [ jdx ]. type, DisconnectedType ) : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> if rop_out is None : <TAB> <TAB> <TAB> <TAB> <TAB> rop_out = bgrads [ jdx ] * eval_point <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> rop_out = rop_out + bgrads [ jdx ] * eval_point <TAB> <TAB> rval [ idx ] = rop_out <TAB> return rval | False | eval_point is not None | len(bgrads) > 0 | 0.6541682481765747 |
262 | 260 | def assert_warns ( expected ) : <TAB> with warnings. catch_warnings ( record = True ) as w : <TAB> <TAB> warnings. simplefilter ( "always" ) <TAB> <TAB> yield <TAB> <TAB> <TAB> if sys. version_info >= ( 3, 0 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> exc_name = expected. __name__ <TAB> <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> exc_name = str ( expected ) <TAB> <TAB> <TAB> raise AssertionError ( "%s not triggerred" % exc_name ) | False | not any((isinstance(m.message, expected) for m in w)) | hasattr(expected, '__name__') | 0.661018967628479 |
263 | 261 | def init_params ( net ) : <TAB> """Init layer parameters.""" <TAB> for module in net. modules ( ) : <TAB> <TAB> if isinstance ( module, nn. Conv2d ) : <TAB> <TAB> <TAB> init. kaiming_normal ( module. weight, mode = "fan_out" ) <TAB> <TAB> <TAB> if module. bias : <TAB> <TAB> <TAB> <TAB> init. constant ( module. bias, 0 ) <TAB> <TAB> elif isinstance ( module, nn. BatchNorm2d ) : <TAB> <TAB> <TAB> init. constant ( module. weight, 1 ) <TAB> <TAB> <TAB> init. constant ( module. bias, 0 ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> init. normal ( module. weight, std = 1e-3 ) <TAB> <TAB> <TAB> if module. bias : <TAB> <TAB> <TAB> <TAB> init. constant ( module. bias, 0 ) | True | isinstance(module, nn.Linear) | isinstance(module, nn.Linear) | 0.6549795866012573 |
264 | 262 | def _mock_send_packet ( eio_sid, pkt ) : <TAB> <TAB> epkt = pkt. encode ( ) <TAB> if not isinstance ( epkt, list ) : <TAB> <TAB> pkt = packet. Packet ( encoded_packet = epkt ) <TAB> else : <TAB> <TAB> pkt = packet. Packet ( encoded_packet = epkt [ 0 ] ) <TAB> <TAB> for att in epkt [ 1 : ] : <TAB> <TAB> <TAB> pkt. add_attachment ( att ) <TAB> if pkt. packet_type == packet. EVENT or pkt. packet_type == packet. BINARY_EVENT : <TAB> <TAB> if eio_sid not in self. queue : <TAB> <TAB> <TAB> self. queue [ eio_sid ] = [ ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. queue [ eio_sid ]. append ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> "name" : pkt. data [ 0 ], <TAB> <TAB> <TAB> <TAB> <TAB> "args" : pkt. data [ 1 ], <TAB> <TAB> <TAB> <TAB> <TAB> "namespace" : pkt. namespace or "/", <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. queue [ eio_sid ]. append ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> "name" : pkt. data [ 0 ], <TAB> <TAB> <TAB> <TAB> <TAB> "args" : pkt. data [ 1 : ], <TAB> <TAB> <TAB> <TAB> <TAB> "namespace" : pkt. namespace or "/", <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> ) <TAB> elif pkt. packet_type == packet. ACK or pkt. packet_type == packet. BINARY_ACK : <TAB> <TAB> self | False | pkt.data[0] == 'message' or pkt.data[0] == 'json' | len(self.queue) > 0 | 0.6525523066520691 |
265 | 263 | def mergeCombiners ( self, x, y ) : <TAB> for item in y : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. heap. push ( x, item ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. heap. push_pop ( x, item ) <TAB> return x | False | len(x) < self.heap_limit | isinstance(item, list) | 0.6545305252075195 |
266 | 264 | def test_write_buffer ( self ) : <TAB> try : <TAB> <TAB> for mode in ( "b", "" ) : <TAB> <TAB> <TAB> with open ( "foo", "w+" + mode ) as foo : <TAB> <TAB> <TAB> <TAB> b = buffer ( b"hello world", 6 ) <TAB> <TAB> <TAB> <TAB> foo. write ( b ) <TAB> <TAB> <TAB> with open ( "foo", "r" ) as foo : <TAB> <TAB> <TAB> <TAB> self. assertEqual ( foo. readlines ( ), [ "world" ] ) <TAB> <TAB> with open ( "foo", "w+" ) as foo : <TAB> <TAB> <TAB> b = buffer ( u"hello world", 6 ) <TAB> <TAB> <TAB> foo. write ( b ) <TAB> <TAB> with open ( "foo", "r" ) as foo : <TAB> <TAB> <TAB> self. assertEqual ( foo. readlines ( ), [ "world" ] ) <TAB> <TAB> with open ( "foo", "w+b" ) as foo : <TAB> <TAB> <TAB> b = buffer ( u"hello world", 6 ) <TAB> <TAB> <TAB> foo. write ( b ) <TAB> <TAB> with open ( "foo", "r" ) as foo : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> <TAB> <TAB> foo. readlines ( ), [ "l\x00o\x00 \x00w\x00o\x00r\x00l\x00d\x00" ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. assertEqual ( foo. readlines ( ), [ "world" ] ) <TAB> finally : <TAB> <TAB> self. delete_files ( "foo" ) | False | is_cpython | hasattr(foo, '__iter__') | 0.6585351228713989 |
267 | 265 | def read_callback ( ) : <TAB> """Parse stats response from Marathon""" <TAB> log_verbose ( "Read callback called" ) <TAB> try : <TAB> <TAB> metrics = json. load ( urllib2. urlopen ( MARATHON_URL, timeout = 10 ) ) <TAB> <TAB> for group in [ "gauges", "histograms", "meters", "timers", "counters" ] : <TAB> <TAB> <TAB> for name, values in metrics. get ( group, { } ). items ( ) : <TAB> <TAB> <TAB> <TAB> for metric, value in values. items ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dispatch_stat ( "gauge", ".". join ( ( name, metric ) ), value ) <TAB> except urllib2. URLError as e : <TAB> <TAB> collectd. error ( <TAB> <TAB> <TAB> "marathon plugin: Error connecting to %s - %r" % ( MARATHON_URL, e ) <TAB> <TAB> ) | False | not isinstance(value, basestring) | metric | 0.6501896381378174 |
268 | 266 | def ReceiveMessageLoop ( self ) : <TAB> while self. connected == True : <TAB> <TAB> tmp = await self. ReadSocketData ( 16 ) <TAB> <TAB> if tmp is None : <TAB> <TAB> <TAB> break <TAB> <TAB> ( expr, ) = struct. unpack ( "!I", tmp [ : 4 ] ) <TAB> <TAB> ( num, ) = struct. unpack ( "!I", tmp [ 8 : 12 ] ) <TAB> <TAB> num2 = expr - 16 <TAB> <TAB> tmp = await self. ReadSocketData ( num2 ) <TAB> <TAB> if tmp is None : <TAB> <TAB> <TAB> break <TAB> <TAB> if num2!= 0 : <TAB> <TAB> <TAB> num -= 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> ( num3, ) = struct. unpack ( "!I", tmp ) <TAB> <TAB> <TAB> <TAB> self. _UserCount = num3 <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> elif num == 3 or num == 4 : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> messages = tmp. decode ( "utf-8" ) <TAB> <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> await self. parseDanMu ( messages ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> elif num == 5 or num == 6 or num == 7 : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if num!= 16 : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> continue | False | num == 0 or num == 1 or num == 2 | num3 != 0 | 0.6565470695495605 |
269 | 267 | def _rmtree ( self, path ) : <TAB> <TAB> <TAB> for name in self. _listdir ( path ) : <TAB> <TAB> fullname = self. _path_join ( path, name ) <TAB> <TAB> try : <TAB> <TAB> <TAB> isdir = self. _isdir ( fullname ) <TAB> <TAB> except self. _os_error : <TAB> <TAB> <TAB> isdir = False <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _rmtree ( fullname ) <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> self. _remove ( fullname ) <TAB> <TAB> <TAB> except self. _os_error : <TAB> <TAB> <TAB> <TAB> pass <TAB> try : <TAB> <TAB> self. _rmdir ( path ) <TAB> except self. _os_error : <TAB> <TAB> pass | True | isdir | isdir | 0.6735173463821411 |
270 | 268 | def write ( self, * bits ) : <TAB> for bit in bits : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. bytestream. append ( 0 ) <TAB> <TAB> byte = self. bytestream [ self. bytenum ] <TAB> <TAB> if self. bitnum == 8 : <TAB> <TAB> <TAB> if self. bytenum == len ( self. bytestream ) - 1 : <TAB> <TAB> <TAB> <TAB> byte = 0 <TAB> <TAB> <TAB> <TAB> self. bytestream += bytes ( [ byte ] ) <TAB> <TAB> <TAB> self. bytenum += 1 <TAB> <TAB> <TAB> self. bitnum = 0 <TAB> <TAB> mask = 2 ** self. bitnum <TAB> <TAB> if bit : <TAB> <TAB> <TAB> byte |= mask <TAB> <TAB> else : <TAB> <TAB> <TAB> byte &= ~ mask <TAB> <TAB> self. bytestream [ self. bytenum ] = byte <TAB> <TAB> self. bitnum += 1 | False | not self.bytestream | bit | 0.6641024351119995 |
271 | 269 | def _write_ready ( self ) : <TAB> assert self. _buffer, "Data should not be empty" <TAB> try : <TAB> <TAB> n = self. _sock. send ( self. _buffer ) <TAB> except ( BlockingIOError, InterruptedError ) : <TAB> <TAB> pass <TAB> except Exception as exc : <TAB> <TAB> self. _loop. remove_writer ( self. _sock_fd ) <TAB> <TAB> self. _buffer. clear ( ) <TAB> <TAB> self. _fatal_error ( exc, "Fatal write error on socket transport" ) <TAB> else : <TAB> <TAB> if n : <TAB> <TAB> <TAB> del self. _buffer [ : n ] <TAB> <TAB> self. _maybe_resume_protocol ( ) <TAB> <TAB> if not self. _buffer : <TAB> <TAB> <TAB> self. _loop. remove_writer ( self. _sock_fd ) <TAB> <TAB> <TAB> if self. _closing : <TAB> <TAB> <TAB> <TAB> self. _call_connection_lost ( None ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> self. _sock. shutdown ( socket. SHUT_WR ) | False | self._eof | shutdown | 0.6725741624832153 |
272 | 270 | def jupyter_progress_bar ( min = 0, max = 1.0 ) : <TAB> """Returns an ipywidget progress bar or None if we can't import it""" <TAB> widgets = wandb. util. get_module ( "ipywidgets" ) <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> from IPython. html import widgets <TAB> <TAB> assert hasattr ( widgets, "VBox" ) <TAB> <TAB> assert hasattr ( widgets, "Label" ) <TAB> <TAB> assert hasattr ( widgets, "FloatProgress" ) <TAB> <TAB> return ProgressWidget ( widgets, min = min, max = max ) <TAB> except ( ImportError, AssertionError ) : <TAB> <TAB> return None | False | widgets is None | hasattr(widgets, 'getItem') | 0.6759294867515564 |
273 | 271 | def call ( self, step_input, states ) : <TAB> new_states = [ ] <TAB> for i in range ( self. num_layers ) : <TAB> <TAB> out, new_state = self. lstm_cells [ i ] ( step_input, states [ i ] ) <TAB> <TAB> step_input = ( <TAB> <TAB> <TAB> layers. dropout ( <TAB> <TAB> <TAB> <TAB> out, self. dropout_prob, dropout_implementation = "upscale_in_train" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else out <TAB> <TAB> ) <TAB> <TAB> new_states. append ( new_state ) <TAB> return step_input, new_states | False | self.dropout_prob > 0.0 | new_state is None | 0.6524040102958679 |
274 | 272 | def _get_stream ( self, mem, base, sat, sec_size, start_sid, size = None, name = "" ) : <TAB> <TAB> sectors = [ ] <TAB> s = start_sid <TAB> if size is None : <TAB> <TAB> <TAB> <TAB> while s >= 0 : <TAB> <TAB> <TAB> start_pos = base + s * sec_size <TAB> <TAB> <TAB> sectors. append ( mem [ start_pos : start_pos + sec_size ] ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> s = sat [ s ] <TAB> <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> raise CompDocError ( <TAB> <TAB> <TAB> <TAB> <TAB> "OLE2 stream %r: sector allocation table invalid entry (%d)" <TAB> <TAB> <TAB> <TAB> <TAB> % ( name, s ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> assert s == EOCSID <TAB> else : <TAB> <TAB> todo = size <TAB> <TAB> while s >= 0 : <TAB> <TAB> <TAB> start_pos = base + s * sec_size <TAB> <TAB> <TAB> grab = sec_size <TAB> <TAB> <TAB> if grab > todo : <TAB> <TAB> <TAB> <TAB> grab = todo <TAB> <TAB> <TAB> todo -= grab <TAB> <TAB> <TAB> sectors. append ( mem [ start_pos : start_pos + grab ] ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> s = sat [ s ] <TAB> <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> raise CompDocError ( <TAB> <TAB> <TAB> <TAB> <TAB> "OLE2 stream %r: sector allocation table invalid entry (%d)" <TAB> <TAB> <TAB> <TAB> <TAB> % ( name, s ) <TAB> <TAB> <TAB> <TAB> ) | False | todo != 0 | s == None | 0.6870219707489014 |
275 | 273 | def __call__ ( self, trainer ) : <TAB> <TAB> keys = self. _keys <TAB> observation = trainer. observation <TAB> summary = self. _summary <TAB> if keys is None : <TAB> <TAB> summary. add ( observation ) <TAB> else : <TAB> <TAB> summary. add ( { k : observation [ k ] for k in keys if k in observation } ) <TAB> if trainer. is_before_training or self. _trigger ( trainer ) : <TAB> <TAB> <TAB> <TAB> stats = self. _summary. compute_mean ( ) <TAB> <TAB> stats_cpu = { } <TAB> <TAB> for name, value in six. iteritems ( stats ) : <TAB> <TAB> <TAB> stats_cpu [ name ] = float ( value ) <TAB> <TAB> updater = trainer. updater <TAB> <TAB> stats_cpu [ "epoch" ] = updater. epoch <TAB> <TAB> stats_cpu [ "iteration" ] = updater. iteration <TAB> <TAB> stats_cpu [ "elapsed_time" ] = trainer. elapsed_time <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _postprocess ( stats_cpu ) <TAB> <TAB> self. _log. append ( stats_cpu ) <TAB> <TAB> <TAB> <TAB> if self. _log_name is not None : <TAB> <TAB> <TAB> log_name = self. _log_name. format ( ** stats_cpu ) <TAB> <TAB> <TAB> with utils. tempdir ( prefix = log_name, dir = trainer. out ) as tempd : <TAB> <TAB> <TAB> <TAB> path = os. path. join ( tempd, "log.json" ) <TAB> <TAB> <TAB> <TAB> with open ( path, "w" ) as f : <TAB> <TAB> <TAB> <TAB> <TAB> json. dump ( self. _log, f, indent = 4 ) <TAB> <TAB> <TAB> <TAB> new_path = os. path. join ( trainer. out, log_name ) <TAB> <TAB> <TAB> <TAB> shutil. move ( path, | False | self._postprocess is not None | self._log_cpu is not None | 0.6575281620025635 |
276 | 274 | def _from_to_normal ( self, pymodule, import_stmt ) : <TAB> resource = pymodule. get_resource ( ) <TAB> from_import = import_stmt. import_info <TAB> module_name = from_import. module_name <TAB> for name, alias in from_import. names_and_aliases : <TAB> <TAB> imported = name <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> imported = alias <TAB> <TAB> occurrence_finder = occurrences. create_finder ( <TAB> <TAB> <TAB> self. pycore, imported, pymodule [ imported ], imports = False <TAB> <TAB> ) <TAB> <TAB> source = rename. rename_in_module ( <TAB> <TAB> <TAB> occurrence_finder, <TAB> <TAB> <TAB> module_name + "." + name, <TAB> <TAB> <TAB> pymodule = pymodule, <TAB> <TAB> <TAB> replace_primary = True, <TAB> <TAB> ) <TAB> <TAB> if source is not None : <TAB> <TAB> <TAB> pymodule = self. pycore. get_string_module ( source, resource ) <TAB> return pymodule | True | alias is not None | alias is not None | 0.6716960668563843 |
277 | 275 | def test_with_three_points ( self ) : <TAB> cba = ia. Polygon ( [ ( 1, 2 ), ( 3, 4 ), ( 5, 5 ) ] ) <TAB> for i, xy in enumerate ( cba ) : <TAB> <TAB> assert i in [ 0, 1, 2 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert np. allclose ( xy, ( 1, 2 ) ) <TAB> <TAB> elif i == 1 : <TAB> <TAB> <TAB> assert np. allclose ( xy, ( 3, 4 ) ) <TAB> <TAB> elif i == 2 : <TAB> <TAB> <TAB> assert np. allclose ( xy, ( 5, 5 ) ) <TAB> assert i == 2 | True | i == 0 | i == 0 | 0.6719369888305664 |
278 | 276 | def resize ( self, newshape ) : <TAB> ( datashape, ) = self. _data. shape <TAB> if newshape > datashape : <TAB> <TAB> ( shape, ) = self. shape <TAB> <TAB> newdatashape = max ( newshape, int ( shape * self. factor ) + 1 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. data = None <TAB> <TAB> <TAB> self. _data. resize ( newdatashape, refcheck = self. refcheck ) <TAB> <TAB> else : <TAB> <TAB> <TAB> newdata = zeros ( newdatashape, dtype = self. dtype ) <TAB> <TAB> <TAB> newdata [ : shape ] = self. data <TAB> <TAB> <TAB> self. _data = newdata <TAB> elif newshape < self. shape [ 0 ] : <TAB> <TAB> <TAB> <TAB> self. _data [ newshape : ] = 0 <TAB> <TAB> self. data = self. _data [ : newshape ] <TAB> self. shape = ( newshape, ) | False | self.use_numpy_resize and self._data.flags['C_CONTIGUOUS'] | newdatashape > 0 | 0.6508387327194214 |
279 | 277 | def handle ( self, input ) : <TAB> match = self. _rx. match ( input ) <TAB> if match is not None : <TAB> <TAB> query = self. _yamlfy_query ( match. group ( "query" ) ) <TAB> <TAB> if query is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> query [ "millis" ] = match. group ( "query_time" ) <TAB> <TAB> <TAB> query [ "ns" ] = match. group ( "ns" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> query [ "orderby" ] = query [ "query" ] [ "$orderby" ] <TAB> <TAB> <TAB> <TAB> del query [ "query" ] [ "$orderby" ] <TAB> <TAB> <TAB> if query [ "query" ]. has_key ( "$query" ) : <TAB> <TAB> <TAB> <TAB> query [ "query" ] = query [ "query" ] [ "$query" ] <TAB> <TAB> <TAB> query [ "stats" ] = parse_line_stats ( match. group ( "stats" ) ) <TAB> <TAB> return query <TAB> return None | False | query['query'].has_key('$orderby') | len(query) > 0 | 0.6572615504264832 |
280 | 278 | def setUp ( self ) : <TAB> CFTPClientTestBase. setUp ( self ) <TAB> self. startServer ( ) <TAB> cmds = ( <TAB> <TAB> "-p %i -l testuser " <TAB> <TAB> "--known-hosts kh_test " <TAB> <TAB> "--user-authentications publickey " <TAB> <TAB> "--host-key-algorithms ssh-rsa " <TAB> <TAB> "-i dsa_test " <TAB> <TAB> "-a " <TAB> <TAB> "-v " <TAB> <TAB> "127.0.0.1" <TAB> ) <TAB> port = self. server. getHost ( ). port <TAB> cmds = test_conch. _makeArgs ( ( cmds % port ). split ( ), mod = "cftp" ) <TAB> log. msg ( "running {} {}". format ( sys. executable, cmds ) ) <TAB> d = defer. Deferred ( ) <TAB> self. processProtocol = SFTPTestProcess ( d ) <TAB> d. addCallback ( lambda _ : self. processProtocol. clearBuffer ( ) ) <TAB> env = os. environ. copy ( ) <TAB> env [ "PYTHONPATH" ] = os. pathsep. join ( sys. path ) <TAB> encodedCmds = [ ] <TAB> encodedEnv = { } <TAB> for cmd in cmds : <TAB> <TAB> if isinstance ( cmd, str ) : <TAB> <TAB> <TAB> cmd = cmd. encode ( "utf-8" ) <TAB> <TAB> encodedCmds. append ( cmd ) <TAB> for var in env : <TAB> <TAB> val = env [ var ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> var = var. encode ( "utf-8" ) <TAB> <TAB> if isinstance ( val, str ) : <TAB> <TAB> <TAB> val = val. encode ( "utf-8" ) <TAB> <TAB> encodedEnv [ var ] = val <TAB> log. msg ( encodedCmds ) <TAB> log. msg ( encodedEnv ) <TAB> reactor. spawnProcess ( <TAB> <TAB> self. processProtocol, sys. executable, encodedCmd | False | isinstance(var, str) | isinstance(val, str) | 0.6510794162750244 |
281 | 279 | def __new__ ( mcs, name, bases, attrs ) : <TAB> include_profile = include_trace = include_garbage = True <TAB> bases = list ( bases ) <TAB> if name == "SaltLoggingClass" : <TAB> <TAB> for base in bases : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> include_trace = False <TAB> <TAB> <TAB> if hasattr ( base, "garbage" ) : <TAB> <TAB> <TAB> <TAB> include_garbage = False <TAB> if include_profile : <TAB> <TAB> bases. append ( LoggingProfileMixin ) <TAB> if include_trace : <TAB> <TAB> bases. append ( LoggingTraceMixin ) <TAB> if include_garbage : <TAB> <TAB> bases. append ( LoggingGarbageMixin ) <TAB> return super ( LoggingMixinMeta, mcs ). __new__ ( mcs, name, tuple ( bases ), attrs ) | True | hasattr(base, 'trace') | hasattr(base, 'trace') | 0.6494925022125244 |
282 | 280 | def alloc ( self ) : <TAB> with self. lock : <TAB> <TAB> <TAB> <TAB> for item in tuple ( self. ban ) : <TAB> <TAB> <TAB> if item [ "counter" ] == 0 : <TAB> <TAB> <TAB> <TAB> self. free ( item [ "addr" ] ) <TAB> <TAB> <TAB> <TAB> self. ban. remove ( item ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> item [ "counter" ] -= 1 <TAB> <TAB> <TAB> <TAB> base = 0 <TAB> <TAB> for cell in self. addr_map : <TAB> <TAB> <TAB> if cell : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> bit = 0 <TAB> <TAB> <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> <TAB> if ( 1 << bit ) & self. addr_map [ base ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. addr_map [ base ] ^= 1 << bit <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> bit += 1 <TAB> <TAB> <TAB> <TAB> ret = base * self. cell_size + bit <TAB> <TAB> <TAB> <TAB> if self. reverse : <TAB> <TAB> <TAB> <TAB> <TAB> ret = self. maxaddr - ret <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> ret = ret + self. minaddr <TAB> <TAB> <TAB> <TAB> if self. minaddr <= ret <= self. maxaddr : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. free ( ret, ban = self. release ) <TAB> <TAB> <TAB> <TAB> <TAB> self. allocated += 1 <TAB> <TAB> | True | self.release | self.release | 0.6604821681976318 |
283 | 281 | def _wait_for_launcher ( self ) -> None : <TAB> log. debug ( "Waiting for Lavalink server to be ready" ) <TAB> lastmessage = 0 <TAB> for i in itertools. cycle ( range ( 50 ) ) : <TAB> <TAB> line = await self. _proc. stdout. readline ( ) <TAB> <TAB> if _RE_READY_LINE. search ( line ) : <TAB> <TAB> <TAB> self. ready. set ( ) <TAB> <TAB> <TAB> break <TAB> <TAB> if _FAILED_TO_START. search ( line ) : <TAB> <TAB> <TAB> raise RuntimeError ( f"Lavalink failed to start: {line.decode().strip()}" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> lastmessage = time. time ( ) <TAB> <TAB> <TAB> log. critical ( "Internal lavalink server exited early" ) <TAB> <TAB> if i == 49 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> await asyncio. sleep ( 0.1 ) | False | self._proc.returncode is not None and lastmessage + 2 < time.time() | i == 53 | 0.6497751474380493 |
284 | 282 | def get_type ( request : HttpRequest, payload : Dict [ str, Any ] ) -> str : <TAB> if payload. get ( "push" ) : <TAB> <TAB> return "push" <TAB> elif payload. get ( "fork" ) : <TAB> <TAB> return "fork" <TAB> elif payload. get ( "comment" ) and payload. get ( "commit" ) : <TAB> <TAB> return "commit_comment" <TAB> elif payload. get ( "commit_status" ) : <TAB> <TAB> return "change_commit_status" <TAB> elif payload. get ( "issue" ) : <TAB> <TAB> if payload. get ( "changes" ) : <TAB> <TAB> <TAB> return "issue_updated" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return "issue_commented" <TAB> <TAB> return "issue_created" <TAB> elif payload. get ( "pullrequest" ) : <TAB> <TAB> pull_request_template = "pull_request_{}" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> event_key = validate_extract_webhook_http_header ( <TAB> <TAB> <TAB> request, "X_EVENT_KEY", "BitBucket" <TAB> <TAB> ) <TAB> <TAB> assert event_key is not None <TAB> <TAB> action = re. match ( "pullrequest:(?P<action>.*)$", event_key ) <TAB> <TAB> if action : <TAB> <TAB> <TAB> action_group = action. group ( "action" ) <TAB> <TAB> <TAB> if action_group in PULL_REQUEST_SUPPORTED_ACTIONS : <TAB> <TAB> <TAB> <TAB> return pull_request_template. format ( action_group ) <TAB> else : <TAB> <TAB> event_key = validate_extract_webhook_http_header ( <TAB> <TAB> <TAB> request, "X_EVENT_KEY", "BitBucket" <TAB> <TAB> ) <TAB> <TAB> if event_key == "repo:updated" : <TAB> <TAB> <TAB> return event_ | False | payload.get('comment') | payload.get( "commented" | 0.6542719602584839 |
285 | 283 | def _get_contrast ( second_level_contrast, design_matrix ) : <TAB> """Check and return contrast when testing one contrast at the time""" <TAB> if isinstance ( second_level_contrast, str ) : <TAB> <TAB> if second_level_contrast in design_matrix. columns. tolist ( ) : <TAB> <TAB> <TAB> contrast = second_level_contrast <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> '"{}" is not a valid contrast name'. format ( second_level_contrast ) <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> <TAB> <TAB> if second_level_contrast is None : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> second_level_contrast = np. ones ( [ 1 ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise ValueError ( "No second-level contrast is specified." ) <TAB> <TAB> elif ( np. nonzero ( second_level_contrast ) [ 0 ] ). size!= 1 : <TAB> <TAB> <TAB> raise ValueError ( "second_level_contrast must be " "a list of 0s and 1s" ) <TAB> <TAB> con_val = np. asarray ( second_level_contrast, dtype = bool ) <TAB> <TAB> contrast = np. asarray ( design_matrix. columns. tolist ( ) ) [ con_val ] [ 0 ] <TAB> return contrast | False | design_matrix.shape[1] == 1 | len(second_level_contrast) == 0 | 0.6579049825668335 |
286 | 284 | def _get_left_part ( self, bar ) : <TAB> import socket, os, pwd <TAB> try : <TAB> <TAB> username = pwd. getpwuid ( os. geteuid ( ) ). pw_name <TAB> except : <TAB> <TAB> username = "???" <TAB> if username == "root" : <TAB> <TAB> clr = "bad" <TAB> else : <TAB> <TAB> clr = "good" <TAB> bar. add ( username, "hostname", clr, fixedsize = True ) <TAB> bar. add ( "@", "hostname", clr, fixedsize = True ) <TAB> bar. add ( socket. gethostname ( ), "hostname", clr, fixedsize = True ) <TAB> for path in self. env. pathway : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> clr = "link" <TAB> <TAB> else : <TAB> <TAB> <TAB> clr = "directory" <TAB> <TAB> bar. add ( path. basename, clr ) <TAB> <TAB> bar. add ( "/", clr, fixedsize = True ) <TAB> if self. env. cf is not None : <TAB> <TAB> bar. add ( self. env. cf. basename, "file", fixedsize = True ) | False | path.islink | path.basename | 0.655146598815918 |
287 | 285 | def assert_registration_mailbox ( self, match = None ) : <TAB> if match is None : <TAB> <TAB> match = "[Weblate] Your registration on Weblate" <TAB> <TAB> self. assertEqual ( len ( mail. outbox ), 1 ) <TAB> self. assertEqual ( mail. outbox [ 0 ]. subject, match ) <TAB> live_url = getattr ( self, "live_server_url", None ) <TAB> <TAB> for line in mail. outbox [ 0 ]. body. splitlines ( ) : <TAB> <TAB> if "verification_code" not in line : <TAB> <TAB> <TAB> continue <TAB> <TAB> if "(" in line or ")" in line or "<" in line or ">" in line : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return line + "&confirm=1" <TAB> <TAB> if line. startswith ( "http://example.com/" ) : <TAB> <TAB> <TAB> return line [ 18 : ] + "&confirm=1" <TAB> self. fail ( "Confirmation URL not found" ) <TAB> return "" | False | live_url and line.startswith(live_url) | live_url and live_url.lower().startswith(line.startswith('https://example.com/') | 0.6480209827423096 |
288 | 286 | def __init__ ( self, document, collection ) : <TAB> self. _document = document <TAB> self. _collection_obj = collection <TAB> self. _mongo_query = None <TAB> self. _query_obj = Q ( ) <TAB> self. _cls_query = { } <TAB> self. _where_clause = None <TAB> self. _loaded_fields = QueryFieldList ( ) <TAB> self. _ordering = None <TAB> self. _snapshot = False <TAB> self. _timeout = True <TAB> self. _read_preference = None <TAB> self. _read_concern = None <TAB> self. _iter = False <TAB> self. _scalar = [ ] <TAB> self. _none = False <TAB> self. _as_pymongo = False <TAB> self. _search_text = None <TAB> <TAB> <TAB> if document. _meta. get ( "allow_inheritance" ) is True : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _cls_query = { "_cls" : self. _document. _subclasses [ 0 ] } <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _cls_query = { "_cls" : { "$in" : self. _document. _subclasses } } <TAB> <TAB> self. _loaded_fields = QueryFieldList ( always_include = [ "_cls" ] ) <TAB> self. _cursor_obj = None <TAB> self. _limit = None <TAB> self. _skip = None <TAB> self. _hint = - 1 <TAB> self. _collation = None <TAB> self. _batch_size = None <TAB> self. _max_time_ms = None <TAB> self. _comment = None <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _empty = False | False | len(self._document._subclasses) == 1 | len(self._document) == 1 | 0.6623180508613586 |
289 | 287 | def wait_for_child ( pid, timeout = 1.0 ) : <TAB> deadline = mitogen. core. now ( ) + timeout <TAB> while timeout < mitogen. core. now ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> target_pid, status = os. waitpid ( pid, os. WNOHANG ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> e = sys. exc_info ( ) [ 1 ] <TAB> <TAB> <TAB> if e. args [ 0 ] == errno. ECHILD : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> time. sleep ( 0.05 ) <TAB> assert False, "wait_for_child() timed out" | False | target_pid == pid | status == 0 | 0.6709791421890259 |
290 | 288 | def resolve_none ( self, data ) : <TAB> <TAB> for tok_idx in range ( len ( data ) ) : <TAB> <TAB> for feat_idx in range ( len ( data [ tok_idx ] ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> data [ tok_idx ] [ feat_idx ] = "_" <TAB> return data | True | data[tok_idx][feat_idx] is None | data[tok_idx][feat_idx] is None | 0.6543666124343872 |
291 | 289 | def test_attributes_types ( self ) : <TAB> if not self. connection. strategy. pooled : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. connection. refresh_server_info ( ) <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> type ( self. connection. server. schema. attribute_types [ "cn" ] ), AttributeTypeInfo <TAB> <TAB> ) | False | not self.connection.server.info | self.connection.schema is not None | 0.6560783386230469 |
292 | 290 | def get_modified_addr ( self, erase_last = False ) : <TAB> last = self. last_iteration <TAB> new = self. feed ( self. last_value, erase_last = erase_last ) <TAB> ret = { } <TAB> for type, l in last. iteritems ( ) : <TAB> <TAB> typeset = set ( new [ type ] ) <TAB> <TAB> for addr in l : <TAB> <TAB> <TAB> if addr not in typeset : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> ret [ type ] = [ ] <TAB> <TAB> <TAB> <TAB> ret [ type ]. append ( addr ) <TAB> return ret | True | type not in ret | type not in ret | 0.6687414646148682 |
293 | 291 | def _get_compressor ( self, algorithm ) : <TAB> try : <TAB> <TAB> if algorithm. lower ( ) in ( "none", "off", "no" ) : <TAB> <TAB> <TAB> return None <TAB> <TAB> if algorithm. lower ( ) in ( "zlib", "gzip" ) : <TAB> <TAB> <TAB> import zlib as compressor <TAB> <TAB> <TAB> result = compressor <TAB> <TAB> elif algorithm. lower ( ) in ( "bz2", "bzip2" ) : <TAB> <TAB> <TAB> import bz2 as compressor <TAB> <TAB> <TAB> result = compressor <TAB> <TAB> else : <TAB> <TAB> <TAB> result = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return eventlet. tpool. Proxy ( result ) <TAB> except ImportError : <TAB> <TAB> pass <TAB> err = _ ( "unsupported compression algorithm: %s" ) % algorithm <TAB> raise ValueError ( err ) | False | result | result is not None | 0.6955109238624573 |
294 | 292 | def choices ( ) : <TAB> """Return a dict of different choices.""" <TAB> choices = { } <TAB> for choice in Action. __dict__ : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> value = int ( getattr ( Action, choice ) ) <TAB> <TAB> <TAB> <TAB> choices [ value ] = choice <TAB> <TAB> <TAB> except ( TypeError, ValueError ) : <TAB> <TAB> <TAB> <TAB> pass <TAB> return choices | True | hasattr(Action, choice) | hasattr(Action, choice) | 0.6596171259880066 |
295 | 293 | def _walkingCount ( self, limFn = None, cntFn = None ) : <TAB> tot = 0 <TAB> pcounts = { } <TAB> <TAB> for did in self. col. decks. active ( ) : <TAB> <TAB> <TAB> <TAB> did = int ( did ) <TAB> <TAB> <TAB> <TAB> lim = limFn ( self. col. decks. get ( did ) ) <TAB> <TAB> if not lim : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> parents = self. col. decks. parents ( did ) <TAB> <TAB> for p in parents : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> pcounts [ p [ "id" ] ] = limFn ( p ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> lim = min ( pcounts [ p [ "id" ] ], lim ) <TAB> <TAB> <TAB> <TAB> cnt = cntFn ( did, lim ) <TAB> <TAB> <TAB> <TAB> for p in parents : <TAB> <TAB> <TAB> pcounts [ p [ "id" ] ] -= cnt <TAB> <TAB> <TAB> <TAB> pcounts [ did ] = lim - cnt <TAB> <TAB> <TAB> <TAB> tot += cnt <TAB> return tot | True | p['id'] not in pcounts | p['id'] not in pcounts | 0.6638380885124207 |
296 | 294 | def generate_eway_bill ( self, ** kwargs ) : <TAB> args = frappe. _dict ( kwargs ) <TAB> headers = self. get_headers ( ) <TAB> eway_bill_details = get_eway_bill_details ( args ) <TAB> data = json. dumps ( <TAB> <TAB> { <TAB> <TAB> <TAB> "Irn" : args. irn, <TAB> <TAB> <TAB> "Distance" : cint ( eway_bill_details. distance ), <TAB> <TAB> <TAB> "TransMode" : eway_bill_details. mode_of_transport, <TAB> <TAB> <TAB> "TransId" : eway_bill_details. gstin, <TAB> <TAB> <TAB> "TransName" : eway_bill_details. transporter, <TAB> <TAB> <TAB> "TrnDocDt" : eway_bill_details. document_date, <TAB> <TAB> <TAB> "TrnDocNo" : eway_bill_details. document_name, <TAB> <TAB> <TAB> "VehNo" : eway_bill_details. vehicle_no, <TAB> <TAB> <TAB> "VehType" : eway_bill_details. vehicle_type, <TAB> <TAB> }, <TAB> <TAB> indent = 4, <TAB> ) <TAB> try : <TAB> <TAB> res = self. make_request ( "post", self. generate_ewaybill_url, headers, data ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. invoice. ewaybill = res. get ( "result" ). get ( "EwbNo" ) <TAB> <TAB> <TAB> self. invoice. eway_bill_cancelled = 0 <TAB> <TAB> <TAB> self. invoice. update ( args ) <TAB> <TAB> <TAB> self. invoice. flags. updater_reference = { <TAB> <TAB> <TAB> <TAB> "doctype" : self. invoice. doctype, <TAB> <TAB> <TAB> <TAB> "docname" : self. invoice | False | res.get('success') | res.get('result') is not None | 0.6566387414932251 |
297 | 295 | def removeKey ( self, key, group = None, locales = True ) : <TAB> <TAB> if not group : <TAB> <TAB> group = self. defaultGroup <TAB> try : <TAB> <TAB> if locales : <TAB> <TAB> <TAB> for name in list ( self. content [ group ] ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> del self. content [ group ] [ name ] <TAB> <TAB> value = self. content [ group ]. pop ( key ) <TAB> <TAB> self. tainted = True <TAB> <TAB> return value <TAB> except KeyError as e : <TAB> <TAB> if debug : <TAB> <TAB> <TAB> if e == group : <TAB> <TAB> <TAB> <TAB> raise NoGroupError ( group, self. filename ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise NoKeyError ( key, group, self. filename ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return "" | False | re.match('^' + key + xdg.Locale.regex + '$', name) and name != key | name in self.content[group] | 0.6521607637405396 |
298 | 296 | def clean_requires_python ( candidates ) : <TAB> """Get a cleaned list of all the candidates with valid specifiers in the `requires_python` attributes.""" <TAB> all_candidates = [ ] <TAB> py_version = parse_version ( <TAB> <TAB> os. environ. get ( "PIP_PYTHON_VERSION", ".". join ( map ( str, sys. version_info [ : 3 ] ) ) ) <TAB> ) <TAB> for c in candidates : <TAB> <TAB> if getattr ( c, "requires_python", None ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> c. requires_python = ">={0},<{1!s}". format ( <TAB> <TAB> <TAB> <TAB> <TAB> c. requires_python, int ( c. requires_python ) + 1 <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> specifierset = SpecifierSet ( c. requires_python ) <TAB> <TAB> <TAB> except InvalidSpecifier : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if not specifierset. contains ( py_version ) : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> all_candidates. append ( c ) <TAB> return all_candidates | False | len(c.requires_python) == 1 and c.requires_python in ('2', '3') | c.requires_python is None | 0.6525837182998657 |
299 | 297 | def JujuWait ( self ) : <TAB> """Wait for all deployed services to be installed, configured, and idle.""" <TAB> status = yaml. safe_load ( self. JujuStatus ( ) ) <TAB> for service in status [ "services" ] : <TAB> <TAB> ss = status [ "services" ] [ service ] [ "service-status" ] [ "current" ] <TAB> <TAB> <TAB> <TAB> if ss not in [ "active", "unknown" ] : <TAB> <TAB> <TAB> raise errors. Juju. TimeoutException ( <TAB> <TAB> <TAB> <TAB> "Service %s is not ready; status is %s" % ( service, ss ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if ss in [ "error" ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> debuglog = self. JujuRun ( "juju debug-log --limit 200" ) <TAB> <TAB> <TAB> logging. warn ( debuglog ) <TAB> <TAB> <TAB> raise errors. Juju. UnitErrorException ( <TAB> <TAB> <TAB> <TAB> "Service %s is in an error state" % service <TAB> <TAB> <TAB> ) <TAB> <TAB> for unit in status [ "services" ] [ service ] [ "units" ] : <TAB> <TAB> <TAB> unit_data = status [ "services" ] [ service ] [ "units" ] [ unit ] <TAB> <TAB> <TAB> ag = unit_data [ "agent-state" ] <TAB> <TAB> <TAB> if ag!= "started" : <TAB> <TAB> <TAB> <TAB> raise errors. Juju. TimeoutException ( <TAB> <TAB> <TAB> <TAB> <TAB> "Service %s is not ready; agent-state is %s" % ( service, ag ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ws = unit_data [ "workload-status" ] [ "current" ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise errors. Juju. TimeoutException ( <TAB> <TAB> | False | ws not in ['active', 'unknown'] | ws != 'cancel' | 0.6560594439506531 |
300 | 298 | def docroutine ( self, object, name = None, mod = None, cl = None ) : <TAB> """Produce text documentation for a function or method object.""" <TAB> realname = object. __name__ <TAB> name = name or realname <TAB> note = "" <TAB> skipdocs = 0 <TAB> if inspect. ismethod ( object ) : <TAB> <TAB> imclass = object. im_class <TAB> <TAB> if cl : <TAB> <TAB> <TAB> if imclass is not cl : <TAB> <TAB> <TAB> <TAB> note = " from " + classname ( imclass, mod ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if object. im_self is not None : <TAB> <TAB> <TAB> <TAB> note = " method of %s instance" % classname ( <TAB> <TAB> <TAB> <TAB> <TAB> object. im_self. __class__, mod <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> note = " unbound %s method" % classname ( imclass, mod ) <TAB> <TAB> object = object. im_func <TAB> if name == realname : <TAB> <TAB> title = self. bold ( realname ) <TAB> else : <TAB> <TAB> if cl and realname in cl. __dict__ and cl. __dict__ [ realname ] is object : <TAB> <TAB> <TAB> skipdocs = 1 <TAB> <TAB> title = self. bold ( name ) + " = " + realname <TAB> if inspect. isfunction ( object ) : <TAB> <TAB> args, varargs, varkw, defaults = inspect. getargspec ( object ) <TAB> <TAB> argspec = inspect. formatargspec ( <TAB> <TAB> <TAB> args, varargs, varkw, defaults, formatvalue = self. formatvalue <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> title = self. bold ( name ) + " lambda " <TAB> <TAB> <TAB> argspec = argspec [ 1 : - 1 ] <TAB> else | False | realname == '<lambda>' | name != None | 0.6732968091964722 |
301 | 299 | def __call__ ( self, context ) : <TAB> <TAB> <TAB> obj = self. param. parent ( context ) <TAB> name = self. param. key <TAB> if obj is None : <TAB> <TAB> raise AssertionError ( "No such object: %s" % self. param. parent. name ) <TAB> try : <TAB> <TAB> function = obj [ name ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise KeyError <TAB> except ( TypeError, KeyError ) : <TAB> <TAB> if hasattr ( obj, name ) and isinstance ( getattr ( obj, name ), ExpressionFunction ) : <TAB> <TAB> <TAB> function = getattr ( obj, name ) <TAB> <TAB> else : <TAB> <TAB> <TAB> wrapper = self. wrap_object ( obj ) <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> wrapper is not None <TAB> <TAB> <TAB> <TAB> and hasattr ( wrapper, name ) <TAB> <TAB> <TAB> <TAB> and isinstance ( getattr ( wrapper, name ), ExpressionFunction ) <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> function = getattr ( wrapper, name ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise AssertionError ( "Not a valid function: %s" % self. param. name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise AssertionError ( "Not a valid function: %s" % self. param. name ) <TAB> args = self. args ( context ) <TAB> return function ( * args ) | False | not isinstance(function, ExpressionFunction) | function is None | 0.6545538902282715 |
302 | 300 | def process_response ( self, request, response ) : <TAB> <TAB> if not response. streaming and len ( response. content ) < 200 : <TAB> <TAB> return response <TAB> patch_vary_headers ( response, ( "Accept-Encoding", ) ) <TAB> <TAB> if response. has_header ( "Content-Encoding" ) : <TAB> <TAB> return response <TAB> <TAB> if "msie" in request. META. get ( "HTTP_USER_AGENT", "" ). lower ( ) : <TAB> <TAB> ctype = response. get ( "Content-Type", "" ). lower ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return response <TAB> ae = request. META. get ( "HTTP_ACCEPT_ENCODING", "" ) <TAB> if not re_accepts_gzip. search ( ae ) : <TAB> <TAB> return response <TAB> if response. streaming : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> response. streaming_content = compress_sequence ( response. streaming_content ) <TAB> <TAB> del response [ "Content-Length" ] <TAB> else : <TAB> <TAB> <TAB> <TAB> compressed_content = compress_string ( response. content ) <TAB> <TAB> if len ( compressed_content ) >= len ( response. content ) : <TAB> <TAB> <TAB> return response <TAB> <TAB> response. content = compressed_content <TAB> <TAB> response [ "Content-Length" ] = str ( len ( response. content ) ) <TAB> if response. has_header ( "ETag" ) : <TAB> <TAB> response [ "ETag" ] = re. sub ( '"$', ';gzip"', response [ "ETag" ] ) <TAB> response [ "Content-Encoding" ] = "gzip" <TAB> return response | False | not ctype.startswith('text/') or 'javascript' in ctype | ctype in _accepts_gzip | 0.6522215604782104 |
303 | 301 | def brushengine_paint_hires ( ) : <TAB> from lib import tiledsurface, brush <TAB> s = tiledsurface. Surface ( ) <TAB> with open ( "brushes/v2/watercolor.myb" ) as fp : <TAB> <TAB> bi = brush. BrushInfo ( fp. read ( ) ) <TAB> b = brush. Brush ( bi ) <TAB> events = np. loadtxt ( "painting30sec.dat" ) <TAB> t_old = events [ 0 ] [ 0 ] <TAB> yield start_measurement <TAB> s. begin_atomic ( ) <TAB> trans_time = 0.0 <TAB> for t, x, y, pressure in events : <TAB> <TAB> dtime = t - t_old <TAB> <TAB> t_old = t <TAB> <TAB> b. stroke_to ( s. backend, x * 5, y * 5, pressure, 0.0, 0.0, dtime ) <TAB> <TAB> trans_time += dtime <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> trans_time = 0.0 <TAB> <TAB> <TAB> s. end_atomic ( ) <TAB> <TAB> <TAB> s. begin_atomic ( ) <TAB> s. end_atomic ( ) <TAB> yield stop_measurement | False | trans_time > 0.05 | trans_time > s.end_atomic() | 0.6561314463615417 |
304 | 302 | def _tile_series ( cls, op ) : <TAB> series = op. inputs [ 0 ] <TAB> if len ( series. chunks ) == 1 : <TAB> <TAB> chunk = series. chunks [ 0 ] <TAB> <TAB> chunk_op = op. copy ( ). reset_key ( ) <TAB> <TAB> out_chunks = [ <TAB> <TAB> <TAB> chunk_op. new_chunk ( <TAB> <TAB> <TAB> <TAB> series. chunks, <TAB> <TAB> <TAB> <TAB> shape = chunk. shape, <TAB> <TAB> <TAB> <TAB> index = chunk. index, <TAB> <TAB> <TAB> <TAB> index_value = op. outputs [ 0 ]. index_value, <TAB> <TAB> <TAB> <TAB> dtype = chunk. dtype, <TAB> <TAB> <TAB> <TAB> name = chunk. name, <TAB> <TAB> <TAB> ) <TAB> <TAB> ] <TAB> <TAB> new_op = op. copy ( ) <TAB> <TAB> kws = op. outputs [ 0 ]. params. copy ( ) <TAB> <TAB> kws [ "nsplits" ] = series. nsplits <TAB> <TAB> kws [ "chunks" ] = out_chunks <TAB> <TAB> return new_op. new_seriess ( op. inputs, ** kws ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise NotImplementedError ( "Only support puts NaNs at the end." ) <TAB> <TAB> <TAB> <TAB> return cls. _tile_psrs ( op, series ) | False | op.na_position != 'last' | len(series.outputs) > 0 | 0.6548214554786682 |
305 | 303 | def post_config_hook ( self ) : <TAB> self. last_transmitted_bytes = 0 <TAB> self. last_received_bytes = 0 <TAB> self. last_time = time. perf_counter ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> with Path ( "/proc/net/route" ). open ( ) as fh : <TAB> <TAB> <TAB> for line in fh : <TAB> <TAB> <TAB> <TAB> fields = line. strip ( ). split ( ) <TAB> <TAB> <TAB> <TAB> if fields [ 1 ] == "00000000" and int ( fields [ 3 ], 16 ) & 2 : <TAB> <TAB> <TAB> <TAB> <TAB> self. nic = fields [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. nic = "lo" <TAB> <TAB> self. py3. log ( f"selected nic: {self.nic}" ) <TAB> self. thresholds_init = self. py3. get_color_names_list ( self. format ) | False | self.nic is None | self.nic | 0.6575226187705994 |
306 | 304 | def import_data ( self ) : <TAB> if os. path. isfile ( self. _path ) : <TAB> <TAB> with open ( self. _path, "r" ) as db_file : <TAB> <TAB> <TAB> import_data = json. loads ( db_file. read ( ) ) <TAB> <TAB> <TAB> data = import_data [ "data" ] <TAB> <TAB> <TAB> for key_data in data : <TAB> <TAB> <TAB> <TAB> key = key_data [ 0 ] <TAB> <TAB> <TAB> <TAB> key_type = key_data [ 1 ] <TAB> <TAB> <TAB> <TAB> key_ttl = key_data [ 2 ] <TAB> <TAB> <TAB> <TAB> key_val = key_data [ 3 ] <TAB> <TAB> <TAB> <TAB> if key_type == "set" : <TAB> <TAB> <TAB> <TAB> <TAB> key_val = set ( key_val ) <TAB> <TAB> <TAB> <TAB> elif key_type == "deque" : <TAB> <TAB> <TAB> <TAB> <TAB> key_val = collections. deque ( key_val ) <TAB> <TAB> <TAB> <TAB> self. _data [ key ] = { <TAB> <TAB> <TAB> <TAB> <TAB> "ttl" : key_ttl, <TAB> <TAB> <TAB> <TAB> <TAB> "val" : key_val, <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> if "timers" in import_data : <TAB> <TAB> <TAB> <TAB> for key in import_data [ "timers" ] : <TAB> <TAB> <TAB> <TAB> <TAB> if key not in self. _data : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> ttl = self. _data [ key ] [ "ttl" ] <TAB> <TAB> <TAB> <TAB> <TAB> if not ttl : <TAB> <TAB> < | False | 'commit_log' in import_data | len(self._data) | 0.6545328497886658 |
307 | 305 | def _process_mempool ( self, all_hashes ) : <TAB> <TAB> txs = self. txs <TAB> hashXs = self. hashXs <TAB> touched = set ( ) <TAB> <TAB> for tx_hash in set ( txs ). difference ( all_hashes ) : <TAB> <TAB> tx = txs. pop ( tx_hash ) <TAB> <TAB> tx_hashXs = { hashX for hashX, value in tx. in_pairs } <TAB> <TAB> tx_hashXs. update ( hashX for hashX, value in tx. out_pairs ) <TAB> <TAB> for hashX in tx_hashXs : <TAB> <TAB> <TAB> hashXs [ hashX ]. remove ( tx_hash ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> del hashXs [ hashX ] <TAB> <TAB> touched. update ( tx_hashXs ) <TAB> <TAB> new_hashes = list ( all_hashes. difference ( txs ) ) <TAB> if new_hashes : <TAB> <TAB> fetches = [ ] <TAB> <TAB> for hashes in chunks ( new_hashes, 200 ) : <TAB> <TAB> <TAB> fetches. append ( self. _fetch_and_accept ( hashes, all_hashes, touched ) ) <TAB> <TAB> tx_map = { } <TAB> <TAB> utxo_map = { } <TAB> <TAB> for fetch in asyncio. as_completed ( fetches ) : <TAB> <TAB> <TAB> deferred, unspent = await fetch <TAB> <TAB> <TAB> tx_map. update ( deferred ) <TAB> <TAB> <TAB> utxo_map. update ( unspent ) <TAB> <TAB> prior_count = 0 <TAB> <TAB> <TAB> <TAB> while tx_map and len ( tx_map )!= prior_count : <TAB> <TAB> <TAB> prior_count = len ( tx_map ) <TAB> <TAB> <TAB> tx_map, utxo_map = self. _accept_transactions ( tx_map, utxo_map, touched ) <TAB> | False | not hashXs[hashX] | hashX | 0.6548793315887451 |
308 | 306 | def forward ( <TAB> self, <TAB> hidden_states, <TAB> attention_mask = None, <TAB> head_mask = None, <TAB> output_attentions = False, <TAB> output_hidden_states = False, <TAB> return_dict = True, ) : <TAB> all_hidden_states = ( ) if output_hidden_states else None <TAB> all_attentions = ( ) if output_attentions else None <TAB> for i, layer_module in enumerate ( self. layer ) : <TAB> <TAB> if output_hidden_states : <TAB> <TAB> <TAB> all_hidden_states = all_hidden_states + ( hidden_states, ) <TAB> <TAB> layer_outputs = layer_module ( <TAB> <TAB> <TAB> hidden_states, <TAB> <TAB> <TAB> attention_mask, <TAB> <TAB> <TAB> head_mask [ i ], <TAB> <TAB> <TAB> output_attentions, <TAB> <TAB> ) <TAB> <TAB> hidden_states = layer_outputs [ 0 ] <TAB> <TAB> if output_attentions : <TAB> <TAB> <TAB> all_attentions = all_attentions + ( layer_outputs [ 1 ], ) <TAB> <TAB> if output_hidden_states : <TAB> <TAB> all_hidden_states = all_hidden_states + ( hidden_states, ) <TAB> if not return_dict : <TAB> <TAB> return tuple ( <TAB> <TAB> <TAB> v <TAB> <TAB> <TAB> for v in [ hidden_states, all_hidden_states, all_attentions ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> ) <TAB> return BaseModelOutput ( <TAB> <TAB> last_hidden_state = hidden_states, <TAB> <TAB> hidden_states = all_hidden_states, <TAB> <TAB> attentions = all_attentions, <TAB> ) | False | v is not None | return_dict | 0.6533644199371338 |
309 | 307 | def sanitizeTreeKobo ( filetree ) : <TAB> pageNumber = 0 <TAB> for root, dirs, files in os. walk ( filetree ) : <TAB> <TAB> dirs, files = walkSort ( dirs, files ) <TAB> <TAB> for name in files : <TAB> <TAB> <TAB> splitname = os. path. splitext ( name ) <TAB> <TAB> <TAB> slugified = str ( pageNumber ). zfill ( 5 ) <TAB> <TAB> <TAB> pageNumber += 1 <TAB> <TAB> <TAB> while ( <TAB> <TAB> <TAB> <TAB> os. path. exists ( os. path. join ( root, slugified + splitname [ 1 ] ) ) <TAB> <TAB> <TAB> <TAB> and splitname [ 0 ]. upper ( )!= slugified. upper ( ) <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> slugified += "A" <TAB> <TAB> <TAB> newKey = os. path. join ( root, slugified + splitname [ 1 ] ) <TAB> <TAB> <TAB> key = os. path. join ( root, name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> os. replace ( key, newKey ) | False | key != newKey | os.path.exists(key) | 0.6999104022979736 |
310 | 308 | def testCheckpointMiddleOfSequence ( self ) : <TAB> <TAB> tm1 = BacktrackingTM ( numberOfCols = 100, cellsPerColumn = 12, verbosity = VERBOSITY ) <TAB> sequences = [ self. generateSequence ( ) for _ in xrange ( 5 ) ] <TAB> train = list ( itertools. chain. from_iterable ( sequences [ : 3 ] + [ sequences [ 3 ] [ : 5 ] ] ) ) <TAB> for bottomUpInput in train : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tm1. reset ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> tm1. compute ( bottomUpInput, True, True ) <TAB> <TAB> checkpointPath = os. path. join ( self. _tmpDir, "a" ) <TAB> tm1. saveToFile ( checkpointPath ) <TAB> tm2 = pickle. loads ( pickle. dumps ( tm1 ) ) <TAB> tm2. loadFromFile ( checkpointPath ) <TAB> <TAB> self. assertTMsEqual ( tm1, tm2 ) <TAB> <TAB> test = list ( itertools. chain. from_iterable ( [ sequences [ 3 ] [ 5 : ] ] + sequences [ 3 : ] ) ) <TAB> for bottomUpInput in test : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tm1. reset ( ) <TAB> <TAB> <TAB> tm2. reset ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> result1 = tm1. compute ( bottomUpInput, True, True ) <TAB> <TAB> <TAB> result2 = tm2. compute ( bottomUpInput, True, True ) <TAB> <TAB> <TAB> self. assertTMsEqual ( tm1, tm2 ) <TAB> <TAB> <TAB> self. assertTrue ( numpy. array_equal ( result1, result2 ) ) | False | bottomUpInput is None | bottomUpInput.hasReset | 0.6644439697265625 |
311 | 309 | def __init__ ( <TAB> self, <TAB> size, <TAB> comm, <TAB> decay = 0.9, <TAB> eps = 2e-5, <TAB> dtype = None, <TAB> use_gamma = True, <TAB> use_beta = True, <TAB> initial_gamma = None, <TAB> initial_beta = None, <TAB> communication_backend = "auto", ) : <TAB> chainer. utils. experimental ( "chainermn.links.MultiNodeBatchNormalization" ) <TAB> super ( MultiNodeBatchNormalization, self ). __init__ ( ) <TAB> self. _highprec_dtype = chainer. get_dtype ( dtype, map_mixed16 = numpy. float32 ) <TAB> self. comm = comm <TAB> self. avg_mean = numpy. zeros ( size, dtype = self. _highprec_dtype ) <TAB> self. register_persistent ( "avg_mean" ) <TAB> self. avg_var = numpy. zeros ( size, dtype = self. _highprec_dtype ) <TAB> self. register_persistent ( "avg_var" ) <TAB> self. N = 0 <TAB> self. register_persistent ( "N" ) <TAB> self. decay = decay <TAB> self. eps = eps <TAB> self. _communication_backend = ( <TAB> <TAB> chainermn_batch_normalization. get_communication_backend ( <TAB> <TAB> <TAB> comm, communication_backend <TAB> <TAB> ) <TAB> ) <TAB> with self. init_scope ( ) : <TAB> <TAB> if use_gamma : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> initial_gamma = 1 <TAB> <TAB> <TAB> initial_gamma = initializers. _get_initializer ( initial_gamma ) <TAB> <TAB> <TAB> initial_gamma. dtype = self. _highprec_dtype <TAB> <TAB> <TAB> self. gamma = variable. Parameter ( initial_gamma, size ) <TAB> <TAB> if use_beta : <TAB> <TAB> <TAB> if initial_beta is None : <TAB> <TAB> <TAB> <TAB | True | initial_gamma is None | initial_gamma is None | 0.6598143577575684 |
312 | 310 | def _install_script ( self, src, header ) : <TAB> strip_ext = True <TAB> set_mode = False <TAB> if sys. platform == "win32" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> strip_ext = False <TAB> targ_basename = os. path. basename ( src ) <TAB> if strip_ext and targ_basename. endswith ( ".py" ) : <TAB> <TAB> targ_basename = targ_basename [ : - 3 ] <TAB> targ = os. path. join ( self. install_dir, targ_basename ) <TAB> self. announce ( "installing %s as %s" % ( src, targ_basename ), level = 2 ) <TAB> if self. dry_run : <TAB> <TAB> return [ ] <TAB> with open ( src, "rU" ) as in_fp : <TAB> <TAB> with open ( targ, "w" ) as out_fp : <TAB> <TAB> <TAB> line = in_fp. readline ( ). rstrip ( ) <TAB> <TAB> <TAB> if line. startswith ( "#!" ) : <TAB> <TAB> <TAB> <TAB> print ( line, file = out_fp ) <TAB> <TAB> <TAB> <TAB> print ( header, file = out_fp ) <TAB> <TAB> <TAB> <TAB> if os. name == "posix" : <TAB> <TAB> <TAB> <TAB> <TAB> set_mode = True <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> print ( header, file = out_fp ) <TAB> <TAB> <TAB> <TAB> print ( line, file = out_fp ) <TAB> <TAB> <TAB> for line in in_fp. readlines ( ) : <TAB> <TAB> <TAB> <TAB> line = line. rstrip ( ) <TAB> <TAB> <TAB> <TAB> print ( line, file = out_fp ) <TAB> if set_mode : <TAB> <TAB> mode = ( ( os. stat ( targ ). st_mode ) | 0o555 ) & 0o7777 <TAB> <TAB | False | 'MSYSTEM' not in os.environ | os.path.exists(src) | 0.6561071872711182 |
313 | 311 | def extract_authors ( self, field, name, docinfo ) : <TAB> try : <TAB> <TAB> if len ( field [ 1 ] ) == 1 : <TAB> <TAB> <TAB> if isinstance ( field [ 1 ] [ 0 ], nodes. paragraph ) : <TAB> <TAB> <TAB> <TAB> authors = self. authors_from_one_paragraph ( field ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> authors = self. authors_from_bullet_list ( field ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise TransformError <TAB> <TAB> else : <TAB> <TAB> <TAB> authors = self. authors_from_paragraphs ( field ) <TAB> <TAB> authornodes = [ nodes. author ( "", "", * author ) for author in authors if author ] <TAB> <TAB> if len ( authornodes ) >= 1 : <TAB> <TAB> <TAB> docinfo. append ( nodes. authors ( "", * authornodes ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise TransformError <TAB> except TransformError : <TAB> <TAB> field [ - 1 ] += self. document. reporter. warning ( <TAB> <TAB> <TAB> 'Bibliographic field "%s" incompatible with extraction:'<TAB> <TAB> <TAB> "it must contain either a single paragraph (with authors " <TAB> <TAB> <TAB>'separated by one of "%s"), multiple paragraphs (one per'<TAB> <TAB> <TAB> "author), or a bullet list with one paragraph (one author) " <TAB> <TAB> <TAB> "per item." % ( name, "". join ( self. language. author_separators ) ), <TAB> <TAB> <TAB> base_node = field, <TAB> <TAB> ) <TAB> <TAB> raise | True | isinstance(field[1][0], nodes.bullet_list) | isinstance(field[1][0], nodes.bullet_list) | 0.6546348333358765 |
314 | 312 | def on_task_filter ( self, task, config ) : <TAB> if not task. accepted : <TAB> <TAB> log. debug ( "No accepted entries, not scanning for existing." ) <TAB> <TAB> return <TAB> log. verbose ( "Scanning path(s) for existing files." ) <TAB> config = self. prepare_config ( config ) <TAB> filenames = { } <TAB> for folder in config : <TAB> <TAB> folder = Path ( folder ). expanduser ( ) <TAB> <TAB> if not folder. exists ( ) : <TAB> <TAB> <TAB> raise plugin. PluginWarning ( "Path %s does not exist" % folder, log ) <TAB> <TAB> for p in folder. rglob ( "*" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> key = p. name <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if platform. system ( ) == "Windows" : <TAB> <TAB> <TAB> <TAB> <TAB> key = key. lower ( ) <TAB> <TAB> <TAB> <TAB> filenames [ key ] = p <TAB> for entry in task. accepted : <TAB> <TAB> <TAB> <TAB> name = Path ( entry. get ( "filename", entry. get ( "location", entry [ "title" ] ) ) ). name <TAB> <TAB> if platform. system ( ) == "Windows" : <TAB> <TAB> <TAB> name = name. lower ( ) <TAB> <TAB> if name in filenames : <TAB> <TAB> <TAB> log. debug ( "Found %s in %s" % ( name, filenames [ name ] ) ) <TAB> <TAB> <TAB> entry. reject ( "exists in %s" % filenames [ name ] ) | False | p.is_file() | p.exists() | 0.6524482369422913 |
315 | 313 | def _update_cds_vdims ( self ) : <TAB> <TAB> <TAB> element = self. plot. current_frame <TAB> cds = self. plot. handles [ "cds" ] <TAB> for d in element. vdims : <TAB> <TAB> scalar = element. interface. isscalar ( element, d ) <TAB> <TAB> dim = dimension_sanitizer ( d. name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if scalar : <TAB> <TAB> <TAB> <TAB> cds. data [ dim ] = element. dimension_values ( d, not scalar ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> cds. data [ dim ] = [ <TAB> <TAB> <TAB> <TAB> <TAB> arr [ :, 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> for arr in element. split ( datatype = "array", dimensions = [ dim ] ) <TAB> <TAB> <TAB> <TAB> ] | False | dim not in cds.data | dim | 0.670620858669281 |
316 | 314 | def progress_bar_update ( <TAB> count1 = None, count2 = None, count3 = None, count4 = None, count5 = None, count6 = None ) : <TAB> lock. acquire ( ) <TAB> global pbar_file_permission_done <TAB> if count1 is not None : <TAB> <TAB> if count1 <= 100 : <TAB> <TAB> <TAB> pbar1. update ( count1 ) <TAB> if count2 is not None : <TAB> <TAB> if count2 <= 100 : <TAB> <TAB> <TAB> pbar2. update ( count2 ) <TAB> if count3 is not None : <TAB> <TAB> if not pbar_file_permission_done : <TAB> <TAB> <TAB> if count3 < 100 : <TAB> <TAB> <TAB> <TAB> pbar3. update ( count3 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> pbar3. update ( count3 ) <TAB> <TAB> <TAB> <TAB> pbar_file_permission_done = True <TAB> <TAB> else : <TAB> <TAB> <TAB> pbar4. update ( count3 ) <TAB> if count4 is not None : <TAB> <TAB> if count4 <= 100 : <TAB> <TAB> <TAB> pbar5. update ( count4 ) <TAB> if count5 is not None : <TAB> <TAB> if count5 <= 100 : <TAB> <TAB> <TAB> pbar6. update ( count5 ) <TAB> if count6 is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pbar7. update ( count6 ) <TAB> lock. release ( ) | True | count6 <= 100 | count6 <= 100 | 0.6802228689193726 |
317 | 315 | def _executables_in_windows ( path ) : <TAB> if not os. path. isdir ( path ) : <TAB> <TAB> return <TAB> extensions = builtins. __xonsh__. env [ "PATHEXT" ] <TAB> try : <TAB> <TAB> for x in scandir ( path ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> is_file = x. is_file ( ) <TAB> <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> fname = x. name <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> base_name, ext = os. path. splitext ( fname ) <TAB> <TAB> <TAB> if ext. upper ( ) in extensions : <TAB> <TAB> <TAB> <TAB> yield fname <TAB> except FileNotFoundError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return | True | is_file | is_file | 0.6598045825958252 |
318 | 316 | def test_payload_splitter ( self ) : <TAB> with open ( FIXTURE_PATH + "/legacy_payload.json" ) as f : <TAB> <TAB> legacy_payload = json. load ( f ) <TAB> legacy_payload_split, metrics_payload, checkruns_payload = split_payload ( <TAB> <TAB> dict ( legacy_payload ) <TAB> ) <TAB> series = metrics_payload [ "series" ] <TAB> legacy_payload_split [ "metrics" ] = [ ] <TAB> for s in series : <TAB> <TAB> attributes = { } <TAB> <TAB> if s. get ( "type" ) : <TAB> <TAB> <TAB> attributes [ "type" ] = s [ "type" ] <TAB> <TAB> if s. get ( "host" ) : <TAB> <TAB> <TAB> attributes [ "hostname" ] = s [ "host" ] <TAB> <TAB> if s. get ( "tags" ) : <TAB> <TAB> <TAB> attributes [ "tags" ] = s [ "tags" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> attributes [ "device_name" ] = s [ "device" ] <TAB> <TAB> formatted_sample = [ <TAB> <TAB> <TAB> s [ "metric" ], <TAB> <TAB> <TAB> s [ "points" ] [ 0 ] [ 0 ], <TAB> <TAB> <TAB> s [ "points" ] [ 0 ] [ 1 ], <TAB> <TAB> <TAB> attributes, <TAB> <TAB> ] <TAB> <TAB> legacy_payload_split [ "metrics" ]. append ( formatted_sample ) <TAB> del legacy_payload [ "service_checks" ] <TAB> self. assertEqual ( legacy_payload, legacy_payload_split ) <TAB> with open ( FIXTURE_PATH + "/sc_payload.json" ) as f : <TAB> <TAB> expected_sc_payload = json. load ( f ) <TAB> self. assertEqual ( checkruns_payload, expected_sc_payload ) | False | s.get('device') | s.get(device) | 0.6555224061012268 |
319 | 317 | def write ( self, data ) : <TAB> if mock_target. _mirror_on_stderr : <TAB> <TAB> if self. _write_line : <TAB> <TAB> <TAB> sys. stderr. write ( fn + ": " ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sys. stderr. write ( data. decode ( "utf8" ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> sys. stderr. write ( data ) <TAB> <TAB> if ( data [ - 1 ] ) == "\n" : <TAB> <TAB> <TAB> self. _write_line = True <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _write_line = False <TAB> super ( Buffer, self ). write ( data ) | False | bytes | isinstance(data, bytes) | 0.6905951499938965 |
320 | 318 | def _calculateParams ( self, listPackages ) : <TAB> self. mapCyclesToPackageList. clear ( ) <TAB> self. mapPackageToCycle. clear ( ) <TAB> self. sortedPackageList = [ ] <TAB> self. listOfPackagesAlreadyBuilt = self. _readAlreadyAvailablePackages ( ) <TAB> if self. listOfPackagesAlreadyBuilt : <TAB> <TAB> self. logger. debug ( "List of already available packages:" ) <TAB> <TAB> self. logger. debug ( self. listOfPackagesAlreadyBuilt ) <TAB> listPackagesToBuild = copy. copy ( listPackages ) <TAB> for pkg in listPackages : <TAB> <TAB> if pkg in self. listOfPackagesAlreadyBuilt and not constants. rpmCheck : <TAB> <TAB> <TAB> listPackagesToBuild. remove ( pkg ) <TAB> if constants. rpmCheck : <TAB> <TAB> self. sortedPackageList = listPackagesToBuild <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> if self. sortedPackageList : <TAB> <TAB> self. logger. info ( "List of packages yet to be built..." ) <TAB> <TAB> self. logger. info ( <TAB> <TAB> <TAB> str ( set ( self. sortedPackageList ) - set ( self. listOfPackagesAlreadyBuilt ) ) <TAB> <TAB> ) <TAB> <TAB> self. logger. info ( "" ) <TAB> return True | False | not self._readPackageBuildData(listPackagesToBuild) | not list(self.sortedPackageList) | 0.6537013053894043 |
321 | 319 | def PyJs_anonymous_53_ ( ast, comments, tokens, this, arguments, var = var ) : <TAB> var = Scope ( <TAB> <TAB> { <TAB> <TAB> <TAB> u"tokens" : tokens, <TAB> <TAB> <TAB> u"this" : this, <TAB> <TAB> <TAB> u"arguments" : arguments, <TAB> <TAB> <TAB> u"comments" : comments, <TAB> <TAB> <TAB> u"ast" : ast, <TAB> <TAB> }, <TAB> <TAB> var, <TAB> ) <TAB> var. registers ( [ u"tokens", u"comments", u"ast" ] ) <TAB> if var. get ( u"ast" ) : <TAB> <TAB> if PyJsStrictEq ( var. get ( u"ast" ). get ( u"type" ), Js ( u"Program" ) ) : <TAB> <TAB> <TAB> return var. get ( u"t" ). callprop ( <TAB> <TAB> <TAB> <TAB> u"file", <TAB> <TAB> <TAB> <TAB> var. get ( u"ast" ), <TAB> <TAB> <TAB> <TAB> ( var. get ( u"comments" ) or Js ( [ ] ) ), <TAB> <TAB> <TAB> <TAB> ( var. get ( u"tokens" ) or Js ( [ ] ) ), <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return var. get ( u"ast" ) <TAB> PyJsTempException = JsToPyException ( <TAB> <TAB> var. get ( u"Error" ). create ( Js ( u"Not a valid ast?" ) ) <TAB> ) <TAB> raise PyJsTempException | False | PyJsStrictEq(var.get(u'ast').get(u'type'), Js(u'File')) | PYJsTempException | 0.6549234390258789 |
322 | 320 | def AdjustLabels ( self, axis, minimum_label_spacing ) : <TAB> if minimum_label_spacing is None : <TAB> <TAB> return <TAB> if len ( axis. labels ) <= 1 : <TAB> <TAB> return <TAB> if axis. max is not None and axis. min is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> maximum_possible_spacing = ( axis. max - axis. min ) / ( len ( axis. labels ) - 1 ) <TAB> <TAB> if minimum_label_spacing > maximum_possible_spacing : <TAB> <TAB> <TAB> minimum_label_spacing = maximum_possible_spacing <TAB> labels = [ list ( x ) for x in zip ( axis. label_positions, axis. labels ) ] <TAB> labels = sorted ( labels, reverse = True ) <TAB> <TAB> for i in range ( 1, len ( labels ) ) : <TAB> <TAB> if labels [ i - 1 ] [ 0 ] - labels [ i ] [ 0 ] < minimum_label_spacing : <TAB> <TAB> <TAB> new_position = labels [ i - 1 ] [ 0 ] - minimum_label_spacing <TAB> <TAB> <TAB> if axis. min is not None and new_position < axis. min : <TAB> <TAB> <TAB> <TAB> new_position = axis. min <TAB> <TAB> <TAB> labels [ i ] [ 0 ] = new_position <TAB> <TAB> for i in range ( len ( labels ) - 2, - 1, - 1 ) : <TAB> <TAB> if labels [ i ] [ 0 ] - labels [ i + 1 ] [ 0 ] < minimum_label_spacing : <TAB> <TAB> <TAB> new_position = labels [ i + 1 ] [ 0 ] + minimum_label_spacing <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> new_position = axis. max <TAB> <TAB> <TAB> labels [ i ] [ 0 ] = new_position <TAB> <TAB> label_positions, labels = zip ( * labels ) <TAB> axis. labels = labels <TAB> axis. label_positions = label_positions | False | axis.max is not None and new_position > axis.max | new_position > axis.max | 0.6511911153793335 |
323 | 321 | def __get_property_type_info ( cls, property_proto ) : <TAB> """Returns the type mapping for the provided property.""" <TAB> name = property_proto. name ( ) <TAB> is_repeated = bool ( property_proto. multiple ( ) ) <TAB> primitive_type = None <TAB> entity_type = None <TAB> if property_proto. has_meaning ( ) : <TAB> <TAB> primitive_type = MEANING_TO_PRIMITIVE_TYPE. get ( property_proto. meaning ( ) ) <TAB> if primitive_type is None : <TAB> <TAB> value = property_proto. value ( ) <TAB> <TAB> if value. has_int64value ( ) : <TAB> <TAB> <TAB> primitive_type = backup_pb2. EntitySchema. INTEGER <TAB> <TAB> elif value. has_booleanvalue ( ) : <TAB> <TAB> <TAB> primitive_type = backup_pb2. EntitySchema. BOOLEAN <TAB> <TAB> elif value. has_stringvalue ( ) : <TAB> <TAB> <TAB> if property_proto. meaning ( ) == entity_pb. Property. ENTITY_PROTO : <TAB> <TAB> <TAB> <TAB> entity_proto = entity_pb. EntityProto ( ) <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> entity_proto. ParsePartialFromString ( value. stringvalue ( ) ) <TAB> <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> entity_type = EntityTypeInfo. create_from_entity_proto ( entity_proto ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> primitive_type = backup_pb2. EntitySchema. STRING <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> primitive_type = backup_pb2. EntitySchema. FLOAT <TAB> <TAB> elif value. has_pointvalue ( ) : <TAB> <TAB> <TAB> primitive_ | False | value.has_doublevalue() | value.has_floating() | 0.6519709229469299 |
324 | 322 | def initialize_batcher ( <TAB> self, <TAB> dataset, <TAB> batch_size = 128, <TAB> bucketing_field = None, <TAB> should_shuffle = True, <TAB> ignore_last = False, ) : <TAB> if self. horovod : <TAB> <TAB> batcher = DistributedBatcher ( <TAB> <TAB> <TAB> dataset, <TAB> <TAB> <TAB> self. horovod. rank ( ), <TAB> <TAB> <TAB> self. horovod, <TAB> <TAB> <TAB> batch_size, <TAB> <TAB> <TAB> should_shuffle = should_shuffle, <TAB> <TAB> <TAB> ignore_last = ignore_last, <TAB> <TAB> ) <TAB> elif bucketing_field is not None : <TAB> <TAB> input_features = self. hyperparameters [ "input_features" ] <TAB> <TAB> bucketing_feature = [ <TAB> <TAB> <TAB> feature for feature in input_features if feature [ "name" ] == bucketing_field <TAB> <TAB> ] <TAB> <TAB> if not bucketing_feature : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> "Bucketing field {} not present in input features". format ( <TAB> <TAB> <TAB> <TAB> <TAB> bucketing_field <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> bucketing_feature = bucketing_feature [ 0 ] <TAB> <TAB> should_trim = bucketing_feature [ "encoder" ] in dynamic_length_encoders <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> trim_side = bucketing_feature [ "preprocessing" ] [ "padding" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> trim_side = self. hyperparameters [ "preprocessing" ] [ <TAB> <TAB> <TAB> <TAB> bucketing_feature [ "type" ] <TAB> <TAB> <TAB> ] [ "padding" | False | 'preprocessing' in bucketing_feature | should_trim | 0.6586976051330566 |
325 | 323 | def get ( self, request, * args, ** kwargs ) : <TAB> if request. GET. get ( "format", None ) == "json" : <TAB> <TAB> self. setup_queryset ( * args, ** kwargs ) <TAB> <TAB> <TAB> <TAB> if "pid" in kwargs : <TAB> <TAB> <TAB> self. static_context_extra [ "pid" ] = kwargs [ "pid" ] <TAB> <TAB> cmd = request. GET. get ( "cmd", None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> data = self. get_filter_info ( request, ** kwargs ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> data = self. get_data ( request, ** kwargs ) <TAB> <TAB> return HttpResponse ( data, content_type = "application/json" ) <TAB> return super ( ToasterTable, self ). get ( request, * args, ** kwargs ) | False | cmd and 'filterinfo' in cmd | cmd == None | 0.658203125 |
326 | 324 | def wakeUp ( self ) : <TAB> """Write one byte to the pipe, and flush it.""" <TAB> <TAB> <TAB> if self. o is not None : <TAB> <TAB> try : <TAB> <TAB> <TAB> util. untilConcludes ( os. write, self. o, b"x" ) <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise | False | e.errno != errno.EAGAIN | e.args[0] not in _EBADF_TAB | 0.6523231267929077 |
327 | 325 | def contact_me ( request, attribute = "", response_format = "html" ) : <TAB> "My Contact card" <TAB> contact = request. user. profile. get_contact ( ) <TAB> if not request. user. profile. has_permission ( contact ) : <TAB> <TAB> return user_denied ( request, message = "You don't have access to this Contact" ) <TAB> types = Object. filter_by_request ( request, ContactType. objects. order_by ( "name" ) ) <TAB> if not contact : <TAB> <TAB> return render_to_response ( <TAB> <TAB> <TAB> "identities/contact_me_missing", <TAB> <TAB> <TAB> { "types" : types }, <TAB> <TAB> <TAB> context_instance = RequestContext ( request ), <TAB> <TAB> <TAB> response_format = response_format, <TAB> <TAB> ) <TAB> subcontacts = Object. filter_by_request ( request, contact. child_set ) <TAB> contact_values = contact. contactvalue_set. order_by ( "field__name" ) <TAB> objects = get_contact_objects ( request. user. profile, contact, preformat = True ) <TAB> module = None <TAB> for key in objects : <TAB> <TAB> if not attribute : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> module = objects [ key ] [ "module" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> if attribute in objects [ key ] [ "objects" ]. keys ( ) : <TAB> <TAB> <TAB> <TAB> module = objects [ key ] [ "module" ] <TAB> <TAB> <TAB> <TAB> break <TAB> return render_to_response ( <TAB> <TAB> "identities/contact_me", <TAB> <TAB> { <TAB> <TAB> <TAB> "contact" : contact, <TAB> <TAB> <TAB> "subcontacts" : subcontacts, <TAB> <TAB> <TAB> "objects" : objects, <TAB> | False | objects[key]['count'] | module and key in objects | 0.6654888391494751 |
328 | 326 | def findfiles ( path ) : <TAB> files = [ ] <TAB> for name in os. listdir ( path ) : <TAB> <TAB> <TAB> <TAB> if name. startswith ( "." ) or name == "lastsnap.jpg" : <TAB> <TAB> <TAB> continue <TAB> <TAB> pathname = os. path. join ( path, name ) <TAB> <TAB> st = os. lstat ( pathname ) <TAB> <TAB> mode = st. st_mode <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> files. extend ( findfiles ( pathname ) ) <TAB> <TAB> elif stat. S_ISREG ( mode ) : <TAB> <TAB> <TAB> files. append ( ( pathname, name, st ) ) <TAB> return files | False | stat.S_ISDIR(mode) | mode | 0.6498696208000183 |
329 | 327 | def make_parser ( <TAB> func : tp. Callable, <TAB> subparser : ap. _SubParsersAction = None, <TAB> params : tp. Dict [ str, tp. Dict [ str, tp. Any ] ] = None, <TAB> ** kwargs ) -> "ap.ArgumentParser" : <TAB> """A bare-bones argparse builder from functions""" <TAB> doc = get_doc ( func ) <TAB> kwargs. setdefault ( "formatter_class", ap. RawTextHelpFormatter ) <TAB> if subparser is None : <TAB> <TAB> kwargs. setdefault ( "description", doc ) <TAB> <TAB> parser = ap. ArgumentParser ( ** kwargs ) <TAB> <TAB> parser. set_defaults ( <TAB> <TAB> <TAB> ** { _FUNC_NAME : lambda stdout : parser. print_help ( file = stdout ) } <TAB> <TAB> ) <TAB> <TAB> return parser <TAB> else : <TAB> <TAB> parser = subparser. add_parser ( <TAB> <TAB> <TAB> kwargs. pop ( "prog", func. __name__ ), <TAB> <TAB> <TAB> help = doc, <TAB> <TAB> <TAB> ** kwargs, <TAB> <TAB> ) <TAB> <TAB> parser. set_defaults ( ** { _FUNC_NAME : func } ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for par, args in params. items ( ) : <TAB> <TAB> <TAB> <TAB> args. setdefault ( "help", get_doc ( func, par ) ) <TAB> <TAB> <TAB> <TAB> parser. add_argument ( par, ** args ) <TAB> <TAB> return parser | False | params | params is not None | 0.7064627408981323 |
330 | 328 | def load_ip ( self ) : <TAB> if os. path. isfile ( self. ip_list_fn ) : <TAB> <TAB> file_path = self. ip_list_fn <TAB> elif self. default_ip_list_fn and os. path. isfile ( self. default_ip_list_fn ) : <TAB> <TAB> file_path = self. default_ip_list_fn <TAB> else : <TAB> <TAB> return <TAB> with open ( file_path, "r" ) as fd : <TAB> <TAB> lines = fd. readlines ( ) <TAB> for line in lines : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> str_l = line. split ( " " ) <TAB> <TAB> <TAB> if len ( str_l ) < 4 : <TAB> <TAB> <TAB> <TAB> self. logger. warning ( "line err: %s", line ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> ip_str = str_l [ 0 ] <TAB> <TAB> <TAB> domain = str_l [ 1 ] <TAB> <TAB> <TAB> server = str_l [ 2 ] <TAB> <TAB> <TAB> handshake_time = int ( str_l [ 3 ] ) <TAB> <TAB> <TAB> if len ( str_l ) > 4 : <TAB> <TAB> <TAB> <TAB> fail_times = int ( str_l [ 4 ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> fail_times = 0 <TAB> <TAB> <TAB> if len ( str_l ) > 5 : <TAB> <TAB> <TAB> <TAB> down_fail = int ( str_l [ 5 ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> down_fail = 0 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. add_ip ( <TAB> <TAB> <TAB> < | False | line.startswith('#') | not line | 0.6520669460296631 |
331 | 329 | def tms_to_quadkey ( self, tms, google = False ) : <TAB> quadKey = "" <TAB> x, y, z = tms <TAB> <TAB> <TAB> if not google : <TAB> <TAB> y = ( 2 ** z - 1 ) - y <TAB> for i in range ( z, 0, - 1 ) : <TAB> <TAB> digit = 0 <TAB> <TAB> mask = 1 << ( i - 1 ) <TAB> <TAB> if ( x & mask )!= 0 : <TAB> <TAB> <TAB> digit += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> digit += 2 <TAB> <TAB> quadKey += str ( digit ) <TAB> return quadKey | False | y & mask != 0 | y & mask | 0.6735246181488037 |
332 | 330 | def wait_success ( self, timeout = 60 * 10 ) : <TAB> for i in range ( timeout // 10 ) : <TAB> <TAB> time. sleep ( 10 ) <TAB> <TAB> status = self. query_job ( ) <TAB> <TAB> print ( "job {} status is {}". format ( self. job_id, status ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return True <TAB> <TAB> if status and status in [ <TAB> <TAB> <TAB> StatusSet. CANCELED, <TAB> <TAB> <TAB> StatusSet. TIMEOUT, <TAB> <TAB> <TAB> StatusSet. FAILED, <TAB> <TAB> ] : <TAB> <TAB> <TAB> return False <TAB> return False | False | status and status == StatusSet.SUCCESS | not status | 0.6639950275421143 |
333 | 331 | def create_connection ( self, address, protocol_factory = None, ** kw ) : <TAB> """Helper method for creating a connection to an ``address``.""" <TAB> protocol_factory = protocol_factory or self. create_protocol <TAB> if isinstance ( address, tuple ) : <TAB> <TAB> host, port = address <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. logger. debug ( "Create connection %s:%s", host, port ) <TAB> <TAB> _, protocol = await self. _loop. create_connection ( <TAB> <TAB> <TAB> protocol_factory, host, port, ** kw <TAB> <TAB> ) <TAB> <TAB> await protocol. event ( "connection_made" ) <TAB> else : <TAB> <TAB> raise NotImplementedError ( "Could not connect to %s" % str ( address ) ) <TAB> return protocol | False | self.debug | self.logger and (not self.logger.isEnabledFor(logging.DEBUG)) | 0.6623555421829224 |
334 | 332 | def _import_module_with_version_check ( module_name, minimum_version, install_info = None ) : <TAB> """Check that module is installed with a recent enough version""" <TAB> from distutils. version import LooseVersion <TAB> try : <TAB> <TAB> module = __import__ ( module_name ) <TAB> except ImportError as exc : <TAB> <TAB> user_friendly_info = ( 'Module "{0}" could not be found. {1}' ). format ( <TAB> <TAB> <TAB> module_name, install_info or "Please install it properly to use nilearn." <TAB> <TAB> ) <TAB> <TAB> exc. args += ( user_friendly_info, ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> exc. msg += ". " + user_friendly_info <TAB> <TAB> raise <TAB> <TAB> module_version = getattr ( module, "__version__", "0.0.0" ) <TAB> version_too_old = not LooseVersion ( module_version ) >= LooseVersion ( minimum_version ) <TAB> if version_too_old : <TAB> <TAB> message = ( <TAB> <TAB> <TAB> "A {module_name} version of at least {minimum_version} " <TAB> <TAB> <TAB> "is required to use nilearn. {module_version} was found. " <TAB> <TAB> <TAB> "Please upgrade {module_name}" <TAB> <TAB> ). format ( <TAB> <TAB> <TAB> module_name = module_name, <TAB> <TAB> <TAB> minimum_version = minimum_version, <TAB> <TAB> <TAB> module_version = module_version, <TAB> <TAB> ) <TAB> <TAB> raise ImportError ( message ) <TAB> return module | False | hasattr(exc, 'msg') | install_info | 0.6600459814071655 |
335 | 333 | def do_search ( lo, hi ) : <TAB> if hi - lo <= 1 : <TAB> <TAB> return hi <TAB> mid = int ( math. floor ( ( hi - lo ) / 2 ) + lo ) <TAB> log. info ( "Testing {0}". format ( draw_graph ( lo, mid, hi, len ( commit_hashes ) ) ) ) <TAB> with log. indent ( ) : <TAB> <TAB> lo_result = None <TAB> <TAB> while lo_result is None : <TAB> <TAB> <TAB> lo_result = do_benchmark ( lo ) <TAB> <TAB> <TAB> if not non_null_results ( lo_result ) : <TAB> <TAB> <TAB> <TAB> lo_result = None <TAB> <TAB> <TAB> <TAB> lo += 1 <TAB> <TAB> <TAB> <TAB> if lo >= mid : <TAB> <TAB> <TAB> <TAB> <TAB> raise util. UserError ( "Too many commits failed" ) <TAB> <TAB> mid_result = None <TAB> <TAB> while mid_result is None : <TAB> <TAB> <TAB> mid_result = do_benchmark ( mid ) <TAB> <TAB> <TAB> if not non_null_results ( mid_result, lo_result ) : <TAB> <TAB> <TAB> <TAB> mid_result = None <TAB> <TAB> <TAB> <TAB> mid += 1 <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> raise util. UserError ( "Too many commits failed" ) <TAB> <TAB> hi_result = None <TAB> <TAB> while hi_result is None : <TAB> <TAB> <TAB> hi_result = do_benchmark ( hi ) <TAB> <TAB> <TAB> if not non_null_results ( lo_result, mid_result, hi_result ) : <TAB> <TAB> <TAB> <TAB> hi_result = None <TAB> <TAB> <TAB> <TAB> hi -= 1 <TAB> <TAB> <TAB> <TAB> if hi <= mid : <TAB> <TAB | False | mid >= hi | lo >= mid and mid_result is None | 0.7026615142822266 |
336 | 334 | def _load ( self, path : str ) : <TAB> ds = DataSet ( ) <TAB> with open ( path, "r", encoding = "utf-8" ) as f : <TAB> <TAB> for line in f : <TAB> <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> <TAB> if line : <TAB> <TAB> <TAB> <TAB> parts = line. split ( "\t" ) <TAB> <TAB> <TAB> <TAB> raw_words1 = parts [ 1 ] <TAB> <TAB> <TAB> <TAB> raw_words2 = parts [ 2 ] <TAB> <TAB> <TAB> <TAB> target = parts [ 0 ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> ds. append ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> Instance ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raw_words1 = raw_words1, raw_words2 = raw_words2, target = target <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> return ds | False | raw_words1 and raw_words2 and target | target | 0.6569558382034302 |
337 | 335 | def FallbackGetIndex ( self, targetMO, argMOs, errorSuggestionMO ) : <TAB> <TAB> <TAB> if not targetMO. HasValue or not all ( map ( lambda x : x. HasValue, argMOs ) ) : <TAB> <TAB> return self. Defer ( ( targetMO, ) + tuple ( argMOs ) ) <TAB> <TAB> isCom, com = ComBinder. TryBindGetIndex ( self, targetMO, argMOs ) <TAB> if isCom : <TAB> <TAB> return com <TAB> <TAB> if type ( targetMO. Value ) is Cons : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return errorSuggestionMO or CreateThrow ( <TAB> <TAB> <TAB> <TAB> targetMO, <TAB> <TAB> <TAB> <TAB> argMOs, <TAB> <TAB> <TAB> <TAB> BindingRestrictions. Empty, <TAB> <TAB> <TAB> <TAB> InvalidOperationException, <TAB> <TAB> <TAB> <TAB> "Indexing Sympl list requires exactly one argument.", <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> return DynamicMetaObject ( <TAB> <TAB> EnsureObjectResult ( GetIndexExpression ( targetMO, argMOs ) ), <TAB> <TAB> <TAB> <TAB> GetTargetArgsRestrictions ( targetMO, argMOs, False ), <TAB> ) | False | len(argMOs) != 1 | errorSuggestionMO | 0.6629995107650757 |
338 | 336 | def _find_completions ( self, doc, incomplete ) : <TAB> """Find completions for incomplete word and save them.""" <TAB> self. _completions = [ ] <TAB> self. _remains = [ ] <TAB> favorites = self. _favorite_words. get ( doc, ( ) ) <TAB> _all_words = set ( ( ) ) <TAB> for words in self. _all_words. itervalues ( ) : <TAB> <TAB> _all_words. update ( words ) <TAB> limit = self. _settings. max_completions_show <TAB> for sequence in ( favorites, _all_words ) : <TAB> <TAB> for word in sequence : <TAB> <TAB> <TAB> if not word. startswith ( incomplete ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if word == incomplete : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> self. _completions. append ( word ) <TAB> <TAB> <TAB> self. _remains. append ( word [ len ( incomplete ) : ] ) <TAB> <TAB> <TAB> if len ( self. _remains ) >= limit : <TAB> <TAB> <TAB> <TAB> break | False | word in self._completions | len(word) == 0 | 0.6740433573722839 |
339 | 337 | def run ( self ) : <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> with DelayedKeyboardInterrupt ( ) : <TAB> <TAB> <TAB> <TAB> raw_inputs = self. _parent_task_queue. get ( ) <TAB> <TAB> <TAB> <TAB> if self. _has_stop_signal ( raw_inputs ) : <TAB> <TAB> <TAB> <TAB> <TAB> self. _rq. put ( raw_inputs, block = True ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> if self. _flow_type == BATCH : <TAB> <TAB> <TAB> <TAB> <TAB> self. _rq. put ( raw_inputs, block = True ) <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _rq. put ( raw_inputs, block = False ) <TAB> <TAB> <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> except KeyboardInterrupt : <TAB> <TAB> <TAB> continue | False | self._flow_type == REALTIME | self._flow_type == DEBUG | 0.6589759588241577 |
340 | 338 | def run ( algs ) : <TAB> for alg in algs : <TAB> <TAB> vcs = alg. get ( "variantcaller" ) <TAB> <TAB> if vcs : <TAB> <TAB> <TAB> if isinstance ( vcs, dict ) : <TAB> <TAB> <TAB> <TAB> vcs = reduce ( operator. add, vcs. values ( ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> vcs = [ vcs ] <TAB> <TAB> <TAB> return any ( vc. startswith ( prefix ) for vc in vcs if vc ) | False | not isinstance(vcs, (list, tuple)) | isinstance(vcs, string_types) | 0.6504191160202026 |
341 | 339 | def getProperty ( self, name ) : <TAB> if name == handler. property_lexical_handler : <TAB> <TAB> return self. _lex_handler_prop <TAB> elif name == property_interning_dict : <TAB> <TAB> return self. _interning <TAB> elif name == property_xml_string : <TAB> <TAB> if self. _parser : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return self. _parser. GetInputContext ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise SAXNotRecognizedException ( <TAB> <TAB> <TAB> <TAB> <TAB> "This version of expat does not support getting" " the XML string" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise SAXNotSupportedException ( <TAB> <TAB> <TAB> <TAB> "XML string cannot be returned when not parsing" <TAB> <TAB> <TAB> ) <TAB> raise SAXNotRecognizedException ( "Property '%s' not recognized" % name ) | True | hasattr(self._parser, 'GetInputContext') | hasattr(self._parser, 'GetInputContext') | 0.6580386161804199 |
342 | 340 | def visible_settings ( self ) : <TAB> visible_settings = super ( RelateObjects, self ). visible_settings ( ) <TAB> visible_settings += [ <TAB> <TAB> self. wants_per_parent_means, <TAB> <TAB> self. find_parent_child_distances, <TAB> <TAB> self. wants_child_objects_saved, <TAB> ] <TAB> if self. wants_child_objects_saved : <TAB> <TAB> visible_settings += [ self. output_child_objects_name ] <TAB> if self. find_parent_child_distances!= D_NONE and self. has_step_parents : <TAB> <TAB> visible_settings += [ self. wants_step_parent_distances ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for group in self. step_parent_names : <TAB> <TAB> <TAB> <TAB> visible_settings += group. visible_settings ( ) <TAB> <TAB> <TAB> visible_settings += [ self. add_step_parent_button ] <TAB> return visible_settings | False | self.wants_step_parent_distances | self.has_step_parent_names | 0.6558775901794434 |
343 | 341 | def get_host_ipv6 ( with_nic = True ) : <TAB> nic_info = get_all_nic_info ( ) <TAB> ipv4 = get_host_ip ( ) <TAB> ipv6 = None <TAB> for nic, info in nic_info. items ( ) : <TAB> <TAB> ip4 = info [ "inet4" ] <TAB> <TAB> ip6 = info [ "inet6" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> ip4, ip6 = ip4. pop ( ), ip6. pop ( ) <TAB> <TAB> if ip4 == ipv4 : <TAB> <TAB> <TAB> ipv6 = ip6 if ip6 else None <TAB> <TAB> <TAB> if ipv6 and "%" not in ipv6 : <TAB> <TAB> <TAB> <TAB> ipv6 = ipv6 + "%" + nic <TAB> <TAB> <TAB> break <TAB> if ipv6 : <TAB> <TAB> if not with_nic : <TAB> <TAB> <TAB> ipv6 = ipv6. split ( "%" ) [ 0 ] <TAB> <TAB> return ipv6 | False | not all([ip4, ip6]) | ip4 and ip6 | 0.6592468023300171 |
344 | 342 | def _listVMsCallback ( self, result, ignore_error = False, error = False, ** kwargs ) : <TAB> if error : <TAB> <TAB> if "message" in result : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> QtWidgets. QMessageBox. critical ( <TAB> <TAB> <TAB> <TAB> <TAB> self, <TAB> <TAB> <TAB> <TAB> <TAB> "List vms", <TAB> <TAB> <TAB> <TAB> <TAB> "Error while listing vms: {}". format ( result [ "message" ] ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> return <TAB> if not sip_is_deleted ( self. uiVMListComboBox ) : <TAB> <TAB> self. uiVMListComboBox. clear ( ) <TAB> <TAB> for vm in result : <TAB> <TAB> <TAB> self. uiVMListComboBox. addItem ( vm [ "vmname" ], vm [ "vmname" ] ) <TAB> <TAB> index = self. uiVMListComboBox. findText ( self. _settings [ "vmname" ] ) <TAB> <TAB> if index == - 1 : <TAB> <TAB> <TAB> index = self. uiVMListComboBox. findText ( "GNS3 VM" ) <TAB> <TAB> <TAB> if index == - 1 : <TAB> <TAB> <TAB> <TAB> index = 0 <TAB> <TAB> self. uiVMListComboBox. setCurrentIndex ( index ) <TAB> <TAB> self. _initialized = True | False | not ignore_error | ignore_error | 0.65879887342453 |
345 | 343 | def get_library_dirs ( platform, arch = None ) : <TAB> if platform == "win32" : <TAB> <TAB> jre_home = get_jre_home ( platform ) <TAB> <TAB> jdk_home = JAVA_HOME <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> jre_home = jre_home. decode ( "utf-8" ) <TAB> <TAB> return [ join ( jdk_home, "lib" ), join ( jdk_home, "bin", "server" ) ] <TAB> elif platform == "android" : <TAB> <TAB> return [ "libs/{}". format ( arch ) ] <TAB> return [ ] | False | isinstance(jre_home, bytes) | jdk_home | 0.6489929556846619 |
346 | 344 | def transform ( self, data ) : <TAB> with timer ( "transform %s" % self. name, logging. DEBUG ) : <TAB> <TAB> if self. operator in { "lat", "latitude" } : <TAB> <TAB> <TAB> return self. series ( data ). apply ( GeoIP. get_latitude ) <TAB> <TAB> elif self. operator in { "lon", "longitude" } : <TAB> <TAB> <TAB> return self. series ( data ). apply ( GeoIP. get_longitude ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return self. series ( data ). apply ( GeoIP. get_accuracy ) <TAB> <TAB> raise NameError ( "Unknown GeoIP operator [lat, lon, acc]: %s" % self. operator ) | False | self.operator in {'acc', 'accuracy'} | self.operator in {'acc', 'longitude'} | 0.6575528383255005 |
347 | 345 | def parseFunctionSourceElements ( ) : <TAB> global strict <TAB> sourceElement = None <TAB> sourceElements = [ ] <TAB> token = None <TAB> directive = None <TAB> firstRestricted = None <TAB> oldLabelSet = None <TAB> oldInIteration = None <TAB> oldInSwitch = None <TAB> oldInFunctionBody = None <TAB> skipComment ( ) <TAB> delegate. markStart ( ) <TAB> expect ( "{" ) <TAB> while index < length : <TAB> <TAB> if lookahead. type!= Token. StringLiteral : <TAB> <TAB> <TAB> break <TAB> <TAB> token = lookahead <TAB> <TAB> sourceElement = parseSourceElement ( ) <TAB> <TAB> sourceElements. append ( sourceElement ) <TAB> <TAB> if sourceElement. expression. type!= Syntax. Literal : <TAB> <TAB> <TAB> break <TAB> <TAB> directive = source [ ( token. range [ 0 ] + 1 ) : ( token. range [ 1 ] - 1 ) ] <TAB> <TAB> if directive == "use strict" : <TAB> <TAB> <TAB> strict = True <TAB> <TAB> <TAB> if firstRestricted : <TAB> <TAB> <TAB> <TAB> throwErrorTolerant ( firstRestricted, Messages. StrictOctalLiteral ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if ( not firstRestricted ) and token. octal : <TAB> <TAB> <TAB> <TAB> firstRestricted = token <TAB> oldLabelSet = state. labelSet <TAB> oldInIteration = state. inIteration <TAB> oldInSwitch = state. inSwitch <TAB> oldInFunctionBody = state. inFunctionBody <TAB> state. labelSet = jsdict ( { } ) <TAB> state. inIteration = False <TAB> state. inSwitch = False <TAB> state. inFunctionBody = True <TAB> while index < length : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> sourceElement = parseSourceElement ( ) <TAB> <TAB> if ( <TAB> <TAB> <TAB> "undefined" if not "sourceElement" in locals ( ) else typeof ( sourceElement ) | False | match('}') | sourceElement.expression.type != Token.StringLiteral | 0.6626948118209839 |
348 | 346 | def publish ( self, channel, * args, ** kwargs ) : <TAB> """Return output of all subscribers for the given channel.""" <TAB> if channel not in self. listeners : <TAB> <TAB> return [ ] <TAB> exc = ChannelFailures ( ) <TAB> output = [ ] <TAB> items = [ <TAB> <TAB> ( self. _priorities [ ( channel, listener ) ], listener ) <TAB> <TAB> for listener in self. listeners [ channel ] <TAB> ] <TAB> try : <TAB> <TAB> items. sort ( key = lambda item : item [ 0 ] ) <TAB> except TypeError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> items. sort ( ) <TAB> for priority, listener in items : <TAB> <TAB> try : <TAB> <TAB> <TAB> output. append ( listener ( * args, ** kwargs ) ) <TAB> <TAB> except KeyboardInterrupt : <TAB> <TAB> <TAB> raise <TAB> <TAB> except SystemExit : <TAB> <TAB> <TAB> e = sys. exc_info ( ) [ 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> e. code = 1 <TAB> <TAB> <TAB> raise <TAB> <TAB> except : <TAB> <TAB> <TAB> exc. handle_exception ( ) <TAB> <TAB> <TAB> if channel == "log" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. log ( <TAB> <TAB> <TAB> <TAB> <TAB> "Error in %r listener %r" % ( channel, listener ), <TAB> <TAB> <TAB> <TAB> <TAB> level = 40, <TAB> <TAB> <TAB> <TAB> <TAB> traceback = True, <TAB> <TAB> <TAB> <TAB> ) <TAB> if exc : <TAB> <TAB> raise exc <TAB> return output | False | exc and e.code == 0 | e | 0.6606873273849487 |
349 | 347 | def bitcoin_done ( request ) : <TAB> with mock. patch ( "bitcoinrpc.connection.BitcoinConnection" ) as MockBitcoinConnection : <TAB> <TAB> connection = MockBitcoinConnection ( ) <TAB> <TAB> connection. getnewaddress. return_value = BTC_TEST_ADDRESS <TAB> <TAB> connection. listtransactions. return_value = BTC_TEST_SUCCESSFUL_TXNS <TAB> <TAB> amount = 0.01 <TAB> <TAB> bitcoin_obj = get_gateway ( "bitcoin" ) <TAB> <TAB> address = request. session. get ( "bitcoin_address", None ) <TAB> <TAB> if not address : <TAB> <TAB> <TAB> return HttpResponseRedirect ( reverse ( "app_bitcoin" ) ) <TAB> <TAB> result = bitcoin_obj. purchase ( amount, address ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> del request. session [ "bitcoin_address" ] <TAB> <TAB> return render ( <TAB> <TAB> <TAB> request, <TAB> <TAB> <TAB> "app/bitcoin_done.html", <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> "title" : "Bitcoin", <TAB> <TAB> <TAB> <TAB> "amount" : amount, <TAB> <TAB> <TAB> <TAB> "address" : address, <TAB> <TAB> <TAB> <TAB> "result" : result, <TAB> <TAB> <TAB> }, <TAB> <TAB> ) | False | result['status'] == 'SUCCESS' | result | 0.6622365713119507 |
350 | 348 | def ensemble ( self, pairs, other_preds ) : <TAB> """Ensemble the dict with statistical model predictions.""" <TAB> lemmas = [ ] <TAB> assert len ( pairs ) == len ( other_preds ) <TAB> for p, pred in zip ( pairs, other_preds ) : <TAB> <TAB> w, pos = p <TAB> <TAB> if ( w, pos ) in self. composite_dict : <TAB> <TAB> <TAB> lemma = self. composite_dict [ ( w, pos ) ] <TAB> <TAB> elif w in self. word_dict : <TAB> <TAB> <TAB> lemma = self. word_dict [ w ] <TAB> <TAB> else : <TAB> <TAB> <TAB> lemma = pred <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> lemma = w <TAB> <TAB> lemmas. append ( lemma ) <TAB> return lemmas | False | lemma is None | lemma is not None | 0.6770522594451904 |
351 | 349 | def __editorKeyPress ( editor, event ) : <TAB> if event. key == "B" : <TAB> <TAB> __findBookmark ( editor ) <TAB> <TAB> return True <TAB> if event. key in [ str ( x ) for x in range ( 0, 10 ) ] : <TAB> <TAB> numericBookmark = int ( event. key ) <TAB> <TAB> if event. modifiers == event. modifiers. Control : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> node = None <TAB> <TAB> <TAB> if isinstance ( editor, GafferUI. GraphEditor ) : <TAB> <TAB> <TAB> <TAB> selection = editor. scriptNode ( ). selection ( ) <TAB> <TAB> <TAB> <TAB> if len ( selection ) == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> node = selection [ 0 ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> backdrops = [ n for n in selection if isinstance ( n, Gaffer. Backdrop ) ] <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> node = backdrops [ 0 ] <TAB> <TAB> <TAB> elif isinstance ( editor, GafferUI. NodeSetEditor ) : <TAB> <TAB> <TAB> <TAB> nodeSet = editor. getNodeSet ( ) <TAB> <TAB> <TAB> <TAB> node = nodeSet [ - 1 ] if len ( nodeSet ) else None <TAB> <TAB> <TAB> if node is not None : <TAB> <TAB> <TAB> <TAB> __assignNumericBookmark ( node, numericBookmark ) <TAB> <TAB> elif not event. modifiers : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if numericBookmark!= 0 : <TAB> <TAB> <TAB> <TAB> __findNumericBookmark ( editor, numericBookmark ) <TAB> <TAB> <TAB> elif isinstance ( editor, GafferUI. Node | False | len(backdrops) == 1 | len(backdrops) > 0 | 0.6597782373428345 |
352 | 350 | def kc_pressed ( self, key, modifierFlags ) : <TAB> if modifierFlags == CTRL_KEY_FLAG : <TAB> <TAB> if key == "C" : <TAB> <TAB> <TAB> self. send ( "\x03" ) <TAB> <TAB> <TAB> self. telnet. running = False <TAB> <TAB> elif key == "D" : <TAB> <TAB> <TAB> self. send ( "\x04" ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. send ( "\x01" ) <TAB> <TAB> elif key == "E" : <TAB> <TAB> <TAB> self. send ( "\x05" ) <TAB> <TAB> elif key == "K" : <TAB> <TAB> <TAB> self. send ( "\x0B" ) <TAB> <TAB> elif key == "L" : <TAB> <TAB> <TAB> self. send ( "\x0C" ) <TAB> <TAB> elif key == "U" : <TAB> <TAB> <TAB> self. send ( "\x15" ) <TAB> <TAB> elif key == "Z" : <TAB> <TAB> <TAB> self. send ( "\x1A" ) <TAB> <TAB> elif key == "[" : <TAB> <TAB> <TAB> self. send ( "\x1B" ) <TAB> elif modifierFlags == 0 : <TAB> <TAB> if key == "UIKeyInputUpArrow" : <TAB> <TAB> <TAB> self. send ( "\x10" ) <TAB> <TAB> elif key == "UIKeyInputDownArrow" : <TAB> <TAB> <TAB> self. send ( "\x0E" ) <TAB> <TAB> elif key == "UIKeyInputLeftArrow" : <TAB> <TAB> <TAB> self. send ( "\033[D" ) <TAB> <TAB> elif key == "UIKeyInputRightArrow" : <TAB> <TAB> <TAB> self. send ( "\033[C" ) | False | key == 'A' | key == 'M' | 0.6609237194061279 |
353 | 351 | def starttag ( self, quoteattr = None ) : <TAB> <TAB> if quoteattr is None : <TAB> <TAB> quoteattr = pseudo_quoteattr <TAB> parts = [ self. tagname ] <TAB> for name, value in self. attlist ( ) : <TAB> <TAB> if value is None : <TAB> <TAB> <TAB> parts. append ( '%s="True"' % name ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> values = [ serial_escape ( "%s" % ( v, ) ) for v in value ] <TAB> <TAB> <TAB> value = " ". join ( values ) <TAB> <TAB> else : <TAB> <TAB> <TAB> value = unicode ( value ) <TAB> <TAB> value = quoteattr ( value ) <TAB> <TAB> parts. append ( u"%s=%s" % ( name, value ) ) <TAB> return u"<%s>" % u" ". join ( parts ) | False | isinstance(value, list) | isinstance(value, basestring) | 0.6511034965515137 |
354 | 352 | def get_tag_values ( self, event ) : <TAB> http = event. interfaces. get ( "sentry.interfaces.Http" ) <TAB> if not http : <TAB> <TAB> return [ ] <TAB> if not http. headers : <TAB> <TAB> return [ ] <TAB> headers = http. headers <TAB> <TAB> if isinstance ( headers, dict ) : <TAB> <TAB> headers = headers. items ( ) <TAB> output = [ ] <TAB> for key, value in headers : <TAB> <TAB> if key!= "User-Agent" : <TAB> <TAB> <TAB> continue <TAB> <TAB> ua = Parse ( value ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> result = self. get_tag_from_ua ( ua ) <TAB> <TAB> if result : <TAB> <TAB> <TAB> output. append ( result ) <TAB> return output | False | not ua | ua | 0.7112003564834595 |
355 | 353 | def post ( self ) : <TAB> old = self. _fetch_existing_config ( ) <TAB> new = dict ( ) <TAB> for key in self. ALLOWED. keys ( ) : <TAB> <TAB> if self. ALLOWED [ key ] == bool : <TAB> <TAB> <TAB> val = self. get_argument ( key, False ) <TAB> <TAB> else : <TAB> <TAB> <TAB> val = self. get_argument ( key, None ) <TAB> <TAB> if val is None or val == "" : <TAB> <TAB> <TAB> new [ key ] = old [ key ] <TAB> <TAB> elif key == "pwdhash" : <TAB> <TAB> <TAB> new [ key ] = bcrypt. hashpw ( val, bcrypt. gensalt ( ) ) <TAB> <TAB> el if<mask> : <TAB> <TAB> <TAB> new [ key ] = str ( val ) <TAB> <TAB> elif self. ALLOWED [ key ] == int : <TAB> <TAB> <TAB> new [ key ] = int ( val ) <TAB> <TAB> elif self. ALLOWED [ key ] == bool : <TAB> <TAB> <TAB> new [ key ] = bool ( val ) <TAB> config_file = open ( self. settings. config_path. web, "w" ) <TAB> for key, val in new. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> config_file. write ( "%s='%s'\n" % ( key, val ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> config_file. write ( "%s=%s\n" % ( key, val ) ) <TAB> config_file. close ( ) <TAB> self. redirect ( "/" ) | True | self.ALLOWED[key] == str | self.ALLOWED[key] == str | 0.659371554851532 |
356 | 354 | def check_samplers_fit_resample ( name, sampler_orig ) : <TAB> sampler = clone ( sampler_orig ) <TAB> X, y = make_classification ( <TAB> <TAB> n_samples = 1000, <TAB> <TAB> n_classes = 3, <TAB> <TAB> n_informative = 4, <TAB> <TAB> weights = [ 0.2, 0.3, 0.5 ], <TAB> <TAB> random_state = 0, <TAB> ) <TAB> target_stats = Counter ( y ) <TAB> X_res, y_res = sampler. fit_resample ( X, y ) <TAB> if isinstance ( sampler, BaseOverSampler ) : <TAB> <TAB> target_stats_res = Counter ( y_res ) <TAB> <TAB> n_samples = max ( target_stats. values ( ) ) <TAB> <TAB> assert all ( value >= n_samples for value in Counter ( y_res ). values ( ) ) <TAB> elif isinstance ( sampler, BaseUnderSampler ) : <TAB> <TAB> n_samples = min ( target_stats. values ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> assert all ( <TAB> <TAB> <TAB> <TAB> Counter ( y_res ) [ k ] <= target_stats [ k ] for k in target_stats. keys ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> assert all ( value == n_samples for value in Counter ( y_res ). values ( ) ) <TAB> elif isinstance ( sampler, BaseCleaningSampler ) : <TAB> <TAB> target_stats_res = Counter ( y_res ) <TAB> <TAB> class_minority = min ( target_stats, key = target_stats. get ) <TAB> <TAB> assert all ( <TAB> <TAB> <TAB> target_stats [ class_sample ] > target_stats_res [ class_sample ] <TAB> <TAB> <TAB> for class_sample in target_stats. keys ( ) <TAB> <TAB> < | False | name == 'InstanceHardnessThreshold' | isinstance(sampler, BaseMultiSampler) | 0.6591370701789856 |
357 | 355 | def preprocess_raw_enwik9 ( input_filename, output_filename ) : <TAB> with open ( input_filename, "r" ) as f1 : <TAB> <TAB> with open ( output_filename, "w" ) as f2 : <TAB> <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> line = f1. readline ( ) <TAB> <TAB> <TAB> <TAB> if not line : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> line = list ( enwik9_norm_transform ( [ line ] ) ) [ 0 ] <TAB> <TAB> <TAB> <TAB> if line!= " " and line!= "" : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> line = line [ 1 : ] <TAB> <TAB> <TAB> <TAB> <TAB> f2. writelines ( line + "\n" ) | False | line[0] == '' | line.startswith('<TAB > <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> < | 0.6549445390701294 |
358 | 356 | def __setitem__ ( self, key, value ) : <TAB> if isinstance ( value, ( tuple, list ) ) : <TAB> <TAB> info, reference = value <TAB> <TAB> if info not in self. _reverse_infos : <TAB> <TAB> <TAB> self. _reverse_infos [ info ] = len ( self. _infos ) <TAB> <TAB> <TAB> self. _infos. append ( info ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _reverse_references [ reference ] = len ( self. _references ) <TAB> <TAB> <TAB> self. _references. append ( reference ) <TAB> <TAB> self. _trails [ key ] = "%d,%d" % ( <TAB> <TAB> <TAB> self. _reverse_infos [ info ], <TAB> <TAB> <TAB> self. _reverse_references [ reference ], <TAB> <TAB> ) <TAB> else : <TAB> <TAB> raise Exception ( "unsupported type '%s'" % type ( value ) ) | False | reference not in self._reverse_references | reference not in self._trails | 0.664270281791687 |
359 | 357 | def init ( self, view, items = None ) : <TAB> selections = [ ] <TAB> if view. sel ( ) : <TAB> <TAB> for region in view. sel ( ) : <TAB> <TAB> <TAB> selections. append ( view. substr ( region ) ) <TAB> values = [ ] <TAB> for idx, index in enumerate ( map ( int, items ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> i = index - 1 <TAB> <TAB> if i >= 0 and i < len ( selections ) : <TAB> <TAB> <TAB> values. append ( selections [ i ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> values. append ( None ) <TAB> <TAB> for idx, value in enumerate ( selections ) : <TAB> <TAB> if len ( values ) + 1 < idx : <TAB> <TAB> <TAB> values. append ( value ) <TAB> self. stack = values | False | idx >= len(selections) | index == 0 | 0.657119631767273 |
360 | 358 | def viewrendered ( event ) : <TAB> """Open render view for commander""" <TAB> c = event. get ( "c" ) <TAB> if not c : <TAB> <TAB> return None <TAB> global controllers, layouts <TAB> vr = controllers. get ( c. hash ( ) ) <TAB> if vr : <TAB> <TAB> vr. activate ( ) <TAB> <TAB> vr. show ( ) <TAB> <TAB> vr. adjust_layout ( "open" ) <TAB> else : <TAB> <TAB> h = c. hash ( ) <TAB> <TAB> controllers [ h ] = vr = ViewRenderedController ( c ) <TAB> <TAB> layouts [ h ] = c. db. get ( "viewrendered_default_layouts", ( None, None ) ) <TAB> <TAB> if hasattr ( c, "free_layout" ) : <TAB> <TAB> <TAB> vr. _ns_id = "_leo_viewrendered" <TAB> <TAB> <TAB> vr. splitter = splitter = c. free_layout. get_top_splitter ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if splitter : <TAB> <TAB> <TAB> <TAB> vr. store_layout ( "closed" ) <TAB> <TAB> <TAB> <TAB> sizes = split_last_sizes ( splitter. sizes ( ) ) <TAB> <TAB> <TAB> <TAB> ok = splitter. add_adjacent ( vr, "bodyFrame", "right-of" ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> splitter. insert ( 0, vr ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> if splitter. orientation ( ) == QtCore. Qt. Horizontal : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> splitter. setSizes ( sizes ) <TAB> <TAB> <TAB> <TAB> vr. adjust_layout ( "open" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> vr. setWindowTitle ( "Rendered View" ) < | False | not ok | ok | 0.6844743490219116 |
361 | 359 | def _stringify ( value ) : <TAB> """Internal function.""" <TAB> if isinstance ( value, ( list, tuple ) ) : <TAB> <TAB> if len ( value ) == 1 : <TAB> <TAB> <TAB> value = _stringify ( value [ 0 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> value = "{%s}" % value <TAB> <TAB> else : <TAB> <TAB> <TAB> value = "{%s}" % _join ( value ) <TAB> else : <TAB> <TAB> if isinstance ( value, basestring ) : <TAB> <TAB> <TAB> value = unicode ( value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> value = str ( value ) <TAB> <TAB> if not value : <TAB> <TAB> <TAB> value = "{}" <TAB> <TAB> elif _magic_re. search ( value ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> value = _magic_re. sub ( r"\\\1", value ) <TAB> <TAB> <TAB> value = _space_re. sub ( r"\\\1", value ) <TAB> <TAB> elif value [ 0 ] == '"' or _space_re. search ( value ) : <TAB> <TAB> <TAB> value = "{%s}" % value <TAB> return value | False | value[0] == '{' | isinstance(value, dict) | 0.6642587184906006 |
362 | 360 | def __init__ ( <TAB> self, <TAB> host : str, <TAB> port : int, <TAB> app : "WSGIApplication", <TAB> handler : t. Optional [ t. Type [ WSGIRequestHandler ] ] = None, <TAB> passthrough_errors : bool = False, <TAB> ssl_context : t. Optional [ _TSSLContextArg ] = None, <TAB> fd : t. Optional [ int ] = None, ) -> None : <TAB> if handler is None : <TAB> <TAB> handler = WSGIRequestHandler <TAB> self. address_family = select_address_family ( host, port ) <TAB> if fd is not None : <TAB> <TAB> real_sock = socket. fromfd ( fd, self. address_family, socket. SOCK_STREAM ) <TAB> <TAB> port = 0 <TAB> server_address = get_sockaddr ( host, int ( port ), self. address_family ) <TAB> <TAB> if self. address_family == af_unix : <TAB> <TAB> server_address = t. cast ( str, server_address ) <TAB> <TAB> if os. path. exists ( server_address ) : <TAB> <TAB> <TAB> os. unlink ( server_address ) <TAB> super ( ). __init__ ( server_address, handler ) <TAB> self. app = app <TAB> self. passthrough_errors = passthrough_errors <TAB> self. shutdown_signal = False <TAB> self. host = host <TAB> self. port = self. socket. getsockname ( ) [ 1 ] <TAB> <TAB> if fd is not None : <TAB> <TAB> self. socket. close ( ) <TAB> <TAB> self. socket = real_sock <TAB> <TAB> self. server_address = self. socket. getsockname ( ) <TAB> if ssl_context is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ssl_context = load_ssl_context ( * ssl_context ) <TAB> <TAB> if ssl_context == "adhoc" : <TAB> <TAB> <TAB> ssl_context = generate_adhoc_ssl_context ( ) <TAB | False | isinstance(ssl_context, tuple) | ssl_context == 'load' | 0.6463333964347839 |
363 | 361 | def _handle_server_unmutes ( self ) : <TAB> """This is where the logic for role unmutes is taken care of""" <TAB> log. debug ( "Checking server unmutes" ) <TAB> for g_id in self. _server_mutes : <TAB> <TAB> guild = self. bot. get_guild ( g_id ) <TAB> <TAB> if guild is None or await self. bot. cog_disabled_in_guild ( self, guild ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> await i18n. set_contextual_locales_from_guild ( self. bot, guild ) <TAB> <TAB> for u_id in self. _server_mutes [ guild. id ] : <TAB> <TAB> <TAB> if self. _server_mutes [ guild. id ] [ u_id ] [ "until" ] is None : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> time_to_unmute = ( <TAB> <TAB> <TAB> <TAB> self. _server_mutes [ guild. id ] [ u_id ] [ "until" ] <TAB> <TAB> <TAB> <TAB> - datetime. now ( timezone. utc ). timestamp ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if time_to_unmute < 60.0 : <TAB> <TAB> <TAB> <TAB> task_name = f"server-unmute-{g_id}-{u_id}" <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> log. debug ( f"Creating task: {task_name}" ) <TAB> <TAB> <TAB> <TAB> self. _unmute_tasks [ task_name ] = asyncio. create_task ( <TAB> <TAB> <TAB> <TAB> <TAB> self. _auto_unmute_user ( guild, self. _server_mutes [ guild. id ] [ u_id ] ) <TAB> <TAB> <TAB> | False | task_name in self._unmute_tasks | task_name not in self._unmute_tasks | 0.6589851975440979 |
364 | 362 | def indent ( elem, level = 0 ) : <TAB> i = "\n" + level * " " <TAB> if len ( elem ) : <TAB> <TAB> if not elem. text or not elem. text. strip ( ) : <TAB> <TAB> <TAB> elem. text = i + " " <TAB> <TAB> if not elem. tail or not elem. tail. strip ( ) : <TAB> <TAB> <TAB> elem. tail = i <TAB> <TAB> for elem in elem : <TAB> <TAB> <TAB> indent ( elem, level + 1 ) <TAB> <TAB> if not elem. tail or not elem. tail. strip ( ) : <TAB> <TAB> <TAB> elem. tail = i <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> elem. tail = i | False | level and (not elem.tail or not elem.tail.strip()) | len(elem.tail) | 0.6508496403694153 |
365 | 363 | def pg_launcher ( pre_created_pgs, num_pgs_to_create ) : <TAB> pgs = [ ] <TAB> pgs += pre_created_pgs <TAB> for i in range ( num_pgs_to_create ) : <TAB> <TAB> pgs. append ( placement_group ( bundles, strategy = "STRICT_SPREAD", name = str ( i ) ) ) <TAB> pgs_removed = [ ] <TAB> pgs_unremoved = [ ] <TAB> <TAB> for pg in pgs : <TAB> <TAB> if random ( ) < 0.5 : <TAB> <TAB> <TAB> pgs_removed. append ( pg ) <TAB> <TAB> else : <TAB> <TAB> <TAB> pgs_unremoved. append ( pg ) <TAB> tasks = [ ] <TAB> max_actor_cnt = 5 <TAB> actor_cnt = 0 <TAB> actors = [ ] <TAB> <TAB> <TAB> for pg in pgs_unremoved : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if random ( ) < 0.5 : <TAB> <TAB> <TAB> tasks. append ( mock_task. options ( placement_group = pg ). remote ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> actors. append ( MockActor. options ( placement_group = pg ). remote ( ) ) <TAB> <TAB> <TAB> <TAB> actor_cnt += 1 <TAB> <TAB> for pg in pgs_removed : <TAB> <TAB> remove_placement_group ( pg ) <TAB> ray. get ( [ pg. ready ( ) for pg in pgs_unremoved ] ) <TAB> ray. get ( tasks ) <TAB> ray. get ( [ actor. ping. remote ( ) for actor in actors ] ) <TAB> <TAB> for pg in pgs_unremoved : <TAB> <TAB> remove_placement_group ( pg ) | False | actor_cnt < max_actor_cnt | random() < 0.5 | 0.6598740816116333 |
366 | 364 | def _find_names ( self, lr_schedulers ) -> List [ str ] : <TAB> <TAB> <TAB> names = [ ] <TAB> for scheduler in lr_schedulers : <TAB> <TAB> sch = scheduler [ "scheduler" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name = scheduler [ "name" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> opt_name = "lr-" + sch. optimizer. __class__. __name__ <TAB> <TAB> <TAB> i, name = 1, opt_name <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> if name not in names : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> i, name = i + 1, f"{opt_name}-{i}" <TAB> <TAB> <TAB> <TAB> param_groups = sch. optimizer. param_groups <TAB> <TAB> if len ( param_groups )!= 1 : <TAB> <TAB> <TAB> for i, pg in enumerate ( param_groups ) : <TAB> <TAB> <TAB> <TAB> temp = f"{name}/pg{i + 1}" <TAB> <TAB> <TAB> <TAB> names. append ( temp ) <TAB> <TAB> else : <TAB> <TAB> <TAB> names. append ( name ) <TAB> <TAB> self. lr_sch_names. append ( name ) <TAB> return names | False | scheduler['name'] is not None | sch.has_option | 0.6601338386535645 |
367 | 365 | def _adjust_to_data ( self, trace, data_trace ) : <TAB> subsampled_idxs = dict ( ) <TAB> for name, site in trace. iter_stochastic_nodes ( ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> site [ "fn" ] = data_trace. nodes [ name ] [ "fn" ] <TAB> <TAB> <TAB> site [ "value" ] = data_trace. nodes [ name ] [ "value" ] <TAB> <TAB> <TAB> <TAB> orig_cis_stack = site [ "cond_indep_stack" ] <TAB> <TAB> site [ "cond_indep_stack" ] = data_trace. nodes [ name ] [ "cond_indep_stack" ] <TAB> <TAB> assert len ( orig_cis_stack ) == len ( site [ "cond_indep_stack" ] ) <TAB> <TAB> site [ "fn" ] = data_trace. nodes [ name ] [ "fn" ] <TAB> <TAB> for ocis, cis in zip ( orig_cis_stack, site [ "cond_indep_stack" ] ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> assert ocis. name == cis. name <TAB> <TAB> <TAB> assert not site_is_subsample ( site ) <TAB> <TAB> <TAB> batch_dim = cis. dim - site [ "fn" ]. event_dim <TAB> <TAB> <TAB> subsampled_idxs [ cis. name ] = subsampled_idxs. get ( <TAB> <TAB> <TAB> <TAB> cis. name, <TAB> <TAB> <TAB> <TAB> torch. randint ( 0, ocis. size, ( cis. size, ), device = site [ "value" ]. device ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> site [ "value" ] = site [ "value" ]. index_select ( <TAB> <TAB> <TAB> <TAB> batch_ | False | site_is_subsample(site) | name in data_trace.nodes | 0.6477853059768677 |
368 | 366 | def deserialize ( self, data ) : <TAB> parts = data. pop ( "parts" ) <TAB> self. parts = { } <TAB> self. __dict__. update ( data ) <TAB> if parts : <TAB> <TAB> for part_id, part in six. iteritems ( parts ) : <TAB> <TAB> <TAB> self. parts [ part_id ] = { } <TAB> <TAB> <TAB> for language, sub_data in six. iteritems ( part ) : <TAB> <TAB> <TAB> <TAB> self. parts [ part_id ] [ language ] = { } <TAB> <TAB> <TAB> <TAB> for sub_key, subtitle_data in six. iteritems ( sub_data ) : <TAB> <TAB> <TAB> <TAB> <TAB> if sub_key == "current" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> subtitle_data = tuple ( subtitle_data. split ( "__" ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. parts [ part_id ] [ language ] [ "current" ] = subtitle_data <TAB> <TAB> <TAB> <TAB> <TAB> elif sub_key == "blacklist" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> bl = dict ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ( tuple ( [ str ( a ) for a in k. split ( "__" ) ] ), v ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for k, v in six. iteritems ( subtitle_data ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. parts [ part_id ] [ language ] [ "blacklist" ] = bl <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sub = JSONStoredSubtitle ( ) | False | not isinstance(subtitle_data, tuple) | subtitle_data | 0.6483365297317505 |
369 | 367 | def get_php_interpreter_path ( ver ) : <TAB> config = get_config ( ) <TAB> candidates = [ <TAB> <TAB> join ( config. phpsBaseDir, ver + "*" ), <TAB> <TAB> join ( config. phpsBaseDir, "php-%s*" % ver ), <TAB> ] <TAB> for pattern in candidates : <TAB> <TAB> base_dirs = glob ( pattern ) <TAB> <TAB> if base_dirs : <TAB> <TAB> <TAB> base_dir = base_dirs [ 0 ] <TAB> <TAB> <TAB> break <TAB> else : <TAB> <TAB> import subprocess <TAB> <TAB> <TAB> <TAB> exe_paths = findPathsForInterpreters ( [ "php" ], "PHP" ) <TAB> <TAB> for exe in exe_paths : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> p = subprocess. Popen ( <TAB> <TAB> <TAB> <TAB> <TAB> [ exe, "-r", "echo phpversion();" ], stdout = subprocess. PIPE <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> stdout, _ = p. communicate ( ) <TAB> <TAB> <TAB> <TAB> if stdout. strip ( ). startswith ( ver ) : <TAB> <TAB> <TAB> <TAB> <TAB> return exe <TAB> <TAB> <TAB> except IOError : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> raise TestSkipped ( <TAB> <TAB> <TAB> "could not find PHP %s for testing: '%s' don't " <TAB> <TAB> <TAB> "exist" % ( ver, "', '". join ( candidates ) ) <TAB> <TAB> ) <TAB> if sys. platform == "win32" : <TAB> <TAB> candidates = [ <TAB> <TAB> <TAB> join ( base_dir, "php.exe" ), <TAB> <TAB> <TAB> join ( base_dir, "Release_TS", "php.exe" ), <TAB> <TAB> ] <TAB> < | False | exists(candidate) | len(candidates) > 0 | 0.6603810787200928 |
370 | 368 | def __getitem__ ( self, name, set = set, getattr = getattr, id = id ) : <TAB> visited = set ( ) <TAB> mydict = self. basedict <TAB> while 1 : <TAB> <TAB> value = mydict [ name ] <TAB> <TAB> if value is not None : <TAB> <TAB> <TAB> return value <TAB> <TAB> myid = id ( mydict ) <TAB> <TAB> assert myid not in visited <TAB> <TAB> visited. add ( myid ) <TAB> <TAB> mydict = mydict. Parent <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return | False | mydict is None | myid not in visited | 0.6602520942687988 |
371 | 369 | def selectionToChunks ( self, remove = False, add = False ) : <TAB> box = self. selectionBox ( ) <TAB> if box : <TAB> <TAB> if box == self. level. bounds : <TAB> <TAB> <TAB> self. selectedChunks = set ( self. level. allChunks ) <TAB> <TAB> <TAB> return <TAB> <TAB> selectedChunks = self. selectedChunks <TAB> <TAB> boxedChunks = set ( box. chunkPositions ) <TAB> <TAB> if boxedChunks. issubset ( selectedChunks ) : <TAB> <TAB> <TAB> remove = True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> selectedChunks. difference_update ( boxedChunks ) <TAB> <TAB> else : <TAB> <TAB> <TAB> selectedChunks. update ( boxedChunks ) <TAB> self. selectionTool. selectNone ( ) | False | remove and (not add) | remove | 0.6538796424865723 |
372 | 370 | def change_opacity_function ( self, new_f ) : <TAB> self. opacity_function = new_f <TAB> dr = self. radius / self. num_levels <TAB> sectors = [ ] <TAB> for submob in self. submobjects : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sectors. append ( submob ) <TAB> for ( r, submob ) in zip ( np. arange ( 0, self. radius, dr ), sectors ) : <TAB> <TAB> if type ( submob )!= AnnularSector : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> alpha = self. opacity_function ( r ) <TAB> <TAB> submob. set_fill ( opacity = alpha ) | False | type(submob) == AnnularSector | type(submob) != AnnularSector | 0.6634690165519714 |
373 | 371 | def addOutput ( self, data, isAsync = None, ** kwargs ) : <TAB> isAsync = _get_async_param ( isAsync, ** kwargs ) <TAB> if isAsync : <TAB> <TAB> self. terminal. eraseLine ( ) <TAB> <TAB> self. terminal. cursorBackward ( len ( self. lineBuffer ) + len ( self. ps [ self. pn ] ) ) <TAB> self. terminal. write ( data ) <TAB> if isAsync : <TAB> <TAB> if self. _needsNewline ( ) : <TAB> <TAB> <TAB> self. terminal. nextLine ( ) <TAB> <TAB> self. terminal. write ( self. ps [ self. pn ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> oldBuffer = self. lineBuffer <TAB> <TAB> <TAB> self. lineBuffer = [ ] <TAB> <TAB> <TAB> self. lineBufferIndex = 0 <TAB> <TAB> <TAB> self. _deliverBuffer ( oldBuffer ) | True | self.lineBuffer | self.lineBuffer | 0.6624734401702881 |
374 | 372 | def testSimple ( self, useCluster = False ) : <TAB> """Run with one really bad swarm to see if terminator picks it up correctly""" <TAB> if not g_myEnv. options. runInProc : <TAB> <TAB> self. skipTest ( "Skipping One Node test since runInProc is not specified" ) <TAB> self. _printTestHeader ( ) <TAB> expDir = os. path. join ( g_myEnv. testSrcExpDir, "swarm_v2" ) <TAB> ( jobID, jobInfo, resultInfos, metricResults, minErrScore ) = self. runPermutations ( <TAB> <TAB> expDir, <TAB> <TAB> hsImp = "v2", <TAB> <TAB> loggingLevel = g_myEnv. options. logLevel, <TAB> <TAB> maxModels = None, <TAB> <TAB> onCluster = useCluster, <TAB> <TAB> env = self. env, <TAB> <TAB> dummyModel = { "iterations" : 200 }, <TAB> ) <TAB> cjDB = ClientJobsDAO. get ( ) <TAB> jobResultsStr = cjDB. jobGetFields ( jobID, [ "results" ] ) [ 0 ] <TAB> jobResults = json. loads ( jobResultsStr ) <TAB> terminatedSwarms = jobResults [ "terminatedSwarms" ] <TAB> swarmMaturityWindow = int ( <TAB> <TAB> configuration. Configuration. get ( "nupic.hypersearch.swarmMaturityWindow" ) <TAB> ) <TAB> prefix = "modelParams|sensorParams|encoders|" <TAB> for swarm, ( generation, scores ) in terminatedSwarms. iteritems ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( generation, swarmMaturityWindow - 1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. assertEqual ( generation, swarmMaturityWindow - 1 + 4 ) | False | prefix + 'gym' in swarm.split('.') | useCluster | 0.650718092918396 |
375 | 373 | def fit ( self, dataset, force_retrain ) : <TAB> if force_retrain : <TAB> <TAB> self. sub_unit_1 [ "fitted" ] = True <TAB> <TAB> self. sub_unit_1 [ "calls" ] += 1 <TAB> <TAB> self. sub_unit_2 [ "fitted" ] = True <TAB> <TAB> self. sub_unit_2 [ "calls" ] += 1 <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. sub_unit_1 [ "fitted" ] = True <TAB> <TAB> <TAB> self. sub_unit_1 [ "calls" ] += 1 <TAB> <TAB> if not self. sub_unit_2 [ "fitted" ] : <TAB> <TAB> <TAB> self. sub_unit_2 [ "fitted" ] = True <TAB> <TAB> <TAB> self. sub_unit_2 [ "calls" ] += 1 <TAB> return self | True | not self.sub_unit_1['fitted'] | not self.sub_unit_1['fitted'] | 0.6576662063598633 |
376 | 374 | def event_cb ( self, widget, event ) : <TAB> if event. type == Gdk. EventType. EXPOSE : <TAB> <TAB> return False <TAB> msg = self. event2str ( widget, event ) <TAB> motion_reports_limit = 5 <TAB> if event. type == Gdk. EventType. MOTION_NOTIFY : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dt = event. time - self. last_motion_time <TAB> <TAB> <TAB> self. motion_event_counter += 1 <TAB> <TAB> <TAB> self. motion_dtime_sample. append ( dt ) <TAB> <TAB> <TAB> self. motion_dtime_sample = self. motion_dtime_sample [ - 10 : ] <TAB> <TAB> <TAB> self. last_motion_time = event. time <TAB> <TAB> <TAB> <TAB> if len ( self. motion_reports ) < motion_reports_limit : <TAB> <TAB> <TAB> self. report ( msg ) <TAB> <TAB> self. motion_reports. append ( msg ) <TAB> else : <TAB> <TAB> unreported = self. motion_reports [ motion_reports_limit : ] <TAB> <TAB> if unreported : <TAB> <TAB> <TAB> last_report = unreported. pop ( ) <TAB> <TAB> <TAB> if unreported : <TAB> <TAB> <TAB> <TAB> self. report ( <TAB> <TAB> <TAB> <TAB> <TAB> "... MOTION_NOTIFY %d events suppressed" % len ( unreported ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. report ( last_report ) <TAB> <TAB> self. motion_reports = [ ] <TAB> <TAB> self. report ( msg ) <TAB> return False | False | widget is self.app.doc.tdw | self.motion_event_counter >= 10 | 0.6579163074493408 |
377 | 375 | def _terminal_messenger ( tp = "write", msg = "", out = sys. stdout ) : <TAB> try : <TAB> <TAB> if tp == "write" : <TAB> <TAB> <TAB> out. write ( msg ) <TAB> <TAB> elif tp == "flush" : <TAB> <TAB> <TAB> out. flush ( ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> out. write ( msg ) <TAB> <TAB> <TAB> out. flush ( ) <TAB> <TAB> elif tp == "print" : <TAB> <TAB> <TAB> print ( msg, file = out ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( "Unsupported type: " + tp ) <TAB> except IOError as e : <TAB> <TAB> logger. critical ( "{}: {}". format ( type ( e ). __name__, ucd ( e ) ) ) <TAB> <TAB> pass | False | tp == 'write_flush' | tp == 'flush_all' | 0.6675392389297485 |
378 | 376 | def test_file_output ( ) : <TAB> """Test output to arbitrary file-like objects""" <TAB> with closing ( StringIO ( ) ) as our_file : <TAB> <TAB> for i in tqdm ( _range ( 3 ), file = our_file ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> our_file. seek ( 0 ) <TAB> <TAB> <TAB> <TAB> assert "0/3" in our_file. read ( ) | False | i == 1 | i % 2 == 0 | 0.6780132055282593 |
379 | 377 | def _transmit_from_storage ( self ) -> None : <TAB> for blob in self. storage. gets ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> envelopes = [ TelemetryItem ( ** x ) for x in blob. get ( ) ] <TAB> <TAB> <TAB> result = self. _transmit ( list ( envelopes ) ) <TAB> <TAB> <TAB> if result == ExportResult. FAILED_RETRYABLE : <TAB> <TAB> <TAB> <TAB> blob. lease ( 1 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> blob. delete ( ) | False | blob.lease(self._timeout + 5) | blob.has() | 0.6557530164718628 |
380 | 378 | def __plugContextMenuSignal ( graphEditor, plug, menuDefinition ) : <TAB> <TAB> nodeGadget = graphEditor. graphGadget ( ). nodeGadget ( plug. node ( ) ) <TAB> if not nodeGadget : <TAB> <TAB> return <TAB> nodule = nodeGadget. nodule ( plug ) <TAB> if<mask> : <TAB> <TAB> plug = plug. parent ( ) <TAB> <TAB> if isinstance ( plug, Gaffer. Plug ) : <TAB> <TAB> <TAB> nodule = nodeGadget. nodule ( plug ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> childNames = "". join ( c. getName ( ) for c in plug ). upper ( ) <TAB> if len ( nodule ) > 0 : <TAB> <TAB> menuDefinition. append ( <TAB> <TAB> <TAB> "/Collapse {} Components". format ( childNames ), <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> "command" : functools. partial ( __applyChildVisibility, plug, False ), <TAB> <TAB> <TAB> <TAB> "active" : not Gaffer. MetadataAlgo. readOnly ( plug ), <TAB> <TAB> <TAB> }, <TAB> <TAB> ) <TAB> else : <TAB> <TAB> menuDefinition. append ( <TAB> <TAB> <TAB> "/Expand {} Components". format ( childNames ), <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> "command" : functools. partial ( __applyChildVisibility, plug, True ), <TAB> <TAB> <TAB> <TAB> "active" : not Gaffer. MetadataAlgo. readOnly ( plug ), <TAB> <TAB> <TAB> }, <TAB> <TAB> ) | False | not isinstance(nodule, GafferUI.CompoundNumericNodule) | not nodule | 0.6510072946548462 |
381 | 379 | def main ( ) : <TAB> parser = argparse. ArgumentParser ( description = "Dispatcher command line parser" ) <TAB> parser. add_argument ( "--exp_params", type = str, required = True ) <TAB> args, _ = parser. parse_known_args ( ) <TAB> exp_params_decode = base64. b64decode ( args. exp_params ). decode ( "utf-8" ) <TAB> logger. debug ( "decoded exp_params: [%s]", exp_params_decode ) <TAB> exp_params = json. loads ( exp_params_decode ) <TAB> logger. debug ( "exp_params json obj: [%s]", json. dumps ( exp_params, indent = 4 ) ) <TAB> if exp_params. get ( "multiThread" ) : <TAB> <TAB> enable_multi_thread ( ) <TAB> if exp_params. get ( "multiPhase" ) : <TAB> <TAB> enable_multi_phase ( ) <TAB> if exp_params. get ( "advisor" ) is not None : <TAB> <TAB> <TAB> <TAB> _run_advisor ( exp_params ) <TAB> else : <TAB> <TAB> <TAB> <TAB> assert exp_params. get ( "tuner" ) is not None <TAB> <TAB> tuner = _create_tuner ( exp_params ) <TAB> <TAB> if exp_params. get ( "assessor" ) is not None : <TAB> <TAB> <TAB> assessor = _create_assessor ( exp_params ) <TAB> <TAB> else : <TAB> <TAB> <TAB> assessor = None <TAB> <TAB> dispatcher = MsgDispatcher ( tuner, assessor ) <TAB> <TAB> try : <TAB> <TAB> <TAB> dispatcher. run ( ) <TAB> <TAB> <TAB> tuner. _on_exit ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> assessor. _on_exit ( ) <TAB> <TAB> except Exception as exception : <TAB> <TAB> <TAB> logger. exception ( exception ) <TAB> <TAB> <TAB> | True | assessor is not None | assessor is not None | 0.6554909348487854 |
382 | 380 | def main ( args ) : <TAB> alphabet = args. alphabet <TAB> subsize = args. length <TAB> if args. lookup : <TAB> <TAB> pat = args. lookup <TAB> <TAB> try : <TAB> <TAB> <TAB> pat = int ( pat, 0 ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> pass <TAB> <TAB> pat = flat ( pat, bytes = args. length ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log. critical ( "Subpattern must be %d bytes" % subsize ) <TAB> <TAB> <TAB> sys. exit ( 1 ) <TAB> <TAB> if not all ( c in alphabet for c in pat ) : <TAB> <TAB> <TAB> log. critical ( "Pattern contains characters not present in the alphabet" ) <TAB> <TAB> <TAB> sys. exit ( 1 ) <TAB> <TAB> offset = cyclic_find ( pat, alphabet, subsize ) <TAB> <TAB> if offset == - 1 : <TAB> <TAB> <TAB> log. critical ( "Given pattern does not exist in cyclic pattern" ) <TAB> <TAB> <TAB> sys. exit ( 1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( offset ) <TAB> else : <TAB> <TAB> want = args. count <TAB> <TAB> result = cyclic ( want, alphabet, subsize ) <TAB> <TAB> got = len ( result ) <TAB> <TAB> if want is not None and got < want : <TAB> <TAB> <TAB> log. failure ( "Alphabet too small (max length = %i)" % got ) <TAB> <TAB> out = getattr ( sys. stdout, "buffer", sys. stdout ) <TAB> <TAB> out. write ( result ) <TAB> <TAB> if out. isatty ( ) : <TAB> <TAB> <TAB> out. write ( b"\n" ) | False | len(pat) != subsize | subsize and len(pat) > 0 | 0.6584582328796387 |
383 | 381 | def post_create ( self, user, billing = None ) : <TAB> from weblate. trans. models import Change <TAB> if billing : <TAB> <TAB> billing. projects. add ( self ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. access_control = Project. ACCESS_PRIVATE <TAB> <TAB> else : <TAB> <TAB> <TAB> self. access_control = Project. ACCESS_PUBLIC <TAB> <TAB> self. save ( ) <TAB> if not user. is_superuser : <TAB> <TAB> self. add_user ( user, "@Administration" ) <TAB> Change. objects. create ( <TAB> <TAB> action = Change. ACTION_CREATE_PROJECT, project = self, user = user, author = user <TAB> ) | False | billing.plan.change_access_control | user.is_private | 0.6539928913116455 |
384 | 382 | def _determine_tool_runners ( self, config, profile ) : <TAB> if config. tools is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> to_run = set ( DEFAULT_TOOLS ) <TAB> <TAB> <TAB> <TAB> for tool in tools. TOOLS. keys ( ) : <TAB> <TAB> <TAB> if profile. is_tool_enabled ( tool ) : <TAB> <TAB> <TAB> <TAB> to_run. add ( tool ) <TAB> else : <TAB> <TAB> to_run = set ( config. tools ) <TAB> <TAB> <TAB> <TAB> <TAB> for tool in config. with_tools : <TAB> <TAB> to_run. add ( tool ) <TAB> for tool in config. without_tools : <TAB> <TAB> if tool in to_run : <TAB> <TAB> <TAB> to_run. remove ( tool ) <TAB> if ( <TAB> <TAB> config. tools is None <TAB> <TAB> and len ( config. with_tools ) == 0 <TAB> <TAB> and len ( config. without_tools ) == 0 <TAB> ) : <TAB> <TAB> for tool in tools. TOOLS. keys ( ) : <TAB> <TAB> <TAB> enabled = profile. is_tool_enabled ( tool ) <TAB> <TAB> <TAB> if enabled is None : <TAB> <TAB> <TAB> <TAB> enabled = tool in DEFAULT_TOOLS <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> to_run. remove ( tool ) <TAB> return sorted ( list ( to_run ) ) | False | tool in to_run and (not enabled) | enabled | 0.6497543454170227 |
385 | 383 | def sample_admin_user ( ) : <TAB> """List of iris messages""" <TAB> with iris_ctl. db_from_config ( sample_db_config ) as ( conn, cursor ) : <TAB> <TAB> cursor. execute ( <TAB> <TAB> <TAB> "SELECT `name` FROM `target` JOIN `user` on `target`.`id` = `user`.`target_id` WHERE `user`.`admin` = TRUE LIMIT 1" <TAB> <TAB> ) <TAB> <TAB> result = cursor. fetchone ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return result [ 0 ] | True | result | result | 0.6948719620704651 |
386 | 384 | def read ( self, iprot ) : <TAB> if ( <TAB> <TAB> iprot. __class__ == TBinaryProtocol. TBinaryProtocolAccelerated <TAB> <TAB> and isinstance ( iprot. trans, TTransport. CReadableTransport ) <TAB> <TAB> and self. thrift_spec is not None <TAB> <TAB> and fastbinary is not None <TAB> ) : <TAB> <TAB> fastbinary. decode_binary ( self, iprot. trans, ( self. __class__, self. thrift_spec ) ) <TAB> <TAB> return <TAB> iprot. readStructBegin ( ) <TAB> while True : <TAB> <TAB> ( fname, ftype, fid ) = iprot. readFieldBegin ( ) <TAB> <TAB> if ftype == TType. STOP : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 1 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. type = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> else : <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> iprot. readFieldEnd ( ) <TAB> iprot. readStructEnd ( ) | False | ftype == TType.STRING | self.type == TType.STRING | 0.6586868762969971 |
387 | 385 | def groups ( self, trans, ** kwargs ) : <TAB> if "operation" in kwargs : <TAB> <TAB> operation = kwargs [ "operation" ]. lower ( ). replace ( "+", " " ) <TAB> <TAB> if operation == "groups" : <TAB> <TAB> <TAB> return self. group ( trans, ** kwargs ) <TAB> <TAB> if operation == "create" : <TAB> <TAB> <TAB> return self. create_group ( trans, ** kwargs ) <TAB> <TAB> if operation == "delete" : <TAB> <TAB> <TAB> return self. mark_group_deleted ( trans, ** kwargs ) <TAB> <TAB> if operation == "undelete" : <TAB> <TAB> <TAB> return self. undelete_group ( trans, ** kwargs ) <TAB> <TAB> if operation == "purge" : <TAB> <TAB> <TAB> return self. purge_group ( trans, ** kwargs ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. manage_users_and_roles_for_group ( trans, ** kwargs ) <TAB> <TAB> if operation == "rename" : <TAB> <TAB> <TAB> return self. rename_group ( trans, ** kwargs ) <TAB> <TAB> return self. group_list_grid ( trans, ** kwargs ) | False | operation == 'manage users and roles' | operation == 'manage_users_and_roles' | 0.6560624837875366 |
388 | 386 | def compare_hash ( hash_of_gold, path_to_file ) : <TAB> with open ( path_to_file, "rb" ) as f : <TAB> <TAB> hash_of_file = hashlib. sha256 ( f. read ( ) ). hexdigest ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> "########## Hash sum of", <TAB> <TAB> <TAB> <TAB> path_to_file, <TAB> <TAB> <TAB> <TAB> "differs from the target, the topology will be deleted!!! ##########", <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> shutil. rmtree ( os. path. dirname ( path_to_file ) ) | False | hash_of_file != hash_of_gold | hash_of_gold != path_to_file or hash_of_file != path_to_file | 0.6501489877700806 |
389 | 387 | def _get_node ( self, node_id ) : <TAB> self. non_terminated_nodes ( { } ) <TAB> with self. lock : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. cached_nodes [ node_id ] <TAB> <TAB> instance = ( <TAB> <TAB> <TAB> self. compute. instances ( ) <TAB> <TAB> <TAB>. get ( <TAB> <TAB> <TAB> <TAB> project = self. provider_config [ "project_id" ], <TAB> <TAB> <TAB> <TAB> zone = self. provider_config [ "availability_zone" ], <TAB> <TAB> <TAB> <TAB> instance = node_id, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB>. execute ( ) <TAB> <TAB> ) <TAB> <TAB> return instance | True | node_id in self.cached_nodes | node_id in self.cached_nodes | 0.660037636756897 |
390 | 388 | def _validate_and_define ( params, key, value ) : <TAB> ( key, force_generic ) = _validate_key ( _unescape ( key ) ) <TAB> if key in params : <TAB> <TAB> raise SyntaxError ( f'duplicate key "{key}"' ) <TAB> cls = _class_for_key. get ( key, GenericParam ) <TAB> emptiness = cls. emptiness ( ) <TAB> if value is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise SyntaxError ( "value cannot be empty" ) <TAB> <TAB> value = cls. from_value ( value ) <TAB> else : <TAB> <TAB> if force_generic : <TAB> <TAB> <TAB> value = cls. from_wire_parser ( dns. wire. Parser ( _unescape ( value ) ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> value = cls. from_value ( value ) <TAB> params [ key ] = value | False | emptiness == Emptiness.NEVER | emptiness | 0.6540172100067139 |
391 | 389 | def get_components_list ( component_revisions_dict, job_type ) : <TAB> """Return a prioritized order of components based on job type.""" <TAB> components = sorted ( component_revisions_dict. keys ( ) ) <TAB> if utils. is_chromium ( ) : <TAB> <TAB> <TAB> <TAB> return components <TAB> project_name = data_handler. get_project_name ( job_type ) <TAB> if not project_name : <TAB> <TAB> <TAB> <TAB> return components <TAB> main_repo = data_handler. get_main_repo ( job_type ) <TAB> project_src = "/src/" + project_name <TAB> for component in components. copy ( ) : <TAB> <TAB> if component_revisions_dict [ component ] [ "url" ] == main_repo : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> components. remove ( component ) <TAB> <TAB> <TAB> components. insert ( 0, component ) <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> components. remove ( component ) <TAB> <TAB> <TAB> components. insert ( 0, component ) <TAB> <TAB> <TAB> break <TAB> <TAB> if project_name. lower ( ) in os. path. basename ( component ). lower ( ) : <TAB> <TAB> <TAB> components. remove ( component ) <TAB> <TAB> <TAB> components. insert ( 0, component ) <TAB> <TAB> <TAB> <TAB> return components | False | component == project_src | project_src.lower() in os.path.basename(component) | 0.6638051271438599 |
392 | 390 | def initEnv ( self, mandatory = True, detailed = False, web = False, forceInit = False ) : <TAB> self. _initRunAs ( ) <TAB> if self. envInitialized and not forceInit : <TAB> <TAB> return <TAB> if web : <TAB> <TAB> self. webInit ( ) <TAB> else : <TAB> <TAB> self. checkDbmsOs ( detailed ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> warnMsg = "functionality requested probably does not work because " <TAB> <TAB> <TAB> warnMsg += "the curent session user is not a database administrator" <TAB> <TAB> <TAB> if not conf. dbmsCred and Backend. getIdentifiedDbms ( ) in ( <TAB> <TAB> <TAB> <TAB> DBMS. MSSQL, <TAB> <TAB> <TAB> <TAB> DBMS. PGSQL, <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> warnMsg += ". You can try to use option '--dbms-cred' " <TAB> <TAB> <TAB> <TAB> warnMsg += "to execute statements as a DBA user if you " <TAB> <TAB> <TAB> <TAB> warnMsg += "were able to extract and crack a DBA " <TAB> <TAB> <TAB> <TAB> warnMsg += "password by any mean" <TAB> <TAB> <TAB> logger. warn ( warnMsg ) <TAB> <TAB> if Backend. getIdentifiedDbms ( ) in ( DBMS. MYSQL, DBMS. PGSQL ) : <TAB> <TAB> <TAB> success = self. udfInjectSys ( ) <TAB> <TAB> <TAB> if success is not True : <TAB> <TAB> <TAB> <TAB> msg = "unable to mount the operating system takeover" <TAB> <TAB> <TAB> <TAB> raise SqlmapFilePathException ( msg ) <TAB> <TAB> elif Backend. isDbms ( DBMS. MSSQL ) : <TAB> <TAB> <TAB> if mandatory : <TAB> <TAB> <TAB> <TAB> self. xpCmdshellInit ( ) <TAB> <TAB | False | mandatory and (not self.isDba()) | detailed | 0.6555026769638062 |
393 | 391 | def getCalculatedPosition ( self ) : <TAB> if self. _lastVLCPositionUpdate is None : <TAB> <TAB> return self. _client. getGlobalPosition ( ) <TAB> diff = time. time ( ) - self. _lastVLCPositionUpdate <TAB> if diff > constants. PLAYER_ASK_DELAY and not self. _paused : <TAB> <TAB> self. _client. ui. showDebugMessage ( <TAB> <TAB> <TAB> "VLC did not response in time, so assuming position is {} ({}+{})". format ( <TAB> <TAB> <TAB> <TAB> self. _position + diff, self. _position, diff <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not self. shownVLCLatencyError or constants. DEBUG_MODE : <TAB> <TAB> <TAB> <TAB> self. _client. ui. showErrorMessage ( <TAB> <TAB> <TAB> <TAB> <TAB> getMessage ( "media-player-latency-warning" ). format ( int ( diff ) ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. shownVLCLatencyError = True <TAB> <TAB> return self. _position + diff <TAB> else : <TAB> <TAB> return self. _position | False | diff > constants.VLC_LATENCY_ERROR_THRESHOLD | diff > 0 | 0.654369592666626 |
394 | 392 | def build_query_from_field ( self, field_name, operation ) : <TAB> if field_name == "permission" : <TAB> <TAB> if operation [ "op" ]!= "eq" : <TAB> <TAB> <TAB> raise InvalidFilterOperator ( value = operation [ "op" ], valid_operators = [ "eq" ] ) <TAB> <TAB> <TAB> <TAB> query_val = operation [ "value" ]. lower ( ). strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise InvalidFilterValue ( value = operation [ "value" ] ) <TAB> <TAB> <TAB> <TAB> resource = self. get_resource ( ) <TAB> <TAB> if query_val == READ : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return Q ( user_id__in = resource. contributors. values_list ( "id", flat = True ) ) <TAB> <TAB> elif query_val == WRITE : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return Q ( <TAB> <TAB> <TAB> <TAB> user_id__in = ( <TAB> <TAB> <TAB> <TAB> <TAB> resource. get_group ( WRITE ). user_set. values_list ( "id", flat = True ) <TAB> <TAB> <TAB> <TAB> <TAB> | resource. get_group ( ADMIN ). user_set. values_list ( "id", flat = True ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif query_val == ADMIN : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return Q ( <TAB> <TAB> <TAB> <TAB> user_id__in = resource. get_group ( ADMIN ). user_set. values_list ( <TAB> <TAB> <TAB> <TAB> <TAB> "id", flat = True <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> return super ( BaseContributorList, self ). build_query | False | query_val not in API_CONTRIBUTOR_PERMISSIONS | query_val != None | 0.6540019512176514 |
395 | 393 | def login ( self ) : <TAB> error = None <TAB> Form = self. get_login_form ( ) <TAB> if request. method == "POST" : <TAB> <TAB> form = Form ( request. form ) <TAB> <TAB> next_url = request. form. get ( "next" ) or self. default_next_url <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> authenticated_user = self. authenticate ( <TAB> <TAB> <TAB> <TAB> form. username. data, <TAB> <TAB> <TAB> <TAB> form. password. data, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if authenticated_user : <TAB> <TAB> <TAB> <TAB> self. login_user ( authenticated_user ) <TAB> <TAB> <TAB> <TAB> return redirect ( next_url ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> flash ( "Incorrect username or password" ) <TAB> else : <TAB> <TAB> form = Form ( ) <TAB> <TAB> next_url = request. args. get ( "next" ) <TAB> return render_template ( <TAB> <TAB> "auth/login.html", <TAB> <TAB> error = error, <TAB> <TAB> form = form, <TAB> <TAB> login_url = url_for ( "%s.login" % self. blueprint. name ), <TAB> <TAB> next = next_url, <TAB> ) | False | form.validate() | self.login_form and self.password | 0.6515189409255981 |
396 | 394 | def preflight ( ) : <TAB> """Preflight checks.""" <TAB> logger. warning ( <TAB> <TAB> "This action is deprecated. Use https://github.com/hacs/action instead" <TAB> ) <TAB> event_data = get_event_data ( ) <TAB> ref = None <TAB> if REPOSITORY and CATEGORY : <TAB> <TAB> repository = REPOSITORY <TAB> <TAB> category = CATEGORY <TAB> <TAB> pr = False <TAB> elif GITHUB_REPOSITORY == "hacs/default" : <TAB> <TAB> category = chose_category ( ) <TAB> <TAB> repository = chose_repository ( category ) <TAB> <TAB> pr = False <TAB> <TAB> logger. info ( f"Actor: {GITHUB_ACTOR}" ) <TAB> else : <TAB> <TAB> category = CATEGORY. lower ( ) <TAB> <TAB> pr = True if event_data. get ( "pull_request" ) is not None else False <TAB> <TAB> if pr : <TAB> <TAB> <TAB> head = event_data [ "pull_request" ] [ "head" ] <TAB> <TAB> <TAB> ref = head [ "ref" ] <TAB> <TAB> <TAB> repository = head [ "repo" ] [ "full_name" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> repository = GITHUB_REPOSITORY <TAB> logger. info ( f"Category: {category}" ) <TAB> logger. info ( f"Repository: {repository}" ) <TAB> if TOKEN is None : <TAB> <TAB> error ( "No GitHub token found, use env GITHUB_TOKEN to set this." ) <TAB> if repository is None : <TAB> <TAB> error ( "No repository found, use env REPOSITORY to set this." ) <TAB> if category is None : <TAB> <TAB> error ( "No category found, use env CATEGORY to set this." ) <TAB> async with aiohttp. ClientSession ( ) as session : <TAB> <TAB> github = GitHub ( TOKEN, session ) <TAB> <TAB> repo = await github. get_repo ( repository ) <TAB> <TAB> | False | not pr and repo.description is None | get_category() is False | 0.6517397165298462 |
397 | 395 | def _wrap_ssl_client ( sock, ssl, server_hostname, alpn_protocols ) : <TAB> <TAB> if ssl : <TAB> <TAB> if isinstance ( ssl, bool ) : <TAB> <TAB> <TAB> sslcontext = curiossl. create_default_context ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> sslcontext. _context. check_hostname = False <TAB> <TAB> <TAB> <TAB> sslcontext. _context. verify_mode = curiossl. CERT_NONE <TAB> <TAB> <TAB> if alpn_protocols : <TAB> <TAB> <TAB> <TAB> sslcontext. set_alpn_protocols ( alpn_protocols ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sslcontext = ssl <TAB> <TAB> if server_hostname : <TAB> <TAB> <TAB> extra_args = { "server_hostname" : server_hostname } <TAB> <TAB> else : <TAB> <TAB> <TAB> extra_args = { } <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( sslcontext, curiossl. CurioSSLContext ) : <TAB> <TAB> <TAB> sock = await sslcontext. wrap_socket ( <TAB> <TAB> <TAB> <TAB> sock, do_handshake_on_connect = False, ** extra_args <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> extra_args [ "do_handshake_on_connect" ] = sock. _socket. gettimeout ( )!= 0.0 <TAB> <TAB> <TAB> sock = Socket ( sslcontext. wrap_socket ( sock. _socket, ** extra_args ) ) <TAB> <TAB> await sock. do_handshake ( ) <TAB> return | False | not server_hostname | hasattr(sslcontext, '_context') | 0.6621442437171936 |
398 | 396 | def _evaluate_local_single ( self, iterator ) : <TAB> for batch in iterator : <TAB> <TAB> in_arrays = convert. _call_converter ( self. converter, batch, self. device ) <TAB> <TAB> with function. no_backprop_mode ( ) : <TAB> <TAB> <TAB> if isinstance ( in_arrays, tuple ) : <TAB> <TAB> <TAB> <TAB> results = self. calc_local ( * in_arrays ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> results = self. calc_local ( ** in_arrays ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> results = self. calc_local ( in_arrays ) <TAB> <TAB> if self. _progress_hook : <TAB> <TAB> <TAB> self. _progress_hook ( batch ) <TAB> <TAB> yield results | False | isinstance(in_arrays, dict) | isinstance(in_arrays, list) | 0.6513357162475586 |
399 | 397 | def get_note_title_file ( note ) : <TAB> mo = note_title_re. match ( note. get ( "content", "" ) ) <TAB> if mo : <TAB> <TAB> fn = mo. groups ( ) [ 0 ] <TAB> <TAB> fn = fn. replace ( " ", "_" ) <TAB> <TAB> fn = fn. replace ( "/", "_" ) <TAB> <TAB> if not fn : <TAB> <TAB> <TAB> return "" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fn = unicode ( fn, "utf-8" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> fn = unicode ( fn ) <TAB> <TAB> if note_markdown ( note ) : <TAB> <TAB> <TAB> fn += ".mkdn" <TAB> <TAB> else : <TAB> <TAB> <TAB> fn += ".txt" <TAB> <TAB> return fn <TAB> else : <TAB> <TAB> return "" | False | isinstance(fn, str) | isinstance(fn, unicode) | 0.6525890827178955 |
400 | 398 | def run ( self, edit, reverse = False ) : <TAB> for region in self. view. sel ( ) : <TAB> <TAB> line = self. view. line ( region ) <TAB> <TAB> line_content = self. view. substr ( line ) <TAB> <TAB> bullets = self. view. settings ( ). get ( "mde.list_indent_bullets", [ "*", "-", "+" ] ) <TAB> <TAB> bullet_pattern = "([" + "". join ( re. escape ( i ) for i in bullets ) + "])" <TAB> <TAB> new_line = line_content <TAB> <TAB> <TAB> <TAB> if self. view. settings ( ). get ( "mde.list_indent_auto_switch_bullet", True ) : <TAB> <TAB> <TAB> for key, bullet in enumerate ( bullets ) : <TAB> <TAB> <TAB> <TAB> if bullet in new_line : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> new_line = new_line. replace ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> bullet, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> bullets [ ( key + ( 1 if not reverse else - 1 ) ) % len ( bullets ) ], <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> if self. view. settings ( ). get ( "translate_tabs_to_spaces" ) : <TAB> <TAB> <TAB> tab_str = self. view. settings ( ). get ( "tab_size", 4 ) * " " <TAB> <TAB> else : <TAB> <TAB> <TAB> tab_str = "\t" <TAB> <TAB> if not reverse : <TAB | False | reverse and new_line.startswith(bullet) and (key is 0) | not reverse | 0.6506942510604858 |
401 | 399 | def _integrate_cycle ( self, cycle, outevent, inevent ) : <TAB> if outevent not in cycle : <TAB> <TAB> total = inevent. null ( ) <TAB> <TAB> for member in cycle. functions : <TAB> <TAB> <TAB> subtotal = member [ inevent ] <TAB> <TAB> <TAB> for call in member. calls. itervalues ( ) : <TAB> <TAB> <TAB> <TAB> callee = self. functions [ call. callee_id ] <TAB> <TAB> <TAB> <TAB> if callee. cycle is not cycle : <TAB> <TAB> <TAB> <TAB> <TAB> subtotal += self. _integrate_call ( call, outevent, inevent ) <TAB> <TAB> <TAB> total += subtotal <TAB> <TAB> cycle [ outevent ] = total <TAB> <TAB> callees = { } <TAB> <TAB> for function in self. functions. itervalues ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> for call in function. calls. itervalues ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> callee = self. functions [ call. callee_id ] <TAB> <TAB> <TAB> <TAB> <TAB> if callee. cycle is cycle : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> callees [ callee ] += call [ CALL_RATIO ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> callees [ callee ] = call [ CALL_RATIO ] <TAB> <TAB> for callee, call_ratio in callees. iteritems ( ) : <TAB> <TAB> <TAB> ranks = { } <TAB> <TAB> <TAB> call_ratios = { } <TAB> <TAB> <TAB> partials = { } <TAB> <TAB> <TAB> self. _rank_cycle_function ( cycle, callee, 0, ranks | False | function.cycle is not cycle | function.has_keys | 0.6627118587493896 |
402 | 400 | def iter ( self, retry_state ) : <TAB> fut = retry_state. outcome <TAB> if fut is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. before ( retry_state ) <TAB> <TAB> return DoAttempt ( ) <TAB> is_explicit_retry = retry_state. outcome. failed and isinstance ( <TAB> <TAB> retry_state. outcome. exception ( ), TryAgain <TAB> ) <TAB> if not ( is_explicit_retry or self. retry ( retry_state = retry_state ) ) : <TAB> <TAB> return fut. result ( ) <TAB> if self. after is not None : <TAB> <TAB> self. after ( retry_state = retry_state ) <TAB> self. statistics [ "delay_since_first_attempt" ] = retry_state. seconds_since_start <TAB> if self. stop ( retry_state = retry_state ) : <TAB> <TAB> if self. retry_error_callback : <TAB> <TAB> <TAB> return self. retry_error_callback ( retry_state = retry_state ) <TAB> <TAB> retry_exc = self. retry_error_cls ( fut ) <TAB> <TAB> if self. reraise : <TAB> <TAB> <TAB> raise retry_exc. reraise ( ) <TAB> <TAB> six. raise_from ( retry_exc, fut. exception ( ) ) <TAB> if self. wait : <TAB> <TAB> sleep = self. wait ( retry_state = retry_state ) <TAB> else : <TAB> <TAB> sleep = 0.0 <TAB> retry_state. next_action = RetryAction ( sleep ) <TAB> retry_state. idle_for += sleep <TAB> self. statistics [ "idle_for" ] += sleep <TAB> self. statistics [ "attempt_number" ] += 1 <TAB> if self. before_sleep is not None : <TAB> <TAB> self. before_sleep ( retry_state = retry_state ) <TAB> return DoSleep ( sleep ) | True | self.before is not None | self.before is not None | 0.6536264419555664 |
403 | 401 | def get_boot_command ( self ) : <TAB> <TAB> <TAB> <TAB> boot_cmd = super ( Connection, self ). get_boot_command ( ) <TAB> bits = [ self. options. sudo_path, "-u", self. options. username ] <TAB> if self. options. preserve_env : <TAB> <TAB> bits += [ "-E" ] <TAB> if self. options. set_home : <TAB> <TAB> bits += [ "-H" ] <TAB> if self. options. login : <TAB> <TAB> bits += [ "-i" ] <TAB> if self. options. selinux_role : <TAB> <TAB> bits += [ "-r", self. options. selinux_role ] <TAB> if self. options. selinux_type : <TAB> <TAB> bits += [ "-t", self. options. selinux_type ] <TAB> <TAB> <TAB> <TAB> source_found = False <TAB> for cmd in boot_cmd [ : ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> boot_cmd. remove ( cmd ) <TAB> <TAB> <TAB> source_found = True <TAB> <TAB> <TAB> continue <TAB> <TAB> if source_found : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not cmd. endswith ( "python" ) : <TAB> <TAB> <TAB> <TAB> boot_cmd. remove ( cmd ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> break <TAB> return bits + [ "--" ] + boot_cmd | False | 'source' == cmd | cmd.endswith('python') | 0.6762728691101074 |
404 | 402 | def _handle_open_tag ( self, html_tag ) : <TAB> ignored = self. handle_ignore ( html_tag ) <TAB> tagname = self. handle_replacement ( html_tag ) <TAB> jannotations = self. read_jannotations ( html_tag ) <TAB> if not jannotations and tagname in self. labelled_tag_stacks : <TAB> <TAB> <TAB> <TAB> self. labelled_tag_stacks [ tagname ]. append ( None ) <TAB> increment = not jannotations <TAB> for jannotation in arg_to_iter ( jannotations ) : <TAB> <TAB> self. extra_required_attrs. extend ( jannotation. pop ( "required", [ ] ) ) <TAB> <TAB> annotation = self. build_annotation ( jannotation ) <TAB> <TAB> self. handle_generated ( annotation, ignored ) <TAB> <TAB> self. handle_variant ( annotation ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> increment = True <TAB> <TAB> <TAB> <TAB> if annotation. surrounds_attribute : <TAB> <TAB> <TAB> self. labelled_tag_stacks [ tagname ]. append ( annotation ) <TAB> <TAB> else : <TAB> <TAB> <TAB> annotation. end_index = annotation. start_index + 1 <TAB> <TAB> <TAB> self. annotations. append ( annotation ) <TAB> self. next_tag_index += increment | False | annotation.annotation_text is None and (not increment) | annotation.surrounds | 0.650397539138794 |
405 | 403 | def _check_main_square_in_range ( self ) : <TAB> """Notifies the user via a message in case there is no main square in range""" <TAB> if not self. owner. is_local_player : <TAB> <TAB> return <TAB> for building in self. get_buildings_in_range ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if StaticPather. get_path_on_roads ( self. island, self, building ) is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if hasattr ( self, "_main_square_status_icon" ) : <TAB> <TAB> <TAB> <TAB> <TAB> RemoveStatusIcon. broadcast ( self, self, SettlerNotConnectedStatus ) <TAB> <TAB> <TAB> <TAB> <TAB> del self. _main_square_status_icon <TAB> <TAB> <TAB> <TAB> return <TAB> if not hasattr ( self, "_main_square_status_icon" ) : <TAB> <TAB> self. _main_square_status_icon = SettlerNotConnectedStatus ( <TAB> <TAB> <TAB> self <TAB> <TAB> ) <TAB> <TAB> AddStatusIcon. broadcast ( self, self. _main_square_status_icon ) <TAB> <TAB> <TAB> self. session. ingame_gui. message_widget. add ( <TAB> <TAB> point = self. position. origin, <TAB> <TAB> string_id = "NO_MAIN_SQUARE_IN_RANGE", <TAB> <TAB> check_duplicate = True, <TAB> ) | False | building.id == BUILDINGS.MAIN_SQUARE | self.island | 0.6523812413215637 |
406 | 404 | def __init__ ( self, centered = None, shape_params = ( ) ) : <TAB> assert centered is None or isinstance ( centered, ( float, torch. Tensor ) ) <TAB> assert isinstance ( shape_params, ( tuple, list ) ) <TAB> assert all ( isinstance ( name, str ) for name in shape_params ) <TAB> if is_validation_enabled ( ) : <TAB> <TAB> if isinstance ( centered, float ) : <TAB> <TAB> <TAB> assert 0 <= centered and centered <= 1 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> assert ( 0 <= centered ). all ( ) <TAB> <TAB> <TAB> assert ( centered <= 1 ). all ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> assert centered is None <TAB> self. centered = centered <TAB> self. shape_params = shape_params | True | isinstance(centered, torch.Tensor) | isinstance(centered, torch.Tensor) | 0.6509578227996826 |
407 | 405 | def __get_id_list ( self, user, attr ) : <TAB> if user. is_superuser or not filer_settings. FILER_ENABLE_PERMISSIONS : <TAB> <TAB> return "All" <TAB> allow_list = set ( ) <TAB> deny_list = set ( ) <TAB> group_ids = user. groups. all ( ). values_list ( "id", flat = True ) <TAB> q = Q ( user = user ) | Q ( group__in = group_ids ) | Q ( everybody = True ) <TAB> perms = self. filter ( q ). order_by ( "folder__tree_id", "folder__level", "folder__lft" ) <TAB> for perm in perms : <TAB> <TAB> p = getattr ( perm, attr ) <TAB> <TAB> if p is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> if not perm. folder : <TAB> <TAB> <TAB> assert perm. type == FolderPermission. ALL <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> allow_list. update ( Folder. objects. all ( ). values_list ( "id", flat = True ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> deny_list. update ( Folder. objects. all ( ). values_list ( "id", flat = True ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> folder_id = perm. folder. id <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> allow_list. add ( folder_id ) <TAB> <TAB> else : <TAB> <TAB> <TAB> deny_list. add ( folder_id ) <TAB> <TAB> if perm. type == FolderPermission. CHILDREN : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> allow_list. update ( <TAB> <TAB> <TAB> <TAB> <TAB> perm. folder. get_descendants ( ). values_list ( "id", flat = True | False | p == FolderPermission.ALLOW | perm.type == FolderPermission.MANDATORY | 0.6616733074188232 |
408 | 406 | def test_native_types ( self ) : <TAB> for tp, fmt, shape, itemtp in native_types : <TAB> <TAB> ob = tp ( ) <TAB> <TAB> v = memoryview ( ob ) <TAB> <TAB> try : <TAB> <TAB> <TAB> self. assertEqual ( normalize ( v. format ), normalize ( fmt ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. assertEqual ( len ( v ), shape [ 0 ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. assertEqual ( len ( v ) * sizeof ( itemtp ), sizeof ( ob ) ) <TAB> <TAB> <TAB> self. assertEqual ( v. itemsize, sizeof ( itemtp ) ) <TAB> <TAB> <TAB> self. assertEqual ( v. shape, shape ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. assertFalse ( v. readonly ) <TAB> <TAB> <TAB> if v. shape : <TAB> <TAB> <TAB> <TAB> n = 1 <TAB> <TAB> <TAB> <TAB> for dim in v. shape : <TAB> <TAB> <TAB> <TAB> <TAB> n = n * dim <TAB> <TAB> <TAB> <TAB> self. assertEqual ( n * v. itemsize, len ( v. tobytes ( ) ) ) <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( tp ) <TAB> <TAB> <TAB> raise | False | shape | itemtp is None | 0.6944328546524048 |
409 | 407 | def uninstall_environments ( self, environments ) : <TAB> environments = [ <TAB> <TAB> env <TAB> <TAB> if not env. startswith ( self. conda_context. envs_path ) <TAB> <TAB> else os. path. basename ( env ) <TAB> <TAB> for env in environments <TAB> ] <TAB> return_codes = [ self. conda_context. exec_remove ( [ env ] ) for env in environments ] <TAB> final_return_code = 0 <TAB> for env, return_code in zip ( environments, return_codes ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log. debug ( "Conda environment '%s' successfully removed." % env ) <TAB> <TAB> else : <TAB> <TAB> <TAB> log. debug ( "Conda environment '%s' could not be removed." % env ) <TAB> <TAB> <TAB> final_return_code = return_code <TAB> return final_return_code | False | return_code == 0 | env | 0.6608858108520508 |
410 | 408 | def updater_run_install_popup_handler ( scene ) : <TAB> global ran_autocheck_install_popup <TAB> ran_autocheck_install_popup = True <TAB> <TAB> if updater. invalidupdater : <TAB> <TAB> return <TAB> try : <TAB> <TAB> bpy. app. handlers. scene_update_post. remove ( updater_run_install_popup_handler ) <TAB> except : <TAB> <TAB> pass <TAB> if "ignore" in updater. json and updater. json [ "ignore" ] : <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> <TAB> elif "version_text" in updater. json and "version" in updater. json [ "version_text" ] : <TAB> <TAB> version = updater. json [ "version_text" ] [ "version" ] <TAB> <TAB> ver_tuple = updater. version_tuple_from_text ( version ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if updater. verbose : <TAB> <TAB> <TAB> <TAB> print ( "RetopoFlow updater: appears user updated, clearing flag" ) <TAB> <TAB> <TAB> updater. json_reset_restore ( ) <TAB> <TAB> <TAB> return <TAB> atr = addon_updater_install_popup. bl_idname. split ( "." ) <TAB> getattr ( getattr ( bpy. ops, atr [ 0 ] ), atr [ 1 ] ) ( "INVOKE_DEFAULT" ) | False | ver_tuple < updater.current_version | len(ver_tuple) > 0 | 0.6495919823646545 |
411 | 409 | def _test_reducibility ( self ) : <TAB> <TAB> graph = networkx. DiGraph ( self. _graph ) <TAB> <TAB> self. _make_supergraph ( graph ) <TAB> while True : <TAB> <TAB> changed = False <TAB> <TAB> <TAB> <TAB> changed |= self. _remove_self_loop ( graph ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> changed |= self. _merge_single_entry_node ( graph ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break | True | not changed | not changed | 0.6800062656402588 |
412 | 410 | def _process_features ( self, datum ) : <TAB> if len ( datum )!= 2 : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> "Expected tuples of ({}_id, features), " <TAB> <TAB> <TAB> "got {}.". format ( self. _entity_type, datum ) <TAB> <TAB> ) <TAB> entity_id, features = datum <TAB> if entity_id not in self. _id_mapping : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> "{entity_type} id {entity_id} not in {entity_type} id mappings.". format ( <TAB> <TAB> <TAB> <TAB> entity_type = self. _entity_type, entity_id = entity_id <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> idx = self. _id_mapping [ entity_id ] <TAB> for ( feature, weight ) in self. _iter_features ( features ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> "Feature {} not in feature mapping. " "Call fit first.". format ( feature ) <TAB> <TAB> <TAB> ) <TAB> <TAB> feature_idx = self. _feature_mapping [ feature ] <TAB> <TAB> yield ( idx, feature_idx, weight ) | True | feature not in self._feature_mapping | feature not in self._feature_mapping | 0.6575216054916382 |
413 | 411 | def vsGetFastParseFields ( self ) : <TAB> fields = [ ] <TAB> for fname in self. _vs_fields : <TAB> <TAB> fobj = self. _vs_values. get ( fname ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fields. append ( fobj ) <TAB> <TAB> <TAB> continue <TAB> <TAB> fields. extend ( fobj. vsGetFastParseFields ( ) ) <TAB> return fields | False | fobj.vsIsPrim() | fobj is None | 0.6561350226402283 |
414 | 412 | def query ( q ) : <TAB> url = query_url ( ) + urllib. parse. quote ( json. dumps ( q ) ) <TAB> ret = None <TAB> for i in range ( 20 ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> ret = urlread ( url ) <TAB> <TAB> <TAB> while ret. startswith ( b"canceling statement due to statement timeout" ) : <TAB> <TAB> <TAB> <TAB> ret = urlread ( url ) <TAB> <TAB> <TAB> if not ret : <TAB> <TAB> <TAB> <TAB> print ( "ret == None" ) <TAB> <TAB> except IOError : <TAB> <TAB> <TAB> pass <TAB> <TAB> if ret : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> data = json. loads ( ret ) <TAB> <TAB> <TAB> <TAB> if isinstance ( data, dict ) : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( "error:" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( ret ) <TAB> <TAB> <TAB> <TAB> <TAB> assert "error" not in data <TAB> <TAB> <TAB> <TAB> return data <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> print ( ret ) <TAB> <TAB> <TAB> <TAB> print ( url ) <TAB> <TAB> sleep ( 20 ) | False | 'error' in data | data['error'] | 0.6619100570678711 |
415 | 413 | def __get_ratio ( self ) : <TAB> """Return splitter ratio of the main splitter.""" <TAB> c = self. c <TAB> free_layout = c. free_layout <TAB> if free_layout : <TAB> <TAB> w = free_layout. get_main_splitter ( ) <TAB> <TAB> if w : <TAB> <TAB> <TAB> aList = w. sizes ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> n1, n2 = aList <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ratio = 0.5 if n1 + n2 == 0 else float ( n1 ) / float ( n1 + n2 ) <TAB> <TAB> <TAB> <TAB> return ratio <TAB> return 0.5 | False | len(aList) == 2 | aList | 0.6570168733596802 |
416 | 414 | def _readenv ( var, msg ) : <TAB> match = _ENV_VAR_PAT. match ( var ) <TAB> if match and match. groups ( ) : <TAB> <TAB> envvar = match. groups ( ) [ 0 ] <TAB> <TAB> if envvar in os. environ : <TAB> <TAB> <TAB> value = os. environ [ envvar ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> value = value. decode ( "utf8" ) <TAB> <TAB> <TAB> return value <TAB> <TAB> else : <TAB> <TAB> <TAB> raise InvalidConfigException ( <TAB> <TAB> <TAB> <TAB> "{} - environment variable '{}' not set". format ( msg, var ) <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> raise InvalidConfigException ( <TAB> <TAB> <TAB> "{} - environment variable name '{}' does not match pattern '{}'". format ( <TAB> <TAB> <TAB> <TAB> msg, var, _ENV_VAR_PAT_STR <TAB> <TAB> <TAB> ) <TAB> <TAB> ) | False | six.PY2 | isinstance(value, bytes) | 0.6693143844604492 |
417 | 415 | def _make_doc_structure ( d, level ) : <TAB> if d. is_redirect : <TAB> <TAB> return None <TAB> if expand : <TAB> <TAB> res = dict ( d. get_json_data ( ) ) <TAB> <TAB> res [ "subpages" ] = [ ] <TAB> else : <TAB> <TAB> res = { <TAB> <TAB> <TAB> "title" : d. title, <TAB> <TAB> <TAB> "slug" : d. slug, <TAB> <TAB> <TAB> "locale" : d. locale, <TAB> <TAB> <TAB> "url" : d. get_absolute_url ( ), <TAB> <TAB> <TAB> "subpages" : [ ], <TAB> <TAB> } <TAB> if level < depth : <TAB> <TAB> descendants = d. get_descendants ( 1 ) <TAB> <TAB> descendants. sort ( key = lambda item : item. title ) <TAB> <TAB> for descendant in descendants : <TAB> <TAB> <TAB> sp = _make_doc_structure ( descendant, level + 1 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> res [ "subpages" ]. append ( sp ) <TAB> return res | False | sp is not None | sp | 0.6613863110542297 |
418 | 416 | def _setup_layer ( self, trainable = False, ** kwargs ) : <TAB> """Constructs keras layer with relevant weights and losses.""" <TAB> <TAB> super ( KerasLayer, self ). __init__ ( trainable = trainable, ** kwargs ) <TAB> <TAB> if hasattr ( self. _func, "trainable_variables" ) : <TAB> <TAB> for v in self. _func. trainable_variables : <TAB> <TAB> <TAB> self. _add_existing_weight ( v, trainable = True ) <TAB> <TAB> trainable_variables = { id ( v ) for v in self. _func. trainable_variables } <TAB> else : <TAB> <TAB> trainable_variables = set ( ) <TAB> if hasattr ( self. _func, "variables" ) : <TAB> <TAB> for v in self. _func. variables : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. _add_existing_weight ( v, trainable = False ) <TAB> <TAB> if hasattr ( self. _func, "regularization_losses" ) : <TAB> <TAB> for l in self. _func. regularization_losses : <TAB> <TAB> <TAB> if not callable ( l ) : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> "hub.KerasLayer(obj) expects obj.regularization_losses to be an " <TAB> <TAB> <TAB> <TAB> <TAB> "iterable of callables, each returning a scalar loss term." <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. add_loss ( self. _call_loss_if_trainable ( l ) ) | False | id(v) not in trainable_variables | v != None | 0.6515688896179199 |
419 | 417 | def process_signature ( app, what, name, obj, options, signature, return_annotation ) : <TAB> if signature : <TAB> <TAB> <TAB> <TAB> signature = re. sub ( "<Mock name='([^']+)'.*>", "\g<1>", signature ) <TAB> <TAB> signature = re. sub ( "tensorflow", "tf", signature ) <TAB> <TAB> <TAB> <TAB> if hasattr ( obj, "use_scope" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> signature = signature [ 0 ] + "variable_scope_name, " + signature [ 1 : ] <TAB> <TAB> <TAB> elif obj. use_scope is None : <TAB> <TAB> <TAB> <TAB> signature = signature [ 0 ] + "[variable_scope_name,] " + signature [ 1 : ] <TAB> <TAB> return signature, return_annotation | False | obj.use_scope | obj.use_scope is True | 0.655645489692688 |
420 | 418 | def check_model_list_copy ( overwrite = False, max_per_line = 119 ) : <TAB> """Check the model lists in the README and index.rst are consistent and maybe `overwrite`.""" <TAB> rst_list, start_index, end_index, lines = _find_text_in_file ( <TAB> <TAB> filename = os. path. join ( PATH_TO_DOCS, "index.rst" ), <TAB> <TAB> start_prompt = " This list is updated automatically from the README", <TAB> <TAB> end_prompt = ".. _bigtable:", <TAB> ) <TAB> md_list = get_model_list ( ) <TAB> converted_list = convert_to_rst ( md_list, max_per_line = max_per_line ) <TAB> if converted_list!= rst_list : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> with open ( <TAB> <TAB> <TAB> <TAB> os. path. join ( PATH_TO_DOCS, "index.rst" ), <TAB> <TAB> <TAB> <TAB> "w", <TAB> <TAB> <TAB> <TAB> encoding = "utf-8", <TAB> <TAB> <TAB> <TAB> newline = "\n", <TAB> <TAB> <TAB> ) as f : <TAB> <TAB> <TAB> <TAB> f. writelines ( lines [ : start_index ] + [ converted_list ] + lines [ end_index : ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> "The model list in the README changed and the list in `index.rst` has not been updated. Run " <TAB> <TAB> <TAB> <TAB> "`make fix-copies` to fix this." <TAB> <TAB> <TAB> ) | True | overwrite | overwrite | 0.6923564672470093 |
421 | 419 | def ExcludePath ( self, path ) : <TAB> """Check to see if this is a service url and matches inbound_services.""" <TAB> skip = False <TAB> for reserved_path in self. reserved_paths. keys ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> not self. inbound_services <TAB> <TAB> <TAB> <TAB> or self. reserved_paths [ reserved_path ] not in self. inbound_services <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> return ( True, self. reserved_paths [ reserved_path ] ) <TAB> return ( False, None ) | False | path.startswith(reserved_path) | path in self.inbound_services[reserved_path] | 0.6445935368537903 |
422 | 420 | def _parse_firstline ( self, line ) : <TAB> try : <TAB> <TAB> if self. kind == 2 : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> self. _parse_request_line ( line ) <TAB> <TAB> <TAB> except InvalidRequestLine : <TAB> <TAB> <TAB> <TAB> self. _parse_response_line ( line ) <TAB> <TAB> elif self. kind == 1 : <TAB> <TAB> <TAB> self. _parse_response_line ( line ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. _parse_request_line ( line ) <TAB> except InvalidRequestLine as e : <TAB> <TAB> self. errno = BAD_FIRST_LINE <TAB> <TAB> self. errstr = str ( e ) <TAB> <TAB> return False <TAB> return True | False | self.kind == 0 | self.kind == 3 | 0.6692343950271606 |
423 | 421 | def compare_multiple_events ( i, expected_results, actual_results ) : <TAB> events_in_a_row = [ ] <TAB> j = i <TAB> while j < len ( expected_results ) and isinstance ( <TAB> <TAB> actual_results [ j ], actual_results [ i ]. __class__ <TAB> ) : <TAB> <TAB> events_in_a_row. append ( actual_results [ j ] ) <TAB> <TAB> j += 1 <TAB> message = "" <TAB> for event in events_in_a_row : <TAB> <TAB> for k in range ( i, j ) : <TAB> <TAB> <TAB> passed, message = compare_events ( expected_results [ k ], event ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> expected_results [ k ] = None <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> return i, False, message <TAB> return j, True, "" | True | passed | passed | 0.6899092197418213 |
424 | 422 | def get_default_region ( ) : <TAB> region = "" <TAB> if "default" in AWS_ACCOUNTS : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> endpoint = AWS_ACCOUNTS [ "default" ]. HOST. get ( ) <TAB> <TAB> <TAB> if re. search ( SUBDOMAIN_ENDPOINT_RE, endpoint, re. IGNORECASE ) : <TAB> <TAB> <TAB> <TAB> region = re. search ( <TAB> <TAB> <TAB> <TAB> <TAB> SUBDOMAIN_ENDPOINT_RE, endpoint, re. IGNORECASE <TAB> <TAB> <TAB> <TAB> ). group ( "region" ) <TAB> <TAB> <TAB> elif re. search ( HYPHEN_ENDPOINT_RE, endpoint, re. IGNORECASE ) : <TAB> <TAB> <TAB> <TAB> region = re. search ( HYPHEN_ENDPOINT_RE, endpoint, re. IGNORECASE ). group ( <TAB> <TAB> <TAB> <TAB> <TAB> "region" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif re. search ( DUALSTACK_ENDPOINT_RE, endpoint, re. IGNORECASE ) : <TAB> <TAB> <TAB> <TAB> region = re. search ( <TAB> <TAB> <TAB> <TAB> <TAB> DUALSTACK_ENDPOINT_RE, endpoint, re. IGNORECASE <TAB> <TAB> <TAB> <TAB> ). group ( "region" ) <TAB> <TAB> elif AWS_ACCOUNTS [ "default" ]. REGION. get ( ) : <TAB> <TAB> <TAB> region = AWS_ACCOUNTS [ "default" ]. REGION. get ( ) <TAB> <TAB> <TAB> <TAB> if region not in get_locations ( ) : <TAB> <TAB> <TAB> LOG. warn ( <TAB> <TAB> <TAB> <TAB> "Region, %s, not found in the list of supported regions: %s" <TAB> <TAB> <TAB> <TAB> % ( region, ", ". join ( get_locations ( ) ) ) <TAB> <TAB> <TAB> ) <TAB> < | False | AWS_ACCOUNTS['default'].HOST.get() | AWS_ACCOUNTS['default'].HOST | 0.6590912342071533 |
425 | 423 | def __init__ ( self, factors, contrast_matrices, num_columns ) : <TAB> self. factors = tuple ( factors ) <TAB> factor_set = frozenset ( factors ) <TAB> if not isinstance ( contrast_matrices, dict ) : <TAB> <TAB> raise ValueError ( "contrast_matrices must be dict" ) <TAB> for factor, contrast_matrix in six. iteritems ( contrast_matrices ) : <TAB> <TAB> if factor not in factor_set : <TAB> <TAB> <TAB> raise ValueError ( "Unexpected factor in contrast_matrices dict" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( "Expected a ContrastMatrix, not %r" % ( contrast_matrix, ) ) <TAB> self. contrast_matrices = contrast_matrices <TAB> if not isinstance ( num_columns, six. integer_types ) : <TAB> <TAB> raise ValueError ( "num_columns must be an integer" ) <TAB> self. num_columns = num_columns | False | not isinstance(contrast_matrix, ContrastMatrix) | contrast_matrix is None | 0.6513559818267822 |
426 | 424 | def resolve ( self, all_profiles, controls_manager = None ) : <TAB> if self. resolved : <TAB> <TAB> return <TAB> self. resolve_controls ( controls_manager ) <TAB> self. resolved_selections = set ( self. selected ) <TAB> if self. extends : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> <TAB> "Profile {name} extends profile {extended}, but " <TAB> <TAB> <TAB> <TAB> "only profiles {known_profiles} are available for resolution.". format ( <TAB> <TAB> <TAB> <TAB> <TAB> name = self. id_, <TAB> <TAB> <TAB> <TAB> <TAB> extended = self. extends, <TAB> <TAB> <TAB> <TAB> <TAB> known_profiles = list ( all_profiles. keys ( ) ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise RuntimeError ( msg ) <TAB> <TAB> extended_profile = all_profiles [ self. extends ] <TAB> <TAB> extended_profile. resolve ( all_profiles, controls_manager ) <TAB> <TAB> self. extend_by ( extended_profile ) <TAB> for uns in self. unselected : <TAB> <TAB> self. resolved_selections. discard ( uns ) <TAB> self. unselected = [ ] <TAB> self. extends = None <TAB> self. selected = sorted ( self. resolved_selections ) <TAB> self. resolved = True | False | self.extends not in all_profiles | self.extended_profiles | 0.6579504013061523 |
427 | 425 | def __init__ ( <TAB> self, <TAB> data_type = "unsupervised", <TAB> transform = None, <TAB> pre_transform = None, <TAB> pre_filter = None, <TAB> empty = False, <TAB> args = None, ) : <TAB> self. data_type = data_type <TAB> self. url = "https://cloud.tsinghua.edu.cn/f/2cac04ee904e4b54b4b2/?dl=1" <TAB> self. root = osp. join ( osp. dirname ( osp. realpath ( __file__ ) ), "../..", "data", "CHEM" ) <TAB> super ( MoleculeDataset, self ). __init__ ( <TAB> <TAB> self. root, transform, pre_transform, pre_filter <TAB> ) <TAB> self. transform, self. pre_transform, self. pre_filter = ( <TAB> <TAB> transform, <TAB> <TAB> pre_transform, <TAB> <TAB> pre_filter, <TAB> ) <TAB> if not empty : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. data, self. slices = torch. load ( self. processed_paths [ 1 ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. data, self. slices = torch. load ( self. processed_paths [ 0 ] ) | False | data_type == 'unsupervised' | args | 0.6502131223678589 |
428 | 426 | def leave ( self, reason = None ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log. info ( "Leaving channel %s (%s)", self, self. id ) <TAB> <TAB> <TAB> self. _bot. api_call ( "conversations.leave", data = { "channel" : self. id } ) <TAB> <TAB> else : <TAB> <TAB> <TAB> log. info ( "Leaving group %s (%s)", self, self. id ) <TAB> <TAB> <TAB> self. _bot. api_call ( "conversations.leave", data = { "channel" : self. id } ) <TAB> except SlackAPIResponseError as e : <TAB> <TAB> if e. error == "user_is_bot" : <TAB> <TAB> <TAB> raise RoomError ( f"Unable to leave channel. {USER_IS_BOT_HELPTEXT}" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise RoomError ( e ) <TAB> self. _id = None | False | self.id.startswith('C') | self._id | 0.6472506523132324 |
429 | 427 | def excluded_files ( self ) : <TAB> ret = [ ] <TAB> try : <TAB> <TAB> file_paths = [ <TAB> <TAB> <TAB> os. path. normpath ( <TAB> <TAB> <TAB> <TAB> os. path. join ( os. path. relpath ( folder, self. folder ), el ) <TAB> <TAB> <TAB> ). replace ( "\\", "/" ) <TAB> <TAB> <TAB> for folder, dirpaths, fs in walk ( self. folder ) <TAB> <TAB> <TAB> for el in fs + dirpaths <TAB> <TAB> ] <TAB> <TAB> if file_paths : <TAB> <TAB> <TAB> paths = to_file_bytes ( "\n". join ( file_paths ) ) <TAB> <TAB> <TAB> out = input_runner ( [ "git", "check-ignore", "--stdin" ], paths, self. folder ) <TAB> <TAB> <TAB> grep_stdout = decode_text ( out ) <TAB> <TAB> <TAB> ret = grep_stdout. splitlines ( ) <TAB> except ( CalledProcessError, IOError, OSError ) as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _output. warn ( <TAB> <TAB> <TAB> <TAB> "Error checking excluded git files: %s. " "Ignoring excluded files" % e <TAB> <TAB> <TAB> ) <TAB> <TAB> ret = [ ] <TAB> return ret | True | self._output | self._output | 0.6693273782730103 |
430 | 428 | def find_internal_python_modules ( <TAB> root_module : types. ModuleType, ) -> Sequence [ Tuple [ str, types. ModuleType ] ] : <TAB> """Returns `(name, module)` for all Haiku submodules under `root_module`.""" <TAB> modules = set ( [ ( root_module. __name__, root_module ) ] ) <TAB> visited = set ( ) <TAB> to_visit = [ root_module ] <TAB> while to_visit : <TAB> <TAB> mod = to_visit. pop ( ) <TAB> <TAB> visited. add ( mod ) <TAB> <TAB> for name in dir ( mod ) : <TAB> <TAB> <TAB> obj = getattr ( mod, name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if obj. __name__. startswith ( "haiku" ) : <TAB> <TAB> <TAB> <TAB> <TAB> to_visit. append ( obj ) <TAB> <TAB> <TAB> <TAB> <TAB> modules. add ( ( obj. __name__, obj ) ) <TAB> return sorted ( modules ) | False | inspect.ismodule(obj) and obj not in visited | obj not in visited | 0.6522250175476074 |
431 | 429 | def __init__ ( <TAB> self, msg = None, data = None, filename = None, password = None, vals = None, file_obj = None ) : <TAB> self. p = None <TAB> self. q = None <TAB> self. g = None <TAB> self. y = None <TAB> self. x = None <TAB> if file_obj is not None : <TAB> <TAB> self. _from_private_key ( file_obj, password ) <TAB> <TAB> return <TAB> if filename is not None : <TAB> <TAB> self. _from_private_key_file ( filename, password ) <TAB> <TAB> return <TAB> if ( msg is None ) and ( data is not None ) : <TAB> <TAB> msg = Message ( data ) <TAB> if vals is not None : <TAB> <TAB> self. p, self. q, self. g, self. y = vals <TAB> else : <TAB> <TAB> if msg is None : <TAB> <TAB> <TAB> raise SSHException ( "Key object may not be empty" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise SSHException ( "Invalid key" ) <TAB> <TAB> self. p = msg. get_mpint ( ) <TAB> <TAB> self. q = msg. get_mpint ( ) <TAB> <TAB> self. g = msg. get_mpint ( ) <TAB> <TAB> self. y = msg. get_mpint ( ) <TAB> self. size = util. bit_length ( self. p ) | False | msg.get_text() != 'ssh-dss' | not msg.has_mpint() | 0.6491572856903076 |
432 | 430 | def test_broadcast ( self ) : <TAB> """Test example broadcast functionality.""" <TAB> self. create_lang_connection ( "1000000000", "en" ) <TAB> self. create_lang_connection ( "1000000001", "en" ) <TAB> self. create_lang_connection ( "1000000002", "en" ) <TAB> self. create_lang_connection ( "1000000003", "es" ) <TAB> self. create_lang_connection ( "1000000004", "es" ) <TAB> app. lang_broadcast ( ) <TAB> self. assertEqual ( 2, len ( self. outbound ) ) <TAB> for message in self. outbound : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( 3, len ( message. connections ) ) <TAB> <TAB> elif message. text == "hola" : <TAB> <TAB> <TAB> self. assertEqual ( 2, len ( message. connections ) ) | False | message.text == 'hello' | message.text == 'contradiction' | 0.6497737169265747 |
433 | 431 | def _map_args ( maps : dict, ** kwargs ) : <TAB> <TAB> output = { } <TAB> for name, val in kwargs. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert isinstance ( maps [ name ], str ) <TAB> <TAB> <TAB> output. update ( { maps [ name ] : val } ) <TAB> <TAB> else : <TAB> <TAB> <TAB> output. update ( { name : val } ) <TAB> for keys in maps. keys ( ) : <TAB> <TAB> if keys not in output. keys ( ) : <TAB> <TAB> <TAB> pass <TAB> return output | True | name in maps | name in maps | 0.6803268194198608 |
434 | 432 | def parse_network_whitelist ( self, network_whitelist_location ) : <TAB> networks = [ ] <TAB> with open ( network_whitelist_location, "r" ) as text_file : <TAB> <TAB> for line in text_file : <TAB> <TAB> <TAB> line = line. strip ( ). strip ( "'" ). strip ( '"' ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> networks. append ( line ) <TAB> return networks | False | isIPv4(line) or isIPv6(line) | line and line.startswith('<TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> < / | 0.6468650102615356 |
435 | 433 | def h_line_down ( self, input ) : <TAB> end_this_line = self. value. find ( "\n", self. cursor_position ) <TAB> if end_this_line == - 1 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. h_exit_down ( None ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. cursor_position = len ( self. value ) <TAB> else : <TAB> <TAB> self. cursor_position = end_this_line + 1 <TAB> <TAB> for x in range ( self. cursorx ) : <TAB> <TAB> <TAB> if self. cursor_position > len ( self. value ) - 1 : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> elif self. value [ self. cursor_position ] == "\n" : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. cursor_position += 1 | False | self.scroll_exit | self.cursorx == 0 | 0.6614938974380493 |
436 | 434 | def lookup_field ( name, obj, model_admin = None ) : <TAB> opts = obj. _meta <TAB> try : <TAB> <TAB> f = _get_non_gfk_field ( opts, name ) <TAB> except ( FieldDoesNotExist, FieldIsAForeignKeyColumnName ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> attr = name <TAB> <TAB> <TAB> value = attr ( obj ) <TAB> <TAB> elif ( <TAB> <TAB> <TAB> model_admin is not None <TAB> <TAB> <TAB> and hasattr ( model_admin, name ) <TAB> <TAB> <TAB> and not name == "__str__" <TAB> <TAB> <TAB> and not name == "__unicode__" <TAB> <TAB> ) : <TAB> <TAB> <TAB> attr = getattr ( model_admin, name ) <TAB> <TAB> <TAB> value = attr ( obj ) <TAB> <TAB> else : <TAB> <TAB> <TAB> attr = getattr ( obj, name ) <TAB> <TAB> <TAB> if callable ( attr ) : <TAB> <TAB> <TAB> <TAB> value = attr ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> value = attr <TAB> <TAB> f = None <TAB> else : <TAB> <TAB> attr = None <TAB> <TAB> value = getattr ( obj, name ) <TAB> return f, attr, value | False | callable(name) | model_admin is None | 0.6619394421577454 |
437 | 435 | def _update_module_index ( self ) : <TAB> self. debug ( "Updating index file..." ) <TAB> <TAB> self. _module_index = [ ] <TAB> <TAB> path = os. path. join ( self. home_path, "modules.yml" ) <TAB> if os. path. exists ( path ) : <TAB> <TAB> with open ( path, "r" ) as infile : <TAB> <TAB> <TAB> self. _module_index = yaml. safe_load ( infile ) <TAB> <TAB> <TAB> <TAB> for module in self. _module_index : <TAB> <TAB> <TAB> status = "not installed" <TAB> <TAB> <TAB> if module [ "path" ] in self. _loaded_category. get ( "disabled", [ ] ) : <TAB> <TAB> <TAB> <TAB> status = "disabled" <TAB> <TAB> <TAB> elif module [ "path" ] in self. _loaded_modules. keys ( ) : <TAB> <TAB> <TAB> <TAB> status = "installed" <TAB> <TAB> <TAB> <TAB> loaded = self. _loaded_modules [ module [ "path" ] ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> status = "outdated" <TAB> <TAB> <TAB> module [ "status" ] = status | False | loaded.meta['version'] != module['version'] | loaded | 0.6473489999771118 |
438 | 436 | def test_nce ( self ) : <TAB> window_size = 5 <TAB> words = [ ] <TAB> for i in range ( window_size ) : <TAB> <TAB> words. append ( layers. data ( name = "word_{0}". format ( i ), shape = [ 1 ], dtype = "int64" ) ) <TAB> dict_size = 10000 <TAB> label_word = int ( window_size // 2 ) + 1 <TAB> embs = [ ] <TAB> for i in range ( window_size ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> emb = layers. embedding ( <TAB> <TAB> <TAB> input = words [ i ], size = [ dict_size, 32 ], param_attr = "emb.w", is_sparse = True <TAB> <TAB> ) <TAB> <TAB> embs. append ( emb ) <TAB> embs = layers. concat ( input = embs, axis = 1 ) <TAB> loss = layers. nce ( <TAB> <TAB> input = embs, <TAB> <TAB> label = words [ label_word ], <TAB> <TAB> num_total_classes = dict_size, <TAB> <TAB> param_attr = "nce.w", <TAB> <TAB> bias_attr = "nce.b", <TAB> ) <TAB> avg_loss = layers. mean ( loss ) <TAB> self. assertIsNotNone ( avg_loss ) <TAB> print ( str ( default_main_program ( ) ) ) | False | i == label_word | label_word == -1 | 0.6597427725791931 |
439 | 437 | def create_if_compatible ( cls, typ : Type, *, root : "RootNode" ) -> Optional [ "Node" ] : <TAB> if cls. compatible_types : <TAB> <TAB> target_type : Type = typ <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> target_type = getattr ( typ, "__origin__", None ) or typ <TAB> <TAB> if cls. _issubclass ( target_type, cls. compatible_types ) : <TAB> <TAB> <TAB> return cls ( typ, root = root ) <TAB> return None | False | cls.use_origin | hasattr(typ, '__origin__') | 0.6618081331253052 |
440 | 438 | def generator ( ) : <TAB> """Yields mutations.""" <TAB> if not self. is_attribute_of_class or not first_posarg or not substs : <TAB> <TAB> return <TAB> try : <TAB> <TAB> inst = abstract_utils. get_atomic_value ( first_posarg, Instance ) <TAB> except abstract_utils. ConversionError : <TAB> <TAB> return <TAB> if inst. cls. template : <TAB> <TAB> for subst in substs : <TAB> <TAB> <TAB> for k, v in subst. items ( ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> value = inst. instance_type_parameters [ k ]. AssignToNewVariable ( node ) <TAB> <TAB> <TAB> <TAB> <TAB> value. PasteVariable ( v, node ) <TAB> <TAB> <TAB> <TAB> <TAB> yield function. Mutation ( inst, k, value ) | True | k in inst.instance_type_parameters | k in inst.instance_type_parameters | 0.6550009250640869 |
441 | 439 | def set_sequences ( self, sequences ) : <TAB> """Set sequences using the given name-to-key-list dictionary.""" <TAB> f = open ( os. path. join ( self. _path, ".mh_sequences" ), "r+", encoding = "ASCII" ) <TAB> try : <TAB> <TAB> os. close ( os. open ( f. name, os. O_WRONLY | os. O_TRUNC ) ) <TAB> <TAB> for name, keys in sequences. items ( ) : <TAB> <TAB> <TAB> if len ( keys ) == 0 : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> f. write ( name + ":" ) <TAB> <TAB> <TAB> prev = None <TAB> <TAB> <TAB> completing = False <TAB> <TAB> <TAB> for key in sorted ( set ( keys ) ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> if not completing : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> completing = True <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> f. write ( "-" ) <TAB> <TAB> <TAB> <TAB> elif completing : <TAB> <TAB> <TAB> <TAB> <TAB> completing = False <TAB> <TAB> <TAB> <TAB> <TAB> f. write ( "%s %s" % ( prev, key ) ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> f. write ( " %s" % key ) <TAB> <TAB> <TAB> <TAB> prev = key <TAB> <TAB> <TAB> if completing : <TAB> <TAB> <TAB> <TAB> f. write ( str ( prev ) + "\n" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> f. write ( "\n" ) <TAB> finally : <TAB> <TAB> _sync_close ( f ) | False | key - 1 == prev | prev is not None | 0.6632115840911865 |
442 | 440 | def on_load_status_changed ( self, widget, * args ) : <TAB> if widget. get_property ( "load-status" ) == WebKit. LoadStatus. FINISHED : <TAB> <TAB> self. _go_back_button. set_sensitive ( widget. can_go_back ( ) ) <TAB> <TAB> self. _forward_button. set_sensitive ( widget. can_go_forward ( ) ) <TAB> <TAB> self. on_size_allocate ( widget ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. is_loaded = True <TAB> <TAB> <TAB> self. emit ( "loaded" ) | False | self.is_loaded == False | not self.is_loaded | 0.6534794569015503 |
443 | 441 | def _get_parents_data ( self, data ) : <TAB> parents = 0 <TAB> if data [ COLUMN_PARENT ] : <TAB> <TAB> family = self. db. get_family_from_handle ( data [ COLUMN_PARENT ] [ 0 ] ) <TAB> <TAB> if family. get_father_handle ( ) : <TAB> <TAB> <TAB> parents += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> parents += 1 <TAB> return parents | False | family.get_mother_handle() | family.get_hather_handle() | 0.6529322862625122 |
444 | 442 | def jobFinished ( self, job ) : <TAB> logger. debug ( "job %s finished", job. id ) <TAB> if job. id in self. activeJobs : <TAB> <TAB> self. last_finish_time = time. time ( ) <TAB> <TAB> del self. activeJobs [ job. id ] <TAB> <TAB> self. activeJobsQueue. remove ( job ) <TAB> <TAB> for tid in self. jobTasks [ job. id ] : <TAB> <TAB> <TAB> self. driver. killTask ( Dict ( value = tid ) ) <TAB> <TAB> del self. jobTasks [ job. id ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. agentTasks. clear ( ) <TAB> for tid, jid in six. iteritems ( self. taskIdToJobId ) : <TAB> <TAB> if jid not in self. activeJobs : <TAB> <TAB> <TAB> logger. debug ( "kill task %s, because it is orphan", tid ) <TAB> <TAB> <TAB> self. driver. killTask ( Dict ( value = tid ) ) | False | not self.activeJobs | self.agentTasks and self.agentTasks[0] | 0.656494677066803 |
445 | 443 | def _validate_tag_field ( value ) : <TAB> <TAB> <TAB> <TAB> for tag in value : <TAB> <TAB> if isinstance ( tag, str ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if isinstance ( tag, ( list, tuple ) ) and len ( tag ) == 2 : <TAB> <TAB> <TAB> name = tag [ 0 ] <TAB> <TAB> <TAB> color = tag [ 1 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if color is None or color == "" : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if isinstance ( color, str ) and re. match ( <TAB> <TAB> <TAB> <TAB> <TAB> "^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$", color <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> "Invalid tag '{value}'. The color is not a " <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> "valid HEX color or null." <TAB> <TAB> <TAB> <TAB> <TAB> ). format ( value = tag ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> "Invalid tag '{value}'. it must be the name or a pair " <TAB> <TAB> <TAB> <TAB> '\'["name", "hex color/" | null]\'.' <TAB> <TAB> <TAB> ). format ( value = tag ) <TAB> <TAB> ) | False | isinstance(name, str) | name is None or name == '' | 0.6513210535049438 |
446 | 444 | def _process_dataloader_aggregated_steps ( result, weights ) : <TAB> internal_keys = { "meta" } <TAB> moved = False <TAB> for k, v in result. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if not isinstance ( v, torch. Tensor ) : <TAB> <TAB> <TAB> v = torch. tensor ( v ) <TAB> <TAB> <TAB> <TAB> if not moved : <TAB> <TAB> <TAB> weights = weights. to ( v. device ) <TAB> <TAB> <TAB> moved = True <TAB> <TAB> <TAB> <TAB> weights_t = weights [ : v. size ( 0 ) ] <TAB> <TAB> <TAB> <TAB> numerator = torch. dot ( v. float ( ), weights_t. transpose ( - 1, 0 ). float ( ) ) <TAB> <TAB> v = numerator / weights. sum ( ). float ( ) <TAB> <TAB> result [ k ] = v | True | k in internal_keys | k in internal_keys | 0.6643571853637695 |
447 | 445 | def __call__ ( cls, * args, ** kwargs ) : <TAB> obj = cls. __new__ ( cls, * args, ** kwargs ) <TAB> from. keras_model import KerasModel <TAB> if issubclass ( cls, KerasModel ) : <TAB> <TAB> from tensorflow. keras import backend as K <TAB> <TAB> if K. backend ( )!= "tensorflow" : <TAB> <TAB> <TAB> obj. __init__ ( * args, ** kwargs ) <TAB> <TAB> <TAB> return obj <TAB> <TAB> K. clear_session ( ) <TAB> <TAB> obj. graph = tf. Graph ( ) <TAB> <TAB> with obj. graph. as_default ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> obj. sess = cls. _config_session ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> obj. sess = tf. Session ( ) <TAB> else : <TAB> <TAB> obj. graph = tf. Graph ( ) <TAB> for meth in dir ( obj ) : <TAB> <TAB> if meth == "__class__" : <TAB> <TAB> <TAB> continue <TAB> <TAB> attr = getattr ( obj, meth ) <TAB> <TAB> if callable ( attr ) : <TAB> <TAB> <TAB> if issubclass ( cls, KerasModel ) : <TAB> <TAB> <TAB> <TAB> wrapped_attr = _keras_wrap ( attr, obj. sess ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> wrapped_attr = _graph_wrap ( attr, obj. graph ) <TAB> <TAB> <TAB> setattr ( obj, meth, wrapped_attr ) <TAB> obj. __init__ ( * args, ** kwargs ) <TAB> return obj | True | hasattr(cls, '_config_session') | hasattr(cls, '_config_session') | 0.6550287008285522 |
448 | 446 | def __getattr__ ( self, attr ) : <TAB> if attr. startswith ( "_" ) : <TAB> <TAB> raise AttributeError ( attr ) <TAB> for name in self : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> else : <TAB> <TAB> raise AttributeError ( "No partition %r" % attr ) <TAB> path = os. path. join ( self. by_name_dir, name ) <TAB> with context. quiet : <TAB> <TAB> <TAB> <TAB> devpath = readlink ( path ) <TAB> <TAB> devname = os. path. basename ( devpath ) <TAB> <TAB> <TAB> <TAB> for blocks, name in self. iter_proc_partitions ( ) : <TAB> <TAB> <TAB> if name in ( devname, attr ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> log. error ( "Could not find size of partition %r" % name ) <TAB> return Partition ( devpath, attr, int ( blocks ) ) | False | name == attr | name in (attr, attr) | 0.6705190539360046 |
449 | 447 | def validate ( self, value ) : <TAB> try : <TAB> <TAB> value = [ <TAB> <TAB> <TAB> datetime. datetime. strptime ( range, "%Y-%m-%d %H:%M:%S" ) <TAB> <TAB> <TAB> for range in value. split ( " to " ) <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return True <TAB> <TAB> else : <TAB> <TAB> <TAB> return False <TAB> except ValueError : <TAB> <TAB> return False | False | len(value) == 2 and value[0] <= value[1] | value | 0.6514225602149963 |
450 | 448 | def _print_cell ( self, space, text, align, width, x, y, fg, attr, bg ) : <TAB> <TAB> if space : <TAB> <TAB> self. _frame. canvas. print_at ( self. _space_delimiter * space, x, y, fg, attr, bg ) <TAB> <TAB> paint_text = _enforce_width ( text, width, self. _frame. canvas. unicode_aware ) <TAB> text_size = self. string_len ( str ( paint_text ) ) <TAB> if text_size < width : <TAB> <TAB> <TAB> <TAB> buffer_1 = buffer_2 = "" <TAB> <TAB> if align == "<" : <TAB> <TAB> <TAB> buffer_2 = " " * ( width - text_size ) <TAB> <TAB> elif align == ">" : <TAB> <TAB> <TAB> buffer_1 = " " * ( width - text_size ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> start_len = int ( ( width - text_size ) / 2 ) <TAB> <TAB> <TAB> buffer_1 = " " * start_len <TAB> <TAB> <TAB> buffer_2 = " " * ( width - text_size - start_len ) <TAB> <TAB> paint_text = paint_text. join ( [ buffer_1, buffer_2 ] ) <TAB> self. _frame. canvas. paint ( <TAB> <TAB> str ( paint_text ), <TAB> <TAB> x + space, <TAB> <TAB> y, <TAB> <TAB> fg, <TAB> <TAB> attr, <TAB> <TAB> bg, <TAB> <TAB> colour_map = paint_text. colour_map if hasattr ( paint_text, "colour_map" ) else None, <TAB> ) | False | align == '^' | align == '<' | 0.6753184795379639 |
451 | 449 | def create_warehouse ( warehouse_name, properties = None, company = None ) : <TAB> if not company : <TAB> <TAB> company = "_Test Company" <TAB> warehouse_id = erpnext. encode_company_abbr ( warehouse_name, company ) <TAB> if not frappe. db. exists ( "Warehouse", warehouse_id ) : <TAB> <TAB> warehouse = frappe. new_doc ( "Warehouse" ) <TAB> <TAB> warehouse. warehouse_name = warehouse_name <TAB> <TAB> warehouse. parent_warehouse = "All Warehouses - _TCUV" <TAB> <TAB> warehouse. company = company <TAB> <TAB> warehouse. account = get_warehouse_account ( warehouse_name, company ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> warehouse. update ( properties ) <TAB> <TAB> warehouse. save ( ) <TAB> <TAB> return warehouse. name <TAB> else : <TAB> <TAB> return warehouse_id | True | properties | properties | 0.6929315328598022 |
452 | 450 | def test_clifford_circuit ( ) : <TAB> ( q0, q1 ) = ( cirq. LineQubit ( 0 ), cirq. LineQubit ( 1 ) ) <TAB> circuit = cirq. Circuit ( ) <TAB> np. random. seed ( 0 ) <TAB> for _ in range ( 100 ) : <TAB> <TAB> x = np. random. randint ( 7 ) <TAB> <TAB> if x == 0 : <TAB> <TAB> <TAB> circuit. append ( cirq. X ( np. random. choice ( ( q0, q1 ) ) ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> circuit. append ( cirq. Z ( np. random. choice ( ( q0, q1 ) ) ) ) <TAB> <TAB> elif x == 2 : <TAB> <TAB> <TAB> circuit. append ( cirq. Y ( np. random. choice ( ( q0, q1 ) ) ) ) <TAB> <TAB> elif x == 3 : <TAB> <TAB> <TAB> circuit. append ( cirq. S ( np. random. choice ( ( q0, q1 ) ) ) ) <TAB> <TAB> elif x == 4 : <TAB> <TAB> <TAB> circuit. append ( cirq. H ( np. random. choice ( ( q0, q1 ) ) ) ) <TAB> <TAB> elif x == 5 : <TAB> <TAB> <TAB> circuit. append ( cirq. CNOT ( q0, q1 ) ) <TAB> <TAB> elif x == 6 : <TAB> <TAB> <TAB> circuit. append ( cirq. CZ ( q0, q1 ) ) <TAB> clifford_simulator = cirq. CliffordSimulator ( ) <TAB> state_vector_simulator = cirq. Simulator ( ) <TAB> np. testing. assert_almost_equal ( <TAB> <TAB> clifford_simulator. simulate ( circuit ). final_state. state_vector ( ), <TAB> <TAB> state_vector_simulator. simulate ( circuit ). final_state_vector, <TAB> ) | True | x == 1 | x == 1 | 0.6688321828842163 |
453 | 451 | def _find_localserver_module ( ) : <TAB> import win32com. server <TAB> path = win32com. server. __path__ [ 0 ] <TAB> baseName = "localserver" <TAB> pyfile = os. path. join ( path, baseName + ".py" ) <TAB> try : <TAB> <TAB> os. stat ( pyfile ) <TAB> except os. error : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ext = ".pyc" <TAB> <TAB> else : <TAB> <TAB> <TAB> ext = ".pyo" <TAB> <TAB> pyfile = os. path. join ( path, baseName + ext ) <TAB> <TAB> try : <TAB> <TAB> <TAB> os. stat ( pyfile ) <TAB> <TAB> except os. error : <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> "Can not locate the Python module 'win32com.server.%s'" % baseName <TAB> <TAB> <TAB> ) <TAB> return pyfile | False | __debug__ | sys.platform == 'win32com' | 0.6698858737945557 |
454 | 452 | def conv2d ( <TAB> input : PTensor, <TAB> weight : PTensor, <TAB> bias : PTensor = None, <TAB> stride = 1, <TAB> padding = 0, <TAB> dilation = 1, <TAB> groups = 1, <TAB> mode = None, ) : <TAB> """Standard conv2d. Returns the input if weight=None.""" <TAB> if weight is None : <TAB> <TAB> return input <TAB> ind = None <TAB> if mode is not None : <TAB> <TAB> if padding!= 0 : <TAB> <TAB> <TAB> raise ValueError ( "Cannot input both padding and mode." ) <TAB> <TAB> if mode == "same" : <TAB> <TAB> <TAB> padding = ( weight. shape [ 2 ] // 2, weight. shape [ 3 ] // 2 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> ind = ( <TAB> <TAB> <TAB> <TAB> <TAB> slice ( - 1 ) if weight. shape [ 2 ] % 2 == 0 else slice ( None ), <TAB> <TAB> <TAB> <TAB> <TAB> slice ( - 1 ) if weight. shape [ 3 ] % 2 == 0 else slice ( None ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> elif mode == "valid" : <TAB> <TAB> <TAB> padding = ( 0, 0 ) <TAB> <TAB> elif mode == "full" : <TAB> <TAB> <TAB> padding = ( weight. shape [ 2 ] - 1, weight. shape [ 3 ] - 1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( "Unknown mode for padding." ) <TAB> assert bias is None <TAB> out = FConv2D ( <TAB> <TAB> input, weight, stride = stride, padding = padding, dilation = dilation, groups = groups <TAB> ) <TAB> if ind is None : <TAB> <TAB> return out <TAB> return out [ :, :, ind [ 0 ], ind [ 1 ] ] | False | weight.shape[2] % 2 == 0 or weight.shape[3] % 2 == 0 | padding != 0 | 0.6526058912277222 |
455 | 453 | def remove_testcases_from_directories ( directories ) : <TAB> """Removes all testcases and their dependencies from testcase directories.""" <TAB> generators = [ ] <TAB> for directory in directories : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> bot_testcases_file_path = utils. get_bot_testcases_file_path ( directory ) <TAB> <TAB> shell. remove_file ( bot_testcases_file_path ) <TAB> <TAB> generators. append ( shell. walk ( directory ) ) <TAB> for generator in generators : <TAB> <TAB> for structure in generator : <TAB> <TAB> <TAB> base_directory = structure [ 0 ] <TAB> <TAB> <TAB> for filename in structure [ 2 ] : <TAB> <TAB> <TAB> <TAB> if not is_testcase_resource ( filename ) : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if filename. startswith ( RESOURCES_PREFIX ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> resources_file_path = os. path. join ( base_directory, filename ) <TAB> <TAB> <TAB> <TAB> <TAB> resources = read_resource_list ( resources_file_path ) <TAB> <TAB> <TAB> <TAB> <TAB> for resource in resources : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> shell. remove_file ( resource ) <TAB> <TAB> <TAB> <TAB> file_path = os. path. join ( base_directory, filename ) <TAB> <TAB> <TAB> <TAB> shell. remove_file ( file_path ) | False | not directory.strip() | not is_testcase_path(directory) | 0.6535124778747559 |
456 | 454 | def test_one_dead_branch ( ) : <TAB> with deterministic_PRNG ( ) : <TAB> <TAB> seen = set ( ) <TAB> <TAB> @ run_to_buffer <TAB> <TAB> def x ( data ) : <TAB> <TAB> <TAB> i = data. draw_bytes ( 1 ) [ 0 ] <TAB> <TAB> <TAB> if i > 0 : <TAB> <TAB> <TAB> <TAB> data. mark_invalid ( ) <TAB> <TAB> <TAB> i = data. draw_bytes ( 1 ) [ 0 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> seen. add ( i ) <TAB> <TAB> <TAB> elif i not in seen : <TAB> <TAB> <TAB> <TAB> data. mark_interesting ( ) | False | len(seen) < 255 | i > 0 | 0.6616944074630737 |
457 | 455 | def _ ( value ) : <TAB> retVal = value <TAB> if value and isinstance ( value, basestring ) and len ( value ) % 2 == 0 : <TAB> <TAB> retVal = hexdecode ( retVal ) <TAB> <TAB> if not kb. binaryField : <TAB> <TAB> <TAB> if Backend. isDbms ( DBMS. MSSQL ) and value. startswith ( "0x" ) : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> retVal = retVal. decode ( "utf-16-le" ) <TAB> <TAB> <TAB> <TAB> except UnicodeDecodeError : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> retVal = retVal. decode ( "utf-16-be" ) <TAB> <TAB> <TAB> <TAB> except UnicodeDecodeError : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> if not isinstance ( retVal, unicode ) : <TAB> <TAB> <TAB> <TAB> retVal = getUnicode ( retVal, "utf8" ) <TAB> return retVal | False | Backend.isDbms(DBMS.HSQLDB) | isinstance(retVal, unicode) | 0.6577309966087341 |
458 | 456 | def mapping ( self ) : <TAB> m = { } <TAB> if getGdriveCredentialsFile ( ) is not None : <TAB> <TAB> m [ "gdrive" ] = "" <TAB> unknown = 0 <TAB> for f in self. scan : <TAB> <TAB> bits = f. split ( "#", 2 ) <TAB> <TAB> if len ( bits ) == 1 : <TAB> <TAB> <TAB> label = os. path. basename ( f ) <TAB> <TAB> else : <TAB> <TAB> <TAB> label = bits [ 1 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> label = "L" + str ( unknown ) <TAB> <TAB> <TAB> unknown += 1 <TAB> <TAB> m [ label ] = bits [ 0 ] <TAB> return m | False | not label or len(label) == 0 or label == '' | unknown > 0 | 0.6542110443115234 |
459 | 457 | def update_schedulers ( self, start = False ) : <TAB> applications_folder = os. path. join ( self. options. folder, "applications" ) <TAB> available_apps = [ <TAB> <TAB> arq <TAB> <TAB> for arq in os. listdir ( applications_folder ) <TAB> <TAB> if os. path. isdir ( os. path. join ( applications_folder, arq ) ) <TAB> ] <TAB> with self. scheduler_processes_lock : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. schedmenu. delete ( 0, "end" ) <TAB> <TAB> for arq in available_apps : <TAB> <TAB> <TAB> if arq not in self. scheduler_processes : <TAB> <TAB> <TAB> <TAB> item = lambda a = arq : self. try_start_scheduler ( a ) <TAB> <TAB> <TAB> <TAB> self. schedmenu. add_command ( label = "start %s" % arq, command = item ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> item = lambda a = arq : self. try_stop_scheduler ( a ) <TAB> <TAB> <TAB> <TAB> self. schedmenu. add_command ( label = "stop %s" % arq, command = item ) <TAB> if start and self. options. with_scheduler and self. options. schedulers : <TAB> <TAB> <TAB> <TAB> apps = [ ag. split ( ":", 1 ) [ 0 ] for ag in self. options. schedulers ] <TAB> else : <TAB> <TAB> apps = [ ] <TAB> for app in apps : <TAB> <TAB> self. try_start_scheduler ( app ) | False | arq in self.scheduler_processes | start | 0.6556118726730347 |
460 | 458 | def TryMerge ( self, d ) : <TAB> while d. avail ( ) > 0 : <TAB> <TAB> tt = d. getVarInt32 ( ) <TAB> <TAB> if tt == 10 : <TAB> <TAB> <TAB> self. set_socket_descriptor ( d. getPrefixedString ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 16 : <TAB> <TAB> <TAB> self. set_requested_events ( d. getVarInt32 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 24 : <TAB> <TAB> <TAB> self. set_observed_events ( d. getVarInt32 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ProtocolBuffer. ProtocolBufferDecodeError <TAB> <TAB> d. skipData ( tt ) | False | tt == 0 | tt > 255 | 0.6810952425003052 |
461 | 459 | def test_adjust_random_hue_in_yiq ( ) : <TAB> x_shapes = [ <TAB> <TAB> [ 2, 2, 3 ], <TAB> <TAB> [ 4, 2, 3 ], <TAB> <TAB> [ 2, 4, 3 ], <TAB> <TAB> [ 2, 5, 3 ], <TAB> <TAB> [ 1000, 1, 3 ], <TAB> ] <TAB> test_styles = [ <TAB> <TAB> "all_random", <TAB> <TAB> "rg_same", <TAB> <TAB> "rb_same", <TAB> <TAB> "gb_same", <TAB> <TAB> "rgb_same", <TAB> ] <TAB> for x_shape in x_shapes : <TAB> <TAB> for test_style in test_styles : <TAB> <TAB> <TAB> x_np = np. random. rand ( * x_shape ) * 255.0 <TAB> <TAB> <TAB> delta_h = ( np. random. rand ( ) * 2.0 - 1.0 ) * np. pi <TAB> <TAB> <TAB> if test_style == "all_random" : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> elif test_style == "rg_same" : <TAB> <TAB> <TAB> <TAB> x_np [..., 1 ] = x_np [..., 0 ] <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> x_np [..., 2 ] = x_np [..., 0 ] <TAB> <TAB> <TAB> elif test_style == "gb_same" : <TAB> <TAB> <TAB> <TAB> x_np [..., 2 ] = x_np [..., 1 ] <TAB> <TAB> <TAB> elif test_style == "rgb_same" : <TAB> <TAB> <TAB> <TAB> x_np [..., 1 ] = x_np [..., 0 ] <TAB> <TAB> <TAB> <TAB> x_np [..., 2 ] = x_np [..., 0 ] | True | test_style == 'rb_same' | test_style == 'rb_same' | 0.6514049768447876 |
462 | 460 | def _get_current_status ( self ) : <TAB> if self. source : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. current_job. status <TAB> <TAB> elif not self. last_job : <TAB> <TAB> <TAB> return "never updated" <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. last_job. status <TAB> else : <TAB> <TAB> return "none" | False | self.current_job and self.current_job.status | self.current_job | 0.6538392305374146 |
463 | 461 | def test_summary ( ) : <TAB> if debug_mode : <TAB> <TAB> if "summary" not in to_test : <TAB> <TAB> <TAB> return <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( "\n\nSUMMARY", end = "" ) <TAB> for ds in datasets : <TAB> <TAB> for dt in ds. dt_s_list : <TAB> <TAB> <TAB> if debug_mode : <TAB> <TAB> <TAB> <TAB> print ( "\n" + dt_s_tup_to_string ( dt ) + ": ", end = "" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> results_sm [ ds ] [ dt ]. summary ( alpha = 0.05 ) <TAB> <TAB> <TAB> exog = results_sm_exog [ ds ] [ dt ]. exog is not None <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> results_sm_exog [ ds ] [ dt ]. summary ( alpha = 0.05 ) <TAB> <TAB> <TAB> exog_coint = results_sm_exog_coint [ ds ] [ dt ]. exog_coint is not None <TAB> <TAB> <TAB> if exog_coint is not None : <TAB> <TAB> <TAB> <TAB> results_sm_exog_coint [ ds ] [ dt ]. summary ( alpha = 0.05 ) | True | exog is not None | exog is not None | 0.6630815267562866 |
464 | 462 | def test_socketserver ( self ) : <TAB> """Using socketserver to create and manage SSL connections.""" <TAB> server = make_https_server ( self, certfile = CERTFILE ) <TAB> <TAB> if<mask> : <TAB> <TAB> sys. stdout. write ( "\n" ) <TAB> with open ( CERTFILE, "rb" ) as f : <TAB> <TAB> d1 = f. read ( ) <TAB> d2 = "" <TAB> <TAB> url = "https://localhost:%d/%s" % ( server. port, os. path. split ( CERTFILE ) [ 1 ] ) <TAB> context = ssl. create_default_context ( cafile = CERTFILE ) <TAB> f = urllib. request. urlopen ( url, context = context ) <TAB> try : <TAB> <TAB> dlen = f. info ( ). get ( "content-length" ) <TAB> <TAB> if dlen and ( int ( dlen ) > 0 ) : <TAB> <TAB> <TAB> d2 = f. read ( int ( dlen ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> sys. stdout. write ( <TAB> <TAB> <TAB> <TAB> <TAB> " client: read %d bytes from remote server '%s'\n" <TAB> <TAB> <TAB> <TAB> <TAB> % ( len ( d2 ), server ) <TAB> <TAB> <TAB> <TAB> ) <TAB> finally : <TAB> <TAB> f. close ( ) <TAB> self. assertEqual ( d1, d2 ) | False | support.verbose | d1 and d2 | 0.6597669720649719 |
465 | 463 | def lex_number ( self, pos ) : <TAB> <TAB> start = pos <TAB> found_dot = False <TAB> while pos < len ( self. string ) and ( <TAB> <TAB> self. string [ pos ]. isdigit ( ) or self. string [ pos ] == "." <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if found_dot is True : <TAB> <TAB> <TAB> <TAB> raise ValueError ( "Invalid number. Found multiple '.'" ) <TAB> <TAB> <TAB> found_dot = True <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pos += 1 <TAB> val = self. string [ start : pos ] <TAB> return Token ( TokenType. LNUM, val, len ( val ) ) | True | self.string[pos] == '.' | self.string[pos] == '.' | 0.6576566100120544 |
466 | 464 | def process_deps ( pipe, pkg, pkgdest, provides, requires ) : <TAB> file = None <TAB> for line in pipe. split ( "\n" ) : <TAB> <TAB> m = file_re. match ( line ) <TAB> <TAB> if m : <TAB> <TAB> <TAB> file = m. group ( 1 ) <TAB> <TAB> <TAB> file = file. replace ( pkgdest + "/" + pkg, "" ) <TAB> <TAB> <TAB> file = file_translate ( file ) <TAB> <TAB> <TAB> continue <TAB> <TAB> m = dep_re. match ( line ) <TAB> <TAB> if not m or not file : <TAB> <TAB> <TAB> continue <TAB> <TAB> type, dep = m. groups ( ) <TAB> <TAB> if type == "R" : <TAB> <TAB> <TAB> i = requires <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> i = provides <TAB> <TAB> else : <TAB> <TAB> <TAB> continue <TAB> <TAB> if dep. startswith ( "python(" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if dep. startswith ( "perl(VMS::" ) or dep. startswith ( "perl(Mac::" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if dep. startswith ( "perl(" ) and dep. endswith ( ".pl)" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if dep. startswith ( "perl" ) and r. search ( dep ) : <TAB> <TAB> <TAB> dep = dep. split ( ) [ 0 ] <TAB> <TAB> <TAB> <TAB> dep = r. sub ( r"(\g<0>)", dep ) <TAB> <TAB> if file not in i : <TAB> <TAB> <TAB> i [ file ] = [ ] <TAB> <TAB> i [ file ]. append ( dep ) <TAB> return | False | type == 'P' | type == 'VMS' | 0.6643229722976685 |
467 | 465 | def translate ( self ) : <TAB> if self. offset : <TAB> <TAB> raise RuntimeError ( "Parser is a one time instance." ) <TAB> while True : <TAB> <TAB> m = self. re_split. search ( self. source [ self. offset : ] ) <TAB> <TAB> if m : <TAB> <TAB> <TAB> text = self. source [ self. offset : self. offset + m. start ( ) ] <TAB> <TAB> <TAB> self. text_buffer. append ( text ) <TAB> <TAB> <TAB> self. offset += m. end ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> line, sep, _ = self. source [ self. offset : ]. partition ( "\n" ) <TAB> <TAB> <TAB> <TAB> self. text_buffer. append ( m. group ( 2 ) + m. group ( 5 ) + line + sep ) <TAB> <TAB> <TAB> <TAB> self. offset += len ( line + sep ) + 1 <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> elif m. group ( 5 ) : <TAB> <TAB> <TAB> <TAB> depr ( "Escape code lines with a backslash." ) <TAB> <TAB> <TAB> <TAB> line, sep, _ = self. source [ self. offset : ]. partition ( "\n" ) <TAB> <TAB> <TAB> <TAB> self. text_buffer. append ( m. group ( 2 ) + line + sep ) <TAB> <TAB> <TAB> <TAB> self. offset += len ( line + sep ) + 1 <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> self. flush_text ( ) <TAB> <TAB> <TAB> self. read_code ( multiline = bool ( m. group ( 4 ) ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> self. text_buffer. append ( self. source [ self. offset : ] ) <TAB> self. flush_text ( ) <TAB> return "". join ( self. code_buffer ) | False | m.group(1) | self.offset | 0.6491327881813049 |
468 | 466 | def test_invite_generation ( event, default_account ) : <TAB> from inbox. events. ical import generate_icalendar_invite <TAB> event. sequence_number = 1 <TAB> event. participants = [ { "email" : "helena@nylas.com" }, { "email" : "myles@nylas.com" } ] <TAB> cal = generate_icalendar_invite ( event ) <TAB> assert cal [ "method" ] == "REQUEST" <TAB> for component in cal. walk ( ) : <TAB> <TAB> if component. name == "VEVENT" : <TAB> <TAB> <TAB> assert component. get ( "summary" ) == event. title <TAB> <TAB> <TAB> assert int ( component. get ( "sequence" ) ) == event. sequence_number <TAB> <TAB> <TAB> assert component. get ( "location" ) == event. location <TAB> <TAB> <TAB> attendees = component. get ( "attendee", [ ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> attendees = [ attendees ] <TAB> <TAB> <TAB> for attendee in attendees : <TAB> <TAB> <TAB> <TAB> email = unicode ( attendee ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if email. lower ( ). startswith ( "mailto:" ) : <TAB> <TAB> <TAB> <TAB> <TAB> email = email [ 7 : ] <TAB> <TAB> <TAB> <TAB> assert email in [ "helena@nylas.com", "myles@nylas.com" ] | False | not isinstance(attendees, list) | attendees | 0.6533714532852173 |
469 | 467 | def remove_duplicate_association ( ) : <TAB> bind = op. get_bind ( ) <TAB> session = Session ( bind = bind ) <TAB> results = session. query ( AssociationTable ). all ( ) <TAB> seen = { } <TAB> for result in results : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> "[-] Duplicate association marked for deletion: {} - {}". format ( <TAB> <TAB> <TAB> <TAB> <TAB> result. user_id, result. account_id <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> session. delete ( result ) <TAB> <TAB> else : <TAB> <TAB> <TAB> seen [ "{}-{}". format ( result. user_id, result. account_id ) ] = True <TAB> print ( "[-->] Deleting duplicate associations..." ) <TAB> session. commit ( ) <TAB> session. flush ( ) <TAB> print ( "[@] Deleted all duplicate associations." ) | False | seen.get('{}-{}'.format(result.user_id, result.account_id)) | result.user_id != result.account_id or seen[result.account_id] != result.account_id | 0.6486219763755798 |
470 | 468 | def set_meta ( self, dataset, overwrite = True, ** kwd ) : <TAB> """Sets the metadata information for datasets previously determined to be in bed format.""" <TAB> i = 0 <TAB> if dataset. has_data ( ) : <TAB> <TAB> for i, line in enumerate ( open ( dataset. file_name ) ) : <TAB> <TAB> <TAB> line = line. rstrip ( "\r\n" ) <TAB> <TAB> <TAB> if line and not line. startswith ( "#" ) : <TAB> <TAB> <TAB> <TAB> elems = line. split ( "\t" ) <TAB> <TAB> <TAB> <TAB> if len ( elems ) > 2 : <TAB> <TAB> <TAB> <TAB> <TAB> if len ( elems ) > 3 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dataset. metadata. nameCol = 4 <TAB> <TAB> <TAB> <TAB> <TAB> if len ( elems ) < 6 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if overwrite or not dataset. metadata. element_is_set ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> "strandCol" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dataset. metadata. strandCol = 0 <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if overwrite or not dataset. metadata. element_is_set ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> "strandCol" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dataset. metadata. strandCol = 6 <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> Tab | False | overwrite or not dataset.metadata.element_is_set('nameCol') | len(dataset.metadata.nameCol) == 0 | 0.6515799760818481 |
471 | 469 | def __remote_port ( self ) : <TAB> port = 22 <TAB> if self. git_has_remote : <TAB> <TAB> m = re. match ( r"^(.*?)?@([^/:]*):?([0-9]+)?", self. git_remote. url ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if m. group ( 3 ) : <TAB> <TAB> <TAB> <TAB> port = m. group ( 3 ) <TAB> return int ( port ) | True | m | m | 0.7070086002349854 |
472 | 470 | def startEntryElement ( self, name, qname, attrs ) : <TAB> """Set new entry with id and the optional entry source (PRIVATE).""" <TAB> if name!= ( None, "entry" ) : <TAB> <TAB> raise ValueError ( "Expected to find the start of an entry element" ) <TAB> if qname is not None : <TAB> <TAB> raise RuntimeError ( "Unexpected qname for entry element" ) <TAB> record = SeqRecord ( "", id = None ) <TAB> if self. speciesName is not None : <TAB> <TAB> record. annotations [ "organism" ] = self. speciesName <TAB> if self. ncbiTaxID is not None : <TAB> <TAB> record. annotations [ "ncbi_taxid" ] = self. ncbiTaxID <TAB> record. annotations [ "source" ] = self. source <TAB> for key, value in attrs. items ( ) : <TAB> <TAB> namespace, localname = key <TAB> <TAB> if namespace is None : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> record. id = value <TAB> <TAB> <TAB> elif localname == "source" : <TAB> <TAB> <TAB> <TAB> record. annotations [ "source" ] = value <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise ValueError ( "Unexpected attribute %s in entry element" % localname ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> "Unexpected namespace '%s' for entry attribute" % namespace <TAB> <TAB> <TAB> ) <TAB> if record. id is None : <TAB> <TAB> raise ValueError ( "Failed to find entry ID" ) <TAB> self. records. append ( record ) <TAB> self. startElementNS = self. startEntryFieldElement <TAB> self. endElementNS = self. endEntryElement | True | localname == 'id' | localname == 'id' | 0.659353494644165 |
473 | 471 | def process_error ( self, data ) : <TAB> if data. get ( "error" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise AuthCanceled ( self, data. get ( "error_description", "" ) ) <TAB> <TAB> raise AuthFailed ( self, data. get ( "error_description" ) or data [ "error" ] ) <TAB> elif "denied" in data : <TAB> <TAB> raise AuthCanceled ( self, data [ "denied" ] ) | False | 'denied' in data['error'] or 'cancelled' in data['error'] | 'error_description' in data | 0.6532981395721436 |
474 | 472 | def __init__ ( self, endog, exog = None, rho = 1, missing = "none", hasconst = None, ** kwargs ) : <TAB> <TAB> if isinstance ( rho, ( int, np. integer ) ) : <TAB> <TAB> self. order = int ( rho ) <TAB> <TAB> self. rho = np. zeros ( self. order, np. float64 ) <TAB> else : <TAB> <TAB> self. rho = np. squeeze ( np. asarray ( rho ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( "AR parameters must be a scalar or a vector" ) <TAB> <TAB> if self. rho. shape == ( ) : <TAB> <TAB> <TAB> self. rho. shape = ( 1, ) <TAB> <TAB> self. order = self. rho. shape [ 0 ] <TAB> if exog is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> super ( GLSAR, self ). __init__ ( <TAB> <TAB> <TAB> endog, <TAB> <TAB> <TAB> np. ones ( ( endog. shape [ 0 ], 1 ) ), <TAB> <TAB> <TAB> missing = missing, <TAB> <TAB> <TAB> hasconst = None, <TAB> <TAB> <TAB> ** kwargs <TAB> <TAB> ) <TAB> else : <TAB> <TAB> super ( GLSAR, self ). __init__ ( endog, exog, missing = missing, ** kwargs ) | False | len(self.rho.shape) not in [0, 1] | not np.isscalar(self.rho) | 0.6566652655601501 |
475 | 473 | def __exit__ ( self, type_ = None, value = None, traceback = None ) : <TAB> reset_Breakpoint ( ) <TAB> sys. settrace ( None ) <TAB> not_empty = "" <TAB> if self. tracer. set_list : <TAB> <TAB> not_empty += "All paired tuples have not been processed, " <TAB> <TAB> not_empty += "the last one was number %d" % self. tracer. expect_set_no <TAB> <TAB> if type_ is not None and issubclass ( BdbNotExpectedError, type_ ) : <TAB> <TAB> if isinstance ( value, BaseException ) and value. args : <TAB> <TAB> <TAB> err_msg = value. args [ 0 ] <TAB> <TAB> <TAB> if not_empty : <TAB> <TAB> <TAB> <TAB> err_msg += "\n" + not_empty <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print ( err_msg ) <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. test_case. fail ( err_msg ) <TAB> <TAB> else : <TAB> <TAB> <TAB> assert False, "BdbNotExpectedError with empty args" <TAB> if not_empty : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( not_empty ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. test_case. fail ( not_empty ) | False | self.dry_run | self.debug | 0.6586962342262268 |
476 | 474 | def __init__ ( self, addr, conf, log, fd = None ) : <TAB> if fd is None : <TAB> <TAB> try : <TAB> <TAB> <TAB> st = os. stat ( addr ) <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> if e. args [ 0 ]!= errno. ENOENT : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> os. remove ( addr ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise ValueError ( "%r is not a socket" % addr ) <TAB> super ( UnixSocket, self ). __init__ ( addr, conf, log, fd = fd ) | False | stat.S_ISSOCK(st.st_mode) | os.path.exists(addr) | 0.6496707201004028 |
477 | 475 | def iter_open_logger_fds ( ) : <TAB> seen = set ( ) <TAB> loggers = list ( values ( logging. Logger. manager. loggerDict ) ) + [ <TAB> <TAB> logging. getLogger ( None ) <TAB> ] <TAB> for l in loggers : <TAB> <TAB> try : <TAB> <TAB> <TAB> for handler in l. handlers : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield handler. stream <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> seen. add ( handler ) <TAB> <TAB> <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> pass | False | handler not in seen | hasattr(handler, 'stream') and (not seen.has_key(handler)) | 0.6733078956604004 |
478 | 476 | def get_all_tracks ( self ) : <TAB> try : <TAB> <TAB> listing = self. __MTPDevice. get_tracklisting ( callback = self. __callback ) <TAB> except Exception as exc : <TAB> <TAB> logger. error ( "unable to get file listing %s (%s)" ) <TAB> tracks = [ ] <TAB> for track in listing : <TAB> <TAB> title = track. title <TAB> <TAB> if not title or title == "" : <TAB> <TAB> <TAB> title = track. filename <TAB> <TAB> if len ( title ) > 50 : <TAB> <TAB> <TAB> title = title [ 0 : 49 ] + "..." <TAB> <TAB> artist = track. artist <TAB> <TAB> if artist and len ( artist ) > 50 : <TAB> <TAB> <TAB> artist = artist [ 0 : 49 ] + "..." <TAB> <TAB> length = track. filesize <TAB> <TAB> age_in_days = 0 <TAB> <TAB> date = self. __mtp_to_date ( track. date ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> modified = track. date <TAB> <TAB> <TAB> modified_sort = - 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> modified = util. format_date ( date ) <TAB> <TAB> <TAB> modified_sort = date <TAB> <TAB> t = SyncTrack ( <TAB> <TAB> <TAB> title, <TAB> <TAB> <TAB> length, <TAB> <TAB> <TAB> modified, <TAB> <TAB> <TAB> modified_sort = modified_sort, <TAB> <TAB> <TAB> mtptrack = track, <TAB> <TAB> <TAB> podcast = artist, <TAB> <TAB> ) <TAB> <TAB> tracks. append ( t ) <TAB> return tracks | False | not date | self.__mode == 'read_date' | 0.6768538951873779 |
479 | 477 | def _dup_file_descriptor ( self, source_fd, dest_fd, mode ) : <TAB> source_fd = int ( source_fd ) <TAB> if source_fd not in self. _descriptors : <TAB> <TAB> raise RedirectionError ( '"%s" is not a valid file descriptor' % str ( source_fd ) ) <TAB> source = self. _descriptors [ source_fd ] <TAB> if source. mode ( )!= mode : <TAB> <TAB> raise RedirectionError ( <TAB> <TAB> <TAB> 'Descriptor %s cannot be duplicated in mode "%s"' % ( str ( source ), mode ) <TAB> <TAB> ) <TAB> if dest_fd == "-" : <TAB> <TAB> <TAB> <TAB> del self. _descriptors [ source_fd ] <TAB> <TAB> source. close ( ) <TAB> else : <TAB> <TAB> dest_fd = int ( dest_fd ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise RedirectionError ( "Cannot replace file descriptor %s" % str ( dest_fd ) ) <TAB> <TAB> dest = self. _descriptors [ dest_fd ] <TAB> <TAB> if dest. mode ( )!= mode : <TAB> <TAB> <TAB> raise RedirectionError ( <TAB> <TAB> <TAB> <TAB> 'Descriptor %s cannot be cannot be redirected in mode "%s"' <TAB> <TAB> <TAB> <TAB> % ( str ( dest ), mode ) <TAB> <TAB> <TAB> ) <TAB> <TAB> self. _descriptors [ dest_fd ] = source. dup ( ) <TAB> <TAB> dest. close ( ) | False | dest_fd not in self._descriptors | dest_fd in self._descriptors | 0.6681382656097412 |
480 | 478 | def get_maxcov_downsample_cl ( data, in_pipe = None ) : <TAB> """Retrieve command line for max coverage downsampling, fitting into bamsormadup output.""" <TAB> max_cov = ( <TAB> <TAB> _get_maxcov_downsample ( data ) if dd. get_aligner ( data ) not in [ "snap" ] else None <TAB> ) <TAB> if max_cov : <TAB> <TAB> if in_pipe == "bamsormadup" : <TAB> <TAB> <TAB> prefix = "level=0" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> prefix = "-l 0" <TAB> <TAB> else : <TAB> <TAB> <TAB> prefix = "" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> core_arg = "" <TAB> <TAB> return "%s | variant - -b %s --mark-as-qc-fail --max-coverage %s" % ( <TAB> <TAB> <TAB> prefix, <TAB> <TAB> <TAB> core_arg, <TAB> <TAB> <TAB> max_cov, <TAB> <TAB> ) <TAB> else : <TAB> <TAB> if in_pipe == "bamsormadup" : <TAB> <TAB> <TAB> prefix = "indexfilename={tx_out_file}.bai" <TAB> <TAB> else : <TAB> <TAB> <TAB> prefix = "" <TAB> <TAB> return prefix | False | in_pipe == 'samtools' | in_pipe == 'gitgit' | 0.6557019948959351 |
481 | 479 | def __init__ ( <TAB> self, fuzzer_name, job_types, stats_columns, group_by, date_start, date_end ) : <TAB> assert group_by <TAB> self. fuzzer_name = fuzzer_name <TAB> self. job_types = job_types <TAB> self. group_by = group_by <TAB> self. date_start = date_start <TAB> self. date_end = date_end <TAB> self. job_run_query = None <TAB> self. testcase_run_query = None <TAB> job_run_fields = [ ] <TAB> testcase_run_fields = [ ] <TAB> fields = parse_stats_column_fields ( stats_columns ) <TAB> for field in fields : <TAB> <TAB> <TAB> <TAB> if not isinstance ( field, QueryField ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if field. table_alias == JobQuery. ALIAS : <TAB> <TAB> <TAB> job_run_fields. append ( field ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> testcase_run_fields. append ( field ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if job_run_fields and self. group_by!= QueryGroupBy. GROUP_BY_TIME : <TAB> <TAB> self. job_run_query = JobQuery ( <TAB> <TAB> <TAB> fuzzer_name, job_types, job_run_fields, group_by, date_start, date_end <TAB> <TAB> ) <TAB> if testcase_run_fields : <TAB> <TAB> self. testcase_run_query = TestcaseQuery ( <TAB> <TAB> <TAB> fuzzer_name, job_types, testcase_run_fields, group_by, date_start, date_end <TAB> <TAB> ) <TAB> assert self. job_run_query or self. testcase_run_query, "Unable to create query." | False | field.table_alias == TestcaseQuery.ALIAS | field.table_alias == TestField.aliased_for_sql | 0.6603524684906006 |
482 | 480 | def create_initial ( self ) : <TAB> pkgs = dict ( ) <TAB> with open ( self. initial_manifest, "w+" ) as manifest : <TAB> <TAB> manifest. write ( self. initial_manifest_file_header ) <TAB> <TAB> for var in self. var_maps [ self. manifest_type ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> split_pkgs = self. _split_multilib ( self. d. getVar ( var ) ) <TAB> <TAB> <TAB> <TAB> if split_pkgs is not None : <TAB> <TAB> <TAB> <TAB> <TAB> pkgs = dict ( list ( pkgs. items ( ) ) + list ( split_pkgs. items ( ) ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> pkg_list = self. d. getVar ( var ) <TAB> <TAB> <TAB> <TAB> if pkg_list is not None : <TAB> <TAB> <TAB> <TAB> <TAB> pkgs [ self. var_maps [ self. manifest_type ] [ var ] ] = self. d. getVar ( var ) <TAB> <TAB> for pkg_type in pkgs : <TAB> <TAB> <TAB> for pkg in pkgs [ pkg_type ]. split ( ) : <TAB> <TAB> <TAB> <TAB> manifest. write ( "%s,%s\n" % ( pkg_type, pkg ) ) | False | var in self.vars_to_split | self.d.getVar(var) is not None | 0.6522716283798218 |
483 | 481 | def parse_object_id ( _, values ) : <TAB> if values : <TAB> <TAB> for key in values : <TAB> <TAB> <TAB> if key. endswith ( "_id" ) : <TAB> <TAB> <TAB> <TAB> val = values [ key ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> values [ key ] = utils. ObjectIdSilent ( val ) <TAB> <TAB> <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> values [ key ] = None | False | len(val) > 10 | hasattr(val, '__getitem__') and val.__getitem__ | 0.6680481433868408 |
484 | 482 | def net ( <TAB> self, input, output_stride = 32, class_dim = 1000, end_points = None, decode_points = None ) : <TAB> self. stride = 2 <TAB> self. block_point = 0 <TAB> self. output_stride = output_stride <TAB> self. decode_points = decode_points <TAB> self. short_cuts = dict ( ) <TAB> with scope ( self. backbone ) : <TAB> <TAB> <TAB> <TAB> data = self. entry_flow ( input ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return data, self. short_cuts <TAB> <TAB> <TAB> <TAB> data = self. middle_flow ( data ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return data, self. short_cuts <TAB> <TAB> <TAB> <TAB> data = self. exit_flow ( data ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return data, self. short_cuts <TAB> <TAB> data = fluid. layers. reduce_mean ( data, [ 2, 3 ], keep_dim = True ) <TAB> <TAB> data = fluid. layers. dropout ( data, 0.5 ) <TAB> <TAB> stdv = 1.0 / math. sqrt ( data. shape [ 1 ] * 1.0 ) <TAB> <TAB> with scope ( "logit" ) : <TAB> <TAB> <TAB> out = fluid. layers. fc ( <TAB> <TAB> <TAB> <TAB> input = data, <TAB> <TAB> <TAB> <TAB> size = class_dim, <TAB> <TAB> <TAB> <TAB> param_attr = fluid. param_attr. ParamAttr ( <TAB> <TAB> <TAB> <TAB> <TAB> name = "fc_weights", <TAB> <TAB> <TAB> <TAB> <TAB> initializer = fluid. initializer. Uniform ( - stdv, stdv ), <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> bias_attr = fluid. param_attr. Param | False | check_points(self.block_point, end_points) | end_points | 0.64871746301651 |
485 | 483 | def deploy_component ( self, components = None ) : <TAB> if self. _train_dsl is None : <TAB> <TAB> raise ValueError ( "Before deploy model, training should be finish!!!" ) <TAB> if components is None : <TAB> <TAB> components = self. _components <TAB> deploy_cpns = [ ] <TAB> for cpn in components : <TAB> <TAB> if isinstance ( cpn, str ) : <TAB> <TAB> <TAB> deploy_cpns. append ( cpn ) <TAB> <TAB> elif isinstance ( cpn, Component ) : <TAB> <TAB> <TAB> deploy_cpns. append ( cpn. name ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> "deploy component parameters is wrong, expect str or Component object, but {} find". format ( <TAB> <TAB> <TAB> <TAB> <TAB> type ( cpn ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> "Component {} does not exist in pipeline". format ( deploy_cpns [ - 1 ] ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if isinstance ( self. _components. get ( deploy_cpns [ - 1 ] ), Reader ) : <TAB> <TAB> <TAB> raise ValueError ( "Reader should not be include in predict pipeline" ) <TAB> res_dict = self. _job_invoker. model_deploy ( <TAB> <TAB> model_id = self. _model_info. model_id, <TAB> <TAB> model_version = self. _model_info. model_version, <TAB> <TAB> cpn_list = deploy_cpns, <TAB> ) <TAB> self. _predict_dsl = self. _job_invoker. get_predict_dsl ( <TAB> <TAB> model_id = res_dict [ "model_id" ], model_version = res_dict [ "model_version" ] <TAB | True | deploy_cpns[-1] not in self._components | deploy_cpns[-1] not in self._components | 0.6595308184623718 |
486 | 484 | def AutoTest ( ) : <TAB> with open ( sys. argv [ 1 ], "rb" ) as f : <TAB> <TAB> for line in f. read ( ). split ( b"\n" ) : <TAB> <TAB> <TAB> line = BYTES2SYSTEMSTR ( line. strip ( ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> elif line. startswith ( "#" ) : <TAB> <TAB> <TAB> <TAB> print ( line ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> print ( ">>> " + line ) <TAB> <TAB> <TAB> <TAB> os. system ( line ) <TAB> <TAB> <TAB> <TAB> sys. stdout. write ( "\npress enter to continue..." ) <TAB> <TAB> <TAB> <TAB> if PY3 : <TAB> <TAB> <TAB> <TAB> <TAB> input ( ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> raw_input ( ) <TAB> <TAB> <TAB> <TAB> sys. stdout. write ( "\n" ) | False | not line | line.startswith(b'#') | 0.6739428043365479 |
487 | 485 | def reposition_division ( f1 ) : <TAB> lines = f1. splitlines ( ) <TAB> if lines [ 2 ] == division : <TAB> <TAB> lines. pop ( 2 ) <TAB> found = 0 <TAB> for i, line in enumerate ( lines ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> found += 1 <TAB> <TAB> <TAB> if found == 2 : <TAB> <TAB> <TAB> <TAB> if division in "\n". join ( lines ) : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> lines. insert ( i + 1, "" ) <TAB> <TAB> <TAB> <TAB> lines. insert ( i + 2, division ) <TAB> <TAB> <TAB> <TAB> break <TAB> return "\n". join ( lines ) | False | line.startswith('"""') | line.startswith(division) | 0.6546669006347656 |
488 | 486 | def _WriteActionParams ( f, actions, counter ) : <TAB> param_names = [ ] <TAB> for key in sorted ( actions ) : <TAB> <TAB> action = actions [ key ] <TAB> <TAB> to_write = None <TAB> <TAB> if isinstance ( action, args. SetToString ) : <TAB> <TAB> <TAB> if action. valid : <TAB> <TAB> <TAB> <TAB> to_write = action. valid <TAB> <TAB> elif isinstance ( action, args. SetNamedOption ) : <TAB> <TAB> <TAB> if action. names : <TAB> <TAB> <TAB> <TAB> to_write = action. names <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if action. names : <TAB> <TAB> <TAB> <TAB> to_write = action. names <TAB> <TAB> if to_write : <TAB> <TAB> <TAB> uniq = counter. next ( ) <TAB> <TAB> <TAB> var_name = "params_%d" % uniq <TAB> <TAB> <TAB> _WriteStrArray ( f, var_name, to_write ) <TAB> <TAB> else : <TAB> <TAB> <TAB> var_name = None <TAB> <TAB> param_names. append ( var_name ) <TAB> return param_names | False | isinstance(action, args.SetNamedAction) | isinstance(action, args.SetSlice) | 0.6523057818412781 |
489 | 487 | def __lt__ ( self, other ) : <TAB> <TAB> try : <TAB> <TAB> A, B = self [ 0 ], other [ 0 ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if A == B : <TAB> <TAB> <TAB> <TAB> return self [ 2 ] < other [ 2 ] <TAB> <TAB> <TAB> return A < B <TAB> <TAB> return self [ 1 ] < other [ 1 ] <TAB> except IndexError : <TAB> <TAB> return NotImplemented | False | A and B | A == other | 0.6828909516334534 |
490 | 488 | def reset ( self ) : <TAB> self. tree. reset ( ) <TAB> self. firstStartTag = False <TAB> self. errors = [ ] <TAB> self. log = [ ] <TAB> <TAB> self. compatMode = "no quirks" <TAB> if self. innerHTMLMode : <TAB> <TAB> self. innerHTML = self. container. lower ( ) <TAB> <TAB> if self. innerHTML in cdataElements : <TAB> <TAB> <TAB> self. tokenizer. state = self. tokenizer. rcdataState <TAB> <TAB> elif self. innerHTML in rcdataElements : <TAB> <TAB> <TAB> self. tokenizer. state = self. tokenizer. rawtextState <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. tokenizer. state = self. tokenizer. plaintextState <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> self. phase = self. phases [ "beforeHtml" ] <TAB> <TAB> self. phase. insertHtmlElement ( ) <TAB> <TAB> self. resetInsertionMode ( ) <TAB> else : <TAB> <TAB> self. innerHTML = False <TAB> <TAB> self. phase = self. phases [ "initial" ] <TAB> self. lastPhase = None <TAB> self. beforeRCDataPhase = None <TAB> self. framesetOK = True | False | self.innerHTML == 'plaintext' | self.innerHTML | 0.6636630296707153 |
491 | 489 | def get_host_metadata ( self ) : <TAB> meta = { } <TAB> if self. agent_url : <TAB> <TAB> try : <TAB> <TAB> <TAB> resp = requests. get ( <TAB> <TAB> <TAB> <TAB> self. agent_url + ECS_AGENT_METADATA_PATH, timeout = 1 <TAB> <TAB> <TAB> ). json ( ) <TAB> <TAB> <TAB> if "Version" in resp : <TAB> <TAB> <TAB> <TAB> match = AGENT_VERSION_EXP. search ( resp. get ( "Version" ) ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> meta [ "ecs_version" ] = match. group ( 1 ) <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> self. log. debug ( "Error getting ECS version: %s" % str ( e ) ) <TAB> return meta | False | match is not None and len(match.groups()) == 1 | match | 0.64990234375 |
492 | 490 | def _build_request ( url : str ) -> HTTPResponse : <TAB> <TAB> <TAB> user_passwd = None <TAB> u = urllib. parse. urlparse ( url ) <TAB> if u. username is not None or u. password is not None : <TAB> <TAB> if u. username and u. password : <TAB> <TAB> <TAB> user_passwd = "%s:%s" % ( u. username, u. password ) <TAB> <TAB> host_port = u. hostname <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> host_port += ":" + str ( u. port ) <TAB> <TAB> url = urllib. parse. urlunparse ( u. _replace ( netloc = host_port ) ) <TAB> <TAB> req = urllib. request. Request ( url ) <TAB> <TAB> req. add_header ( "User-Agent", "SABnzbd/%s" % sabnzbd. __version__ ) <TAB> req. add_header ( "Accept-encoding", "gzip" ) <TAB> if user_passwd : <TAB> <TAB> req. add_header ( <TAB> <TAB> <TAB> "Authorization", <TAB> <TAB> <TAB> "Basic " + ubtou ( base64. b64encode ( utob ( user_passwd ) ) ). strip ( ), <TAB> <TAB> ) <TAB> return urllib. request. urlopen ( req ) | False | u.port | u.port and u.port | 0.668384313583374 |
493 | 491 | def read ( self, iprot ) : <TAB> if ( <TAB> <TAB> iprot. __class__ == TBinaryProtocol. TBinaryProtocolAccelerated <TAB> <TAB> and isinstance ( iprot. trans, TTransport. CReadableTransport ) <TAB> <TAB> and self. thrift_spec is not None <TAB> <TAB> and fastbinary is not None <TAB> ) : <TAB> <TAB> fastbinary. decode_binary ( self, iprot. trans, ( self. __class__, self. thrift_spec ) ) <TAB> <TAB> return <TAB> iprot. readStructBegin ( ) <TAB> while True : <TAB> <TAB> ( fname, ftype, fid ) = iprot. readFieldBegin ( ) <TAB> <TAB> if ftype == TType. STOP : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 1 : <TAB> <TAB> <TAB> if ftype == TType. I64 : <TAB> <TAB> <TAB> <TAB> self. maxColLen = iprot. readI64 ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. DOUBLE : <TAB> <TAB> <TAB> <TAB> self. avgColLen = iprot. readDouble ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if ftype == TType. I64 : <TAB> <TAB> <TAB> <TAB> self. numNulls = iprot. readI64 ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> else : <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> iprot. readFieldEnd ( ) <TAB> iprot. readStructEnd ( ) | True | fid == 3 | fid == 3 | 0.6727274656295776 |
494 | 492 | def writeback ( self, doc_type, body, rule = None, match_body = None ) : <TAB> <TAB> if self. replace_dots_in_field_names : <TAB> <TAB> writeback_body = replace_dots_in_field_names ( body ) <TAB> else : <TAB> <TAB> writeback_body = body <TAB> for key in list ( writeback_body. keys ( ) ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> writeback_body [ key ] = dt_to_ts ( writeback_body [ key ] ) <TAB> if self. debug : <TAB> <TAB> elastalert_logger. info ( "Skipping writing to ES: %s" % ( writeback_body ) ) <TAB> <TAB> return None <TAB> if "@timestamp" not in writeback_body : <TAB> <TAB> writeback_body [ "@timestamp" ] = dt_to_ts ( ts_now ( ) ) <TAB> try : <TAB> <TAB> index = self. writeback_es. resolve_writeback_index ( <TAB> <TAB> <TAB> self. writeback_index, doc_type <TAB> <TAB> ) <TAB> <TAB> if self. writeback_es. is_atleastsixtwo ( ) : <TAB> <TAB> <TAB> res = self. writeback_es. index ( index = index, body = body ) <TAB> <TAB> else : <TAB> <TAB> <TAB> res = self. writeback_es. index ( index = index, doc_type = doc_type, body = body ) <TAB> <TAB> return res <TAB> except ElasticsearchException as e : <TAB> <TAB> logging. exception ( "Error writing alert info to Elasticsearch: %s" % ( e ) ) | False | isinstance(writeback_body[key], datetime.datetime) | key in writeback_body | 0.6496360301971436 |
495 | 493 | def update_sockets ( self ) : <TAB> """Upate sockets based on selected operation""" <TAB> inputs = self. inputs <TAB> if self. operation in Q_operations : <TAB> <TAB> for a in ABC [ 1 : ] : <TAB> <TAB> <TAB> if a in inputs : <TAB> <TAB> <TAB> <TAB> inputs. remove ( inputs [ a ] ) <TAB> elif self. operation in QQ_operations : <TAB> <TAB> for a in ABC [ 2 : ] : <TAB> <TAB> <TAB> if a in inputs : <TAB> <TAB> <TAB> <TAB> inputs. remove ( inputs [ a ] ) <TAB> <TAB> if not "B" in inputs : <TAB> <TAB> <TAB> inputs. new ( "SvQuaternionSocket", "B" ) <TAB> else : <TAB> <TAB> if not "B" in inputs : <TAB> <TAB> <TAB> inputs. new ( "SvQuaternionSocket", "B" ) <TAB> inputs [ "Scale" ]. hide_safe = self. operation!= "SCALE" <TAB> outputs = self. outputs <TAB> if self. operation in output_S_operations : <TAB> <TAB> outputs [ "Quaternion" ]. hide_safe = True <TAB> <TAB> if outputs [ "Value" ]. hide : <TAB> <TAB> <TAB> outputs [ "Value" ]. hide_safe = False <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> outputs [ "Quaternion" ]. hide_safe = False <TAB> <TAB> outputs [ "Value" ]. hide_safe = True <TAB> self. update ( ) | True | outputs['Quaternion'].hide | outputs['Quaternion'].hide | 0.6670730710029602 |
496 | 494 | def _return_poolnumber ( self, nominated_pools ) : <TAB> """Select pool form nominated pools.""" <TAB> selected_pool = - 1 <TAB> min_ldn = 0 <TAB> for pool in nominated_pools : <TAB> <TAB> nld = len ( pool [ "ld_list" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> selected_pool = pool [ "pool_num" ] <TAB> <TAB> <TAB> min_ldn = nld <TAB> if selected_pool < 0 : <TAB> <TAB> msg = _ ( "No available pools found." ) <TAB> <TAB> raise exception. VolumeBackendAPIException ( data = msg ) <TAB> return selected_pool | False | selected_pool == -1 or min_ldn > nld | nld > min_ldn | 0.6589834094047546 |
497 | 495 | def __call__ ( self, x : JaxArray, training : bool ) -> JaxArray : <TAB> if self. stride > 1 : <TAB> <TAB> shortcut = objax. functional. max_pool_2d ( x, size = 1, strides = self. stride ) <TAB> else : <TAB> <TAB> shortcut = x <TAB> for i, ( bn_i, conv_i ) in enumerate ( self. layers ) : <TAB> <TAB> x = bn_i ( x, training ) <TAB> <TAB> x = self. activation_fn ( x ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> shortcut = self. proj_conv ( x ) <TAB> <TAB> x = conv_i ( x ) <TAB> return x + shortcut | False | i == 0 and self.use_projection | self.proj_conv is not None | 0.6522647142410278 |
498 | 496 | def tokens ( self, event, next ) : <TAB> kind, data, _ = event <TAB> if kind == START : <TAB> <TAB> tag, attribs = data <TAB> <TAB> name = tag. localname <TAB> <TAB> namespace = tag. namespace <TAB> <TAB> converted_attribs = { } <TAB> <TAB> for k, v in attribs : <TAB> <TAB> <TAB> if isinstance ( k, QName ) : <TAB> <TAB> <TAB> <TAB> converted_attribs [ ( k. namespace, k. localname ) ] = v <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> converted_attribs [ ( None, k ) ] = v <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for token in self. emptyTag ( <TAB> <TAB> <TAB> <TAB> namespace, <TAB> <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> <TAB> converted_attribs, <TAB> <TAB> <TAB> <TAB> not next or next [ 0 ]!= END or next [ 1 ]!= tag, <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> yield token <TAB> <TAB> else : <TAB> <TAB> <TAB> yield self. startTag ( namespace, name, converted_attribs ) <TAB> elif kind == END : <TAB> <TAB> name = data. localname <TAB> <TAB> namespace = data. namespace <TAB> <TAB> if namespace!= namespaces [ "html" ] or name not in voidElements : <TAB> <TAB> <TAB> yield self. endTag ( namespace, name ) <TAB> elif kind == COMMENT : <TAB> <TAB> yield self. comment ( data ) <TAB> elif kind == TEXT : <TAB> <TAB> for token in self. text ( data ) : <TAB> <TAB> <TAB> yield token <TAB> elif kind == DOCTYPE : <TAB> <TAB> yield self. doctype ( * data ) <TAB> elif kind in ( XML_NAMESPACE, DOCTYPE, START_NS, END_NS, START_CDATA, END_CDATA, PI ) : <TAB> < | False | namespace == namespaces['html'] and name in voidElements | kind == START | 0.6586155891418457 |
499 | 497 | def slowSorted ( qq ) : <TAB> "Reference sort peformed by insertion using only <" <TAB> rr = list ( ) <TAB> for q in qq : <TAB> <TAB> i = 0 <TAB> <TAB> for i in range ( len ( rr ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> rr. insert ( i, q ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> rr. append ( q ) <TAB> return rr | False | q < rr[i] | i < len(q) - 1 | 0.6682837009429932 |
500 | 498 | def read ( self, iprot ) : <TAB> if ( <TAB> <TAB> iprot. __class__ == TBinaryProtocol. TBinaryProtocolAccelerated <TAB> <TAB> and isinstance ( iprot. trans, TTransport. CReadableTransport ) <TAB> <TAB> and self. thrift_spec is not None <TAB> <TAB> and fastbinary is not None <TAB> ) : <TAB> <TAB> fastbinary. decode_binary ( self, iprot. trans, ( self. __class__, self. thrift_spec ) ) <TAB> <TAB> return <TAB> iprot. readStructBegin ( ) <TAB> while True : <TAB> <TAB> ( fname, ftype, fid ) = iprot. readFieldBegin ( ) <TAB> <TAB> if ftype == TType. STOP : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 1 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. db_name = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. tbl_name = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 3 : <TAB> <TAB> <TAB> if ftype == TType. LIST : <TAB> <TAB> <TAB> <TAB> self. part_vals = [ ] <TAB> <TAB> <TAB> <TAB> ( _etype725, _size722 ) = iprot. readListBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i726 in xrange ( _size722 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _elem727 = iprot. readString ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. part_vals. append ( _elem727 ) <TAB> | True | ftype == TType.STRING | ftype == TType.STRING | 0.663554310798645 |
501 | 499 | def set_random_avatar ( user ) : <TAB> galleries = get_available_galleries ( include_default = True ) <TAB> if not galleries : <TAB> <TAB> raise RuntimeError ( "no avatar galleries are set" ) <TAB> avatars_list = [ ] <TAB> for gallery in galleries : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> avatars_list = gallery [ "images" ] <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> avatars_list += gallery [ "images" ] <TAB> random_avatar = random. choice ( avatars_list ) <TAB> store. store_new_avatar ( user, Image. open ( random_avatar. image ) ) | False | gallery['name'] == DEFAULT_GALLERY | include_default | 0.6590063571929932 |
502 | 500 | def fetch_rvalue ( self ) -> List [ Token ] : <TAB> """Fetch right-hand value of assignment.""" <TAB> tokens = [ ] <TAB> while self. fetch_token ( ) : <TAB> <TAB> tokens. append ( self. current ) <TAB> <TAB> if self. current == [ OP, "(" ] : <TAB> <TAB> <TAB> tokens += self. fetch_until ( [ OP, ")" ] ) <TAB> <TAB> elif self. current == [ OP, "{" ] : <TAB> <TAB> <TAB> tokens += self. fetch_until ( [ OP, "}" ] ) <TAB> <TAB> elif self. current == [ OP, "[" ] : <TAB> <TAB> <TAB> tokens += self. fetch_until ( [ OP, "]" ] ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> tokens += self. fetch_until ( DEDENT ) <TAB> <TAB> elif self. current == [ OP, ";" ] : <TAB> <TAB> <TAB> break <TAB> <TAB> elif self. current. kind not in ( OP, NAME, NUMBER, STRING ) : <TAB> <TAB> <TAB> break <TAB> return tokens | False | self.current == INDENT | self.current == [DEDENT] | 0.6982951164245605 |
503 | 501 | def describe ( self, done = False ) : <TAB> description = ShellCommand. describe ( self, done ) <TAB> if done : <TAB> <TAB> if not description : <TAB> <TAB> <TAB> description = [ "compile" ] <TAB> <TAB> description. append ( "%d projects" % self. getStatistic ( "projects", 0 ) ) <TAB> <TAB> description. append ( "%d files" % self. getStatistic ( "files", 0 ) ) <TAB> <TAB> warnings = self. getStatistic ( "warnings", 0 ) <TAB> <TAB> if warnings > 0 : <TAB> <TAB> <TAB> description. append ( "%d warnings" % warnings ) <TAB> <TAB> errors = self. getStatistic ( "errors", 0 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> description. append ( "%d errors" % errors ) <TAB> return description | True | errors > 0 | errors > 0 | 0.6735945343971252 |
504 | 502 | def notify ( self, message = "", data = None, listener = None ) : <TAB> if not data : <TAB> <TAB> data = { } <TAB> nma = pynma. PyNMA ( ) <TAB> keys = splitString ( self. conf ( "api_key" ) ) <TAB> nma. addkey ( keys ) <TAB> nma. developerkey ( self. conf ( "dev_key" ) ) <TAB> response = nma. push ( <TAB> <TAB> application = self. default_title, <TAB> <TAB> event = message. split ( " " ) [ 0 ], <TAB> <TAB> description = message, <TAB> <TAB> priority = self. conf ( "priority" ), <TAB> <TAB> batch_mode = len ( keys ) > 1, <TAB> ) <TAB> successful = 0 <TAB> for key in keys : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log. error ( <TAB> <TAB> <TAB> <TAB> "Could not send notification to NotifyMyAndroid (%s). %s", <TAB> <TAB> <TAB> <TAB> ( key, response [ key ] [ "message" ] ), <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> successful += 1 <TAB> return successful == len ( keys ) | False | not response[str(key)]['code'] == six.u('200') | not self.notify_mute(key, listener) | 0.6516914963722229 |
505 | 503 | def _run_and_test ( self, hparams, test_transform = False ) : <TAB> <TAB> scalar_data = ScalarData ( hparams ) <TAB> self. assertEqual ( scalar_data. list_items ( ) [ 0 ], hparams [ "dataset" ] [ "data_name" ] ) <TAB> iterator = DataIterator ( scalar_data ) <TAB> i = 0 <TAB> for batch in iterator : <TAB> <TAB> self. assertEqual ( set ( batch. keys ( ) ), set ( scalar_data. list_items ( ) ) ) <TAB> <TAB> value = batch [ scalar_data. data_name ] [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( 2 * i, value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. assertEqual ( i, value ) <TAB> <TAB> i += 1 <TAB> <TAB> data_type = hparams [ "dataset" ] [ "data_type" ] <TAB> <TAB> if data_type == "int" : <TAB> <TAB> <TAB> self. assertEqual ( value. dtype, torch. int32 ) <TAB> <TAB> elif data_type == "float" : <TAB> <TAB> <TAB> self. assertEqual ( value. dtype, torch. float32 ) <TAB> <TAB> elif data_type == "bool" : <TAB> <TAB> <TAB> self. assertTrue ( value. dtype, torch_bool ) <TAB> <TAB> self. assertIsInstance ( value, torch. Tensor ) | True | test_transform | test_transform | 0.665885329246521 |
506 | 504 | def check_WinExec ( self, emu ) : <TAB> profile = emu. emu_profile_output. decode ( ) <TAB> while True : <TAB> <TAB> offset = profile. find ( "WinExec" ) <TAB> <TAB> if offset < 0 : <TAB> <TAB> <TAB> break <TAB> <TAB> profile = profile [ offset : ] <TAB> <TAB> p = profile. split ( ";" ) <TAB> <TAB> if not p : <TAB> <TAB> <TAB> profile = profile [ 1 : ] <TAB> <TAB> <TAB> continue <TAB> <TAB> s = p [ 0 ]. split ( '"' ) <TAB> <TAB> if len ( s ) < 2 : <TAB> <TAB> <TAB> profile = profile [ 1 : ] <TAB> <TAB> <TAB> continue <TAB> <TAB> url = s [ 1 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> profile = profile [ 1 : ] <TAB> <TAB> <TAB> continue <TAB> <TAB> self. retrieve_WinExec ( url ) <TAB> <TAB> profile = profile [ 1 : ] | False | not url.startswith('\\\\') | url.find('/') < 0 | 0.6551992893218994 |
507 | 505 | def convert_path ( ctx, tpath ) : <TAB> for points, code in tpath. iter_segments ( ) : <TAB> <TAB> if code == Path. MOVETO : <TAB> <TAB> <TAB> ctx. move_to ( * points ) <TAB> <TAB> elif code == Path. LINETO : <TAB> <TAB> <TAB> ctx. line_to ( * points ) <TAB> <TAB> elif code == Path. CURVE3 : <TAB> <TAB> <TAB> ctx. curve_to ( <TAB> <TAB> <TAB> <TAB> points [ 0 ], points [ 1 ], points [ 0 ], points [ 1 ], points [ 2 ], points [ 3 ] <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> ctx. curve_to ( * points ) <TAB> <TAB> elif code == Path. CLOSEPOLY : <TAB> <TAB> <TAB> ctx. close_path ( ) | False | code == Path.CURVE4 | code == Path.CURVE | 0.6630367040634155 |
508 | 506 | def msg_ser ( inst, sformat, lev = 0 ) : <TAB> if sformat in [ "urlencoded", "json" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> res = inst. serialize ( sformat, lev ) <TAB> <TAB> else : <TAB> <TAB> <TAB> res = inst <TAB> elif sformat == "dict" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> res = inst. serialize ( sformat, lev ) <TAB> <TAB> elif isinstance ( inst, dict ) : <TAB> <TAB> <TAB> res = inst <TAB> <TAB> elif isinstance ( inst, str ) : <TAB> <TAB> <TAB> res = inst <TAB> <TAB> else : <TAB> <TAB> <TAB> raise MessageException ( "Wrong type: %s" % type ( inst ) ) <TAB> else : <TAB> <TAB> raise PyoidcError ( "Unknown sformat", inst ) <TAB> return res | False | isinstance(inst, Message) | isinstance(inst, list) | 0.6594626903533936 |
509 | 507 | def tokeneater ( self, type, token, srow_scol, erow_ecol, line ) : <TAB> srow, scol = srow_scol <TAB> erow, ecol = erow_ecol <TAB> if not self. started : <TAB> <TAB> <TAB> <TAB> if token in ( "def", "class", "lambda" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. islambda = True <TAB> <TAB> <TAB> self. started = True <TAB> <TAB> self. passline = True <TAB> elif type == tokenize. NEWLINE : <TAB> <TAB> self. passline = False <TAB> <TAB> self. last = srow <TAB> <TAB> if self. islambda : <TAB> <TAB> <TAB> raise EndOfBlock <TAB> elif self. passline : <TAB> <TAB> pass <TAB> elif type == tokenize. INDENT : <TAB> <TAB> self. indent = self. indent + 1 <TAB> <TAB> self. passline = True <TAB> elif type == tokenize. DEDENT : <TAB> <TAB> self. indent = self. indent - 1 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. indent <= 0 : <TAB> <TAB> <TAB> raise EndOfBlock <TAB> elif self. indent == 0 and type not in ( tokenize. COMMENT, tokenize. NL ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise EndOfBlock | False | token == 'lambda' | token == tokenize.START | 0.6736103296279907 |
510 | 508 | def precheck ( self, runner, script, info ) : <TAB> <TAB> if getattr ( script, "modelVars", None ) is None : <TAB> <TAB> script. modelVars = { } <TAB> <TAB> if isinstance ( info, ast. Assign ) : <TAB> <TAB> if isinstance ( info. value, ast. Call ) : <TAB> <TAB> <TAB> if isinstance ( info. value. func, ast. Name ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> for target in info. targets : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( target, ast. Name ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> script. modelVars [ target. id ] = info. value. func. id <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif isinstance ( target, ast. Tuple ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for elt in target. elts : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( elt, ast. Name ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> script. modelVars [ elt. id ] = info. value. func. id <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> for target in info. targets : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( target, ast. Name ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if target. id in script. modelVars : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> del script. modelVars [ target. id ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif isinstance ( target, ast. Tuple ) : <TAB> <TAB> <TAB> <TAB | False | info.value.func.id.endswith('Model') | isinstance(target, ast.List) | 0.6484423279762268 |
511 | 509 | def _load_ui_modules ( self, modules : Any ) -> None : <TAB> if isinstance ( modules, types. ModuleType ) : <TAB> <TAB> self. _load_ui_modules ( dict ( ( n, getattr ( modules, n ) ) for n in dir ( modules ) ) ) <TAB> elif isinstance ( modules, list ) : <TAB> <TAB> for m in modules : <TAB> <TAB> <TAB> self. _load_ui_modules ( m ) <TAB> else : <TAB> <TAB> assert isinstance ( modules, dict ) <TAB> <TAB> for name, cls in modules. items ( ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. ui_modules [ name ] = cls <TAB> <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> <TAB> pass | False | issubclass(cls, UIModule) | cls is not None | 0.6570519208908081 |
512 | 510 | def postprocess_message ( self, msg ) : <TAB> if msg [ "type" ] in ( "subsample", "param" ) and self. dim is not None : <TAB> <TAB> event_dim = msg [ "kwargs" ]. get ( "event_dim" ) <TAB> <TAB> if event_dim is not None : <TAB> <TAB> <TAB> assert event_dim >= 0 <TAB> <TAB> <TAB> dim = self. dim - event_dim <TAB> <TAB> <TAB> shape = jnp. shape ( msg [ "value" ] ) <TAB> <TAB> <TAB> if len ( shape ) >= - dim and shape [ dim ]!= 1 : <TAB> <TAB> <TAB> <TAB> if shape [ dim ]!= self. size : <TAB> <TAB> <TAB> <TAB> <TAB> if msg [ "type" ] == "param" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> statement = "numpyro.param({},..., event_dim={})". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> msg [ "name" ], event_dim <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> statement = "numpyro.subsample(..., event_dim={})". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> event_dim <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> "Inside numpyro.plate({}, {}, dim={}) invalid shape of {}: {}". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. name, self. size, self. dim, statement, shape <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> < | False | self.subsample_size < self.size | self.dim is not None | 0.6525208353996277 |
513 | 511 | def forward ( self, input ) : <TAB> s0 = s1 = self. stem ( input ) <TAB> weights2 = None <TAB> for i, cell in enumerate ( self. cells ) : <TAB> <TAB> if cell. reduction : <TAB> <TAB> <TAB> weights = fluid. layers. softmax ( self. alphas_reduce ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> n = 3 <TAB> <TAB> <TAB> <TAB> start = 2 <TAB> <TAB> <TAB> <TAB> weights2 = fluid. layers. softmax ( self. betas_reduce [ 0 : 2 ] ) <TAB> <TAB> <TAB> <TAB> for i in range ( self. _steps - 1 ) : <TAB> <TAB> <TAB> <TAB> <TAB> end = start + n <TAB> <TAB> <TAB> <TAB> <TAB> tw2 = fluid. layers. softmax ( self. betas_reduce [ start : end ] ) <TAB> <TAB> <TAB> <TAB> <TAB> start = end <TAB> <TAB> <TAB> <TAB> <TAB> n += 1 <TAB> <TAB> <TAB> <TAB> <TAB> weights2 = fluid. layers. concat ( [ weights2, tw2 ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> weights = fluid. layers. softmax ( self. alphas_normal ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> n = 3 <TAB> <TAB> <TAB> <TAB> start = 2 <TAB> <TAB> <TAB> <TAB> weights2 = fluid. layers. softmax ( self. betas_normal [ 0 : 2 ] ) <TAB> <TAB> <TAB> <TAB> for i in range ( self. _steps - 1 ) : <TAB> <TAB> <TAB> <TAB> <TAB> end = start + n <TAB> <TAB> <TAB> <TAB> <TAB> tw2 = fluid. layers. softmax ( self. betas_normal [ start : end ] ) <TAB> <TAB> <TAB> <TAB> <TAB> start = end | False | self._method == 'PC-DARTS' | self.betas_normal is not None | 0.6522391438484192 |
514 | 512 | def read ( self, iprot ) : <TAB> if ( <TAB> <TAB> iprot. __class__ == TBinaryProtocol. TBinaryProtocolAccelerated <TAB> <TAB> and isinstance ( iprot. trans, TTransport. CReadableTransport ) <TAB> <TAB> and self. thrift_spec is not None <TAB> <TAB> and fastbinary is not None <TAB> ) : <TAB> <TAB> fastbinary. decode_binary ( self, iprot. trans, ( self. __class__, self. thrift_spec ) ) <TAB> <TAB> return <TAB> iprot. readStructBegin ( ) <TAB> while True : <TAB> <TAB> ( fname, ftype, fid ) = iprot. readFieldBegin ( ) <TAB> <TAB> if ftype == TType. STOP : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 1 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. username = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. password = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 3 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. consumerKey = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 4 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. consumerSecret = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> else : <TAB> <TAB> < | False | ftype == TType.STRING | fid == 5 | 0.6608601808547974 |
515 | 513 | def include ( elem, loader = None ) : <TAB> if loader is None : <TAB> <TAB> loader = default_loader <TAB> <TAB> i = 0 <TAB> while i < len ( elem ) : <TAB> <TAB> e = elem [ i ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> href = e. get ( "href" ) <TAB> <TAB> <TAB> parse = e. get ( "parse", "xml" ) <TAB> <TAB> <TAB> if parse == "xml" : <TAB> <TAB> <TAB> <TAB> node = loader ( href, parse ) <TAB> <TAB> <TAB> <TAB> if node is None : <TAB> <TAB> <TAB> <TAB> <TAB> raise FatalIncludeError ( "cannot load %r as %r" % ( href, parse ) ) <TAB> <TAB> <TAB> <TAB> node = copy. copy ( node ) <TAB> <TAB> <TAB> <TAB> if e. tail : <TAB> <TAB> <TAB> <TAB> <TAB> node. tail = ( node. tail or "" ) + e. tail <TAB> <TAB> <TAB> <TAB> elem [ i ] = node <TAB> <TAB> <TAB> elif parse == "text" : <TAB> <TAB> <TAB> <TAB> text = loader ( href, parse, e. get ( "encoding" ) ) <TAB> <TAB> <TAB> <TAB> if text is None : <TAB> <TAB> <TAB> <TAB> <TAB> raise FatalIncludeError ( "cannot load %r as %r" % ( href, parse ) ) <TAB> <TAB> <TAB> <TAB> if i : <TAB> <TAB> <TAB> <TAB> <TAB> node = elem [ i - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> node. tail = ( node. tail or "" ) + text <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> elem. text = ( elem. text or "" ) + text + ( e. tail or "" ) < | False | e.tag == XINCLUDE_INCLUDE | e | 0.6595921516418457 |
516 | 514 | def make_row ( self ) : <TAB> res = [ ] <TAB> for i in range ( self. num_cols ) : <TAB> <TAB> t = sqlite3_column_type ( self. stmnt, i ) <TAB> <TAB> <TAB> <TAB> if t == SQLITE_INTEGER : <TAB> <TAB> <TAB> res. append ( sqlite3_column_int ( self. stmnt, i ) ) <TAB> <TAB> elif t == SQLITE_FLOAT : <TAB> <TAB> <TAB> res. append ( sqlite3_column_double ( self. stmnt, i ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> res. append ( sqlite3_column_text ( self. stmnt, i ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise NotImplementedError <TAB> return tuple ( res ) | True | t == SQLITE_TEXT | t == SQLITE_TEXT | 0.6896180510520935 |
517 | 515 | def startNotificationService ( self ) : <TAB> if self. __enabled : <TAB> <TAB> if self. __polling_service : <TAB> <TAB> <TAB> self. __polling_service. startNotificationService ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. __os_file_service. startNotificationService ( ) | False | self.os_notifications_available | self.__os_file_service | 0.6588118076324463 |
518 | 516 | def add_to_path ( self, fnames ) : <TAB> """Add fnames to path""" <TAB> indexes = [ ] <TAB> for path in fnames : <TAB> <TAB> project = self. get_source_project ( path ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. parent_widget. emit ( SIGNAL ( "pythonpath_changed()" ) ) <TAB> <TAB> <TAB> indexes. append ( self. get_index ( path ) ) <TAB> if indexes : <TAB> <TAB> self. reset_icon_provider ( ) <TAB> <TAB> for index in indexes : <TAB> <TAB> <TAB> self. update ( index ) | False | project.add_to_pythonpath(path) | project | 0.650256872177124 |
519 | 517 | def test_adding_a_mutually_exclusive_label_replaces_the_other ( <TAB> db, api_client, default_account, folder_and_message_maps, label ) : <TAB> <TAB> <TAB> <TAB> <TAB> folder_map, message_map = folder_and_message_maps <TAB> label_to_add = folder_map [ label ] <TAB> for key in message_map : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> message = message_map [ key ] <TAB> <TAB> resp_data = api_client. get_data ( "/messages/{}". format ( message. public_id ) ) <TAB> <TAB> labels = resp_data [ "labels" ] <TAB> <TAB> assert len ( labels ) == 1 <TAB> <TAB> assert labels [ 0 ] [ "name" ] == key <TAB> <TAB> existing_label = labels [ 0 ] [ "id" ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> response = api_client. put_data ( <TAB> <TAB> <TAB> "/messages/{}". format ( message. public_id ), <TAB> <TAB> <TAB> { "label_ids" : [ label_to_add. category. public_id, existing_label ] }, <TAB> <TAB> ) <TAB> <TAB> labels = json. loads ( response. data ) [ "labels" ] <TAB> <TAB> assert len ( labels ) == 1 <TAB> <TAB> assert labels [ 0 ] [ "name" ] == label | False | key == label | key == 'public_id' | 0.6733598113059998 |